• Resolved larsdegnbol

    (@larsdegnbol)


    Hi

    I installed the plugin and all is good. Only problem is, that in the category archive page the main menu disappeared (https://staging2.wefrb.dk/category/restaurant).

    I updated the functions.php with the code below … Hope you can help? The Theme is Newspaper8 …

    Best regards from Lars

    function my_cptui_add_post_types_to_archives( $query ) {
    // We do not want unintended consequences.
    if ( is_admin() || ! $query->is_main_query() ) {
    return;
    }

    if ( is_category() || is_tag() && empty( $query->query_vars[‘suppress_filters’] ) ) {
    $cptui_post_types = cptui_get_post_type_slugs();

    $query->set(
    ‘post_type’,
    array_merge(
    array( ‘post’ ),
    $cptui_post_types
    )
    );
    }
    }

    add_filter( ‘pre_get_posts’, ‘my_cptui_add_post_types_to_archives’ );

    add_filter(‘pre_get_posts’, ‘query_post_type’);
    function query_post_type($query) {
    if( is_category() ) {
    $post_type = get_query_var(‘post_type’);
    if($post_type)
    $post_type = $post_type;
    else
    $post_type = array(‘nav_menu_item’, ‘post’, ‘community’); // don’t forget nav_menu_item to allow menus to work!
    $query->set(‘post_type’,$post_type);
    return $query;
    }
    }

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Questions to help you along:

    Are either of these functions added to try and address the menu issue, or are they perhaps the cause of it going away? Specifically that 2nd one.

    Have you tried removing both to see if the menu returns like expected?

    I would look into using the if ( is_admin() || ! $query->is_main_query() ) { ... } check again for that 2nd one. I have a feeling you’re affecting all of the queries that use WP_Query unintentionally.

Viewing 1 replies (of 1 total)
  • The topic ‘Menu in category archive disappeared’ is closed to new replies.