[Resolved] Category entries

Home Forums Support [Resolved] Category entries

Home Forums Support Category entries

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #562368
    Catalin

    Hi,

    I add info on my blog via pods.io plugin for custom posts and I’m using wordpress categories to group my entries. However, when I click on a category name, I get a Nothing found page and the search bar.

    Any idea how could I display this entries?

    Thanks.

    #562470
    Catalin

    I already tried to add to functions.php the following codes:

    add_filter('pre_get_posts', 'query_post_type');
    function query_post_type($query) {
     if(is_category() || is_tag()) {
       $post_type = get_query_var('post_type');
        if($post_type)
            $post_type = $post_type;
        else
            $post_type = array('post','review');
       $query->set('post_type',$post_type);
        return $query;
       }
    }

    and

    add_action( 'pre_get_posts', function ( $q )
    {
        if (    !is_admin() // Only target front end queries
             && $q->is_main_query() // Only target the main query
             && $q->is_category() // Only target category archives
        ) {
            $q->set( 'post_type', ['post', 'review'] ); // Adjust as needed
        }
    });
    

    It didn’t work.

    #562620
    Tom
    Lead Developer
    Lead Developer

    Hmm, that’s strange.

    What are your permalinks set to in “Settings > Permalinks”?

    Can you deactivate your custom functions, then re-save the permalink settings?

    #562669
    Catalin

    I forgot to change the permalinks and it was set to Date and time. Now it’s set to Post name.
    What do you mean by Custom functions?

    Meanwhile I found a solution via a very old plugin: Custom posts type archive (https://wordpress.org/plugins/custom-post-type-taxonomy-archives/), like 7 years old. It did the trick. πŸ™‚

    #562873
    Tom
    Lead Developer
    Lead Developer

    The custom functions you pasted in your reply above.

    Something must be interfering with the permalinks, as /category/name is a typical WP permalink structure. Perhaps try deactivating your other plugins/custom functions and then re-add them one by one to see if it’s a plugin issue.

    #562982
    Catalin

    I deactivated all the plugins, reactivated one by one, and nothing happen. I’m pretty happy that it works, now I can sleep at night. πŸ™‚ If this is something that you’ll like to check for you, I have no problem sending you the pass to check some things.

    #563191
    Tom
    Lead Developer
    Lead Developer

    It’s all working as it should now?

    #563195
    Catalin

    Yes. Everything’s perfect.

    #563464
    Tom
    Lead Developer
    Lead Developer

    Awesome πŸ™‚

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.