Display hierarchical categories/sub-categories for a single post only
Display hierarchical categories/sub-categories for a single post only
Display hierarchical categories/sub-categories for a single post only
I’ve found Link Library to be pretty flexible. http://wordpress.org/extend/plugins/link-library/
get_the_category() get_categories() get_category_link() <?php echo ‘<ul>’; foreach(get_the_category() as $cat) { echo ‘<li><a href=”‘.get_category_link($cat->term_id).'”>’.$cat->name.'</a>’; $sub_cats = get_categories(‘parent=”.$cat->term_id.”&hide_empty=0’); if($sub_cats) { echo ‘<ul>’; foreach($sub_cats as $sub_cat) { echo ‘<li><a href=”‘.get_category_link($sub_cat->term_id).'”>’.$sub_cat->name.'</a></li>’; } echo ‘</ul>’; echo ‘</li>’; } } echo ‘</ul>’; ?> edit: for a list of sub categories in a category archive, try this code: <?php $cat = get_query_var(‘cat’); … Read more
when you create a custom post type, and make it hierarchical, it will behave like pages. so you can have sub events the same way you have sub pages. look at register_post_type function arguments here : http://codex.wordpress.org/Function_Reference/register_post_type#Arguments then use wp_list_pages function to list subpages. see : http://codex.wordpress.org/Function_Reference/wp_list_pages#List_members_of_a_custom_post_type something like this (not tested) : <?php $args … Read more
You can set a post type to hierarchical when you register it with register_post_type. Simply set the ‘hierarchical’ argument to true. $args = array( ‘public’ => true, ‘publicly_queryable’ => true, ‘has_archive’ => true, ‘rewrite’ => true, … ‘hierarchical’ => true, … ‘supports’ => array( ‘title’, ‘editor’, ‘author’, ‘thumbnail’, ‘excerpt’, ‘comments’,’page-attributes’ ) ); register_post_type(‘my-cpt’,$args);
Your code is failing because the first term is the parent term, caused by checking both the parent and the child term. You dont need to do that, if I have a heirarchy A->B->C->post, and I add the post to the C category, it’s automatically a part of its parents
I may suggest not combining each of these into hierarchical taxonomies, but setting up 3 distinct taxonomies. It seems like they are 3 unrelated properties of the photos, and thus, I would separate the code for them. Then you’re not trying to code around nested taxonomy terms, but you can access them each individually. The … Read more
Sry, here is my answer: Here is first the output for listing the category in checkbox: Walker for the Category Output class Adv_Multicheck_Walker_Category extends Walker { var $tree_type=”category”; var $db_fields = array (‘parent’ => ‘parent’, ‘id’ => ‘term_id’); function start_lvl($output, $depth, $args) { if ( ‘list’ != $args[‘style’] ) return $output; $indent = str_repeat(“\t”, $depth); … Read more
Once wordpress reads the “Events” part of the URL it knows that what follows are posts or subcategories of the events category, and a page is neither, and that is the reason you don’t even have an option of doing what you want. Do it as a post instead of a page. Then edit you … Read more
Did you try BulkPress Plugin? Easily add and manage multiple categories, pages, custom taxonomy terms and custom post type posts. Create and reorder terms