Finding the Code for Custom Post Types to Solve Menu Vanishing Bug

Home Forums Add Tags And Category to Page and Post Types Finding the Code for Custom Post Types to Solve Menu Vanishing Bug

This topic contains 0 replies, has 1 voice, and was last updated by  Sean 3 years ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #2861

    Sean

    Hi, so my menu was vanishing on category archive pages and content was not displaying properly on custom post types.

    Solution so far from browsing this forum seems to be to create a functions.php file for your child theme with nothing but the following inside:

    <?php
    /*added to give compatibility to the Add Tags And Category To Page And Post Types plugin.*/
    
    function namespace_add_custom_types( $query ) { if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { $query->set( 'post_type', array( 'post', 'nav_menu_item', '<strong>YOURCUSTOMPOSTTYPE</strong>' )); return $query; } } add_filter( 'pre_get_posts', 'namespace_add_custom_types' ); 
    

    Change the “YOURCUSTOMPOSTTYPE” to “page” or add whatever custom post types you need to the array.

    The problem I’m now facing is that my other post types beyond “page” are still not displaying properly. Is there a way to determine exactly what needs to be added to the array? Is it the exact same name as the post-type names listed in the plugin’s settings page? What about capital letters? Eg. “Landing pages” How do I know if I should be using an underscore or a dash to fill spaces? What if the title isn’t exactly as the array code should be? for example “landing_page_category” was showing n my address bar so I tried that in the array to no avail.

    Any Suggestions?

Viewing 1 post (of 1 total)

The topic ‘Finding the Code for Custom Post Types to Solve Menu Vanishing Bug’ is closed to new replies.