Which php file lists all the post of a category

WordPress uses a hierarchy of templates (see the visual overview) which it checks for presence. In your case when showing a category archive it will check for presence the following files in this order and use the first one it finds: category-$slug.php (In your case probably category-news-events.php) category-$id.php category.php archive.php [paged.php] if paged index.php So … Read more

WooCommerce Link to Product Category

For this purpose there is get_term_link function (documentation). <a href=”https://wordpress.stackexchange.com/questions/199226/<?php echo get_term_link( 42 ,”product_cat’) ?>”>Fine Art … etc.</a> Product category is just WP taxonomy, so there is plenty of functions to work with. In this case you have to know your product category ID (taxonomy term ID, actually). When editing category, you will find it … Read more

Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy

WP defaults to showing normal native Posts in archives. It won’t automagically pick up which post types you want in your archive. You will have to adjust main query for it to explain that to it, with something like: add_action( ‘pre_get_posts’, function ( WP_Query $query ) { if ( $query->is_main_query() && $query->is_tax( ‘department’ ) ) … Read more

How to make a custom Archive Page

You can get the queried date from the query vars in the $wp_query object: if( is_date() ){ if( isset( $wp_query->query_vars[‘year’] ) ){ echo ‘queried year is ‘ . $wp_query->query_vars[‘year’]; } if( isset( $wp_query->query_vars[‘monthnum’] ) ){ echo ‘queried month is ‘ . $wp_query->query_vars[‘monthnum’]; } if( isset( $wp_query->query_vars[‘day’] ) ){ echo ‘queried day is ‘ . $wp_query->query_vars[‘day’]; … Read more

Display page of custom posts?

I think your problem is in the exact code that you’ve mentioned. pre_get_post is a bastard if you don’t use it correctly. With any archive type conditions used in pre_get_posts, it will affect both front end and back end. This include archives pages, category and taxonomy pages, tag pages and author pages. You’ll need to … Read more

Pagination problems with multiple custom post type archive pages

Your problem comes from a fundamental misunderstanding of how WordPress loads the main loop. Here you have a main query that goes and grabs the posts to display in your post type archive. It then decides to load archive-recept.php based on that query. The call to paginate_links then provides the pagination for that main query. … Read more

Archive template for taxonomy terms

I want to document this because I just found the answer recently. The problem with having taxonomy is that most developers have the mindset of expecting the taxonomy to be seen inside the post_type url of: http://hostname/post_type/taxonomy_term Instead, you are going to find the url in: http://hostname/taxonomy_slug/taxonomy_term This means that we often may be creating … Read more

Change number of posts to show on Archive page (custom post type)

Just make sure you’re not in the admin when changing the query: function num_posts_archive_project_ie($query) { if (!is_admin() && $query->is_archive(‘projects-ie’) && $query->is_main_query()) { $query->set(‘posts_per_page’, 6); } return $query; } is_admin() does return true only if you’re in the backend (it does not, however, verify that the current user is an admin user, despite the name, don’t … Read more