• Hi, I´m using the following code to display a menu of the categories where my post is

    $category = get_the_category(); 
    
    			$parent = $category[0]->term_id;
    			$category_link = get_category_link( $parent  );
    
    			$args = array(
    				'child_of' =>  $parent,
    				'order' => 'desc',
    			);
    
    			$categories = get_categories( $args );

    and it works fine but on some posts I have the following structure:

    Cat 11 (parent)
    Cat 13(child)

    but when I echo the $parent it says that the 13 is the parent and it´s not displaying the menu but it only happens in some categories and I don´t know why is this happening

  • The topic ‘Error catching parent category’ is closed to new replies.