wp-list-categories

Wordpress Categories and SubCategories

血红的双手。 提交于 2020-01-06 18:10:46
问题 I am doing some changes on my blog theme, and i need to list the subcategories when user is inside the parent category, example: main-category -- subcat1 -- subcat2 So i need to show the subcat1 and subcat2 only when the user is inside main-category. At this moment i have 2 divs, one for the main-categories (this is what i need users to see on all pages) and one div bellow the main-category div to show the subcategories. Is this possible? I am sorry for my English, let me know if this is too

Wordpress Categories and SubCategories

元气小坏坏 提交于 2020-01-06 18:10:30
问题 I am doing some changes on my blog theme, and i need to list the subcategories when user is inside the parent category, example: main-category -- subcat1 -- subcat2 So i need to show the subcat1 and subcat2 only when the user is inside main-category. At this moment i have 2 divs, one for the main-categories (this is what i need users to see on all pages) and one div bellow the main-category div to show the subcategories. Is this possible? I am sorry for my English, let me know if this is too

Add current_cat class on wp_list_categories when I'm on single with custom taxonomy

浪尽此生 提交于 2019-12-13 21:23:07
问题 I search all the web for that answer. I use wp_list_categories to make a submenu with custom taxonomy, It works well, and puts current-cat when I browse those categories. The thing is, when I browse single posts with this menu, the highlight no more works. For the blog part of that site, I use the following code to highlight current category on wp_list_categories(): function sgr_show_current_cat_on_single($output) { global $post; if( is_single() ) { $categories = wp_get_post_categories($post-

WORDPRESS: Display list of Sub-Categories and the posts they contain, within one main Category

半腔热情 提交于 2019-12-13 17:00:26
问题 I've found tons of code and plugins to do various things; from show posts for specific cats, subcats of a cat, etc.. BUT, I cannot for the life of me find, nor do I know the WP API well enough to do what I need with it.. Here is what I'm trying to accomplish: Display a UL of all subcats within Cat31, and the posts for each of those subcats: SubCat1 Post 1 Post 2 SubCat2 Post 1 Post 2 SubCat3 Post 1 Post 2 It's pretty straight forward, but all the loops I have tried fail either at the subcat

Display last child categories

旧巷老猫 提交于 2019-12-13 03:33:15
问题 I would print only the list child categories. Example : News --> Press Release --> Viking Cruises I would print Viking Cruises I have this code that works, but print the entire tree of categories not last. <?php $categories = get_the_category(); $separator = ' '; $output = ''; if ( ! empty( $categories ) ) { foreach( $categories as $category ) { $output .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '">' . esc_html ($category->name) . '</a>' . $separator; } echo trim(

Filter wp_list_categories from one custom post type

亡梦爱人 提交于 2019-12-12 05:35:30
问题 I have 2 custom post types called 'project' and 'client' that share a taxonomy called 'sector'. if (!is_taxonomy('sector')) { register_taxonomy( 'sector', array('project', 'client'), array( 'hierarchical' => true, 'label' => 'Sector', 'query_var' => true, 'rewrite' => array( 'slug' => 'sector' ), 'with_front' => false ) ); wp_insert_term('Health', 'sector'); wp_insert_term('Clubs', 'sector'); wp_insert_term('Commercial', 'sector'); } I have created a taxonomy archive template with a sidebar

wordpress sidebar issue with wp_list_categories showing NO Categories

故事扮演 提交于 2019-12-12 01:30:05
问题 So on my wordpress install. I am trying to display category list in the sidebar but having issue with wp_list_categories function. There are handful of categories in the system but this function just prints "NO Categories". Can't figure out why. Any ideas? 回答1: Make sure you have at least 1 Post in every category you want to display wp_list_categories should be outside of the wordpress LOOP. You'll probably need to provide the sidebar's code before the LOOP's code. 回答2: You're using the right

WordPress > wp_list_categories with no child categories listed

淺唱寂寞╮ 提交于 2019-12-10 17:53:28
问题 The script below creates a listing of the categories in the site (excluding those in "uncategorized"). If possible, I'd like to modify it so that it only lists the top level categories (no child categories)... I thought the "depth"=1 argument would do the trick but not so. It lists ALL categories. When I remove the "heirarchical" argyument, it DOES exclude child categories, but then also includes the "uncategorized" category which I'm explicitly excluding via the exclude_tree = 1 argument. At