WordPress.org

Ready to get started?Download WordPress

Forums

Links in nav menu disappearing on category pages (2 posts)

  1. downtownboogie
    Member
    Posted 4 months ago #

    I'm using the following function to add custom post type posts to my archive pages loops, but when its added its removing the custom links from my category pages. ie. the links where i manually specify the title/address, and its only happening when viewing posts by category.

    This is the function:

    function namespace_add_custom_types( $query ) {
      if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
        $query->set('post_type', array('post', 'page', 'feed', 'news', 'fitness', 'faith'));
        return $query;
      }
    }
    add_filter( 'pre_get_posts', 'namespace_add_custom_types' );

    When I remove the function the custom post type posts disappear but the links return, so this function appears to be the culprit, but I'm not sure what to do from here.

    Can anyone point me in the right direction to getting back these links whilst viewing posts by category please?

    Thanks

  2. The Grey Parrots
    Member
    Posted 4 months ago #

Reply

You must log in to post.

About this Topic