No projects are returned when clicking on specific category

Hello.

I bumped into a specific problem.
I have portfolio widget on the main page with my projects and sorting/filtering by categories (slugs) works just fine on main page when clicking on different buttons.

When I open whatever project, it opens on a new page and shows this project and what category is this project in.
But when I click on that category, I get “Nothing found”

Any idea where the problem could be?
(I am using polylang plugin, not sure if relevant here)

Thank you,
best regards

phrase

Hello Phrase,

I would like to apologize in advance for the inconvenience. By default, the custom post type’s category doesn’t load. To fix it, please add the below PHP snippet into your child theme’s functions.php file.


function sydney_include_projects_archive($query) {
	if ( !is_admin() && $query->is_main_query() ) {
	    if ( $query->is_archive() && !is_woocommerce() ) {
			$query->set('post_type', array( 'post', 'projects' ) );
		}
	}
}
add_action('pre_get_posts','sydney_include_projects_archive');


If you don’t have a child theme yet, alternatively you can use functionality plugin like Code Snippets.

Regards,
Kharis

Hello Kharis!

I have the same problem but the solution described via Code Snippets does not work. when i copy the above written snippet and click on the category i get the info: page does not function.

here is a link to my page:http://www.k1alpinism.com/

Unfortunately i do not have a cild theme. Any other idea?

Best regards,
Raphael

Try to use our premade Sydney child theme that can be downloaded from this link.

Regards,
Kharis

Hello Kharis.

Thank you for the snippet,
it works perfectly fine when I omit “&& !is_woocommerce()” from the function.

I leave this thread open for another ~2 days if someone else wants to reply,
then I’ll put this into resolved status.

Thanks again, appreciate your help!
With kind regards

phrase

Excellent! I’m glad it helped.

Please let us know in a new topic if you need anything else.

Regards,
Kharis

Problem solved here too! thank you very much for the help. Best regards!

Raphael

Hi - I have the same issue in Talon Pro./ If I delete the Woocommerce line, the project link works but all other menus don’t. If I change ‘sydney_’ in the code snippet to ‘talon_’ the main menu works but Project menu stops working again.

Update, two of the links within the category work (there are multiple posts in all categories).

Hello there,

Have you tried this code?

    function talon_pro_include_projects_archive($query) {
      if ( !is_admin() && $query->is_main_query() ) {
        if ( $query->is_archive() ) {
          $query->set('post_type', array( 'post', 'projects' ) );
        }
      }
    }
    add_action('pre_get_posts','talon_pro_include_projects_archive'); 

Regards,
Kharis