- This topic has 8 replies, 2 voices, and was last updated 7 years, 11 months ago by
Tom.
-
AuthorPosts
-
April 28, 2018 at 3:43 am #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.
April 28, 2018 at 7:38 am #562470Catalin
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.
April 28, 2018 at 10:08 am #562620Tom
Lead DeveloperLead DeveloperHmm, that’s strange.
What are your permalinks set to in “Settings > Permalinks”?
Can you deactivate your custom functions, then re-save the permalink settings?
April 28, 2018 at 11:43 am #562669Catalin
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. 🙂
April 28, 2018 at 9:06 pm #562873Tom
Lead DeveloperLead DeveloperThe 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.
April 29, 2018 at 3:40 am #562982Catalin
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.
April 29, 2018 at 9:21 am #563191Tom
Lead DeveloperLead DeveloperIt’s all working as it should now?
April 29, 2018 at 9:43 am #563195Catalin
Yes. Everything’s perfect.
April 29, 2018 at 9:00 pm #563464Tom
Lead DeveloperLead DeveloperAwesome 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.