WordPress.org

Ready to get started?Download WordPress

Forums

custom menu not showing in post of categories (2 posts)

  1. eric brockman
    Member
    Posted 2 years ago #

    I've been racking my head for days and can't seem to get this sorted.

    I have a custom menu called 'x' it contains categories and single posts, it's location is set to 'single-x.php'
    when I view the category archive from menu-x the menu is present, but when I view single posts from category-x (or it's children) it is not.

    In my index.php I have:

    } if ( in_category('x') ) {
        include (TEMPLATEPATH.'/single-about.php');

    But no luck for single post views.

    I have also tried adding:

    } if ( in_category('x') || post_is_in_descendant_category( 'x' ) ) {
        include (TEMPLATEPATH.'/single-about.php');

    Along with this in my function.php to help with the posts of descendant categories of 'category-x':

    if ( ! function_exists( 'post_is_in_descendant_category' ) ) {
    	function post_is_in_descendant_category( $cats, $_post = null ) {
    		foreach ( (array) $cats as $cat ) {
    			// get_term_children() accepts integer ID only
    			$descendants = get_term_children( (int) $cat, 'category' );
    			if ( $descendants && in_category( $descendants, $_post ) )
    				return true;
    		}
    		return false;
    	}
    }

    Still no luck in single post view!
    Any help is greatly appreciated!!!!

  2. eric brockman
    Member
    Posted 2 years ago #

    Is there anybody out there?

Topic Closed

This topic has been closed to new replies.

About this Topic