How do I change the sql query for wp_get_archive()

Looking at the source code for wp_get_archives(), there is a filter called getarchives_join which you can use to restrict wp_get_archives() to a specific category You also need to get the current category ID, which is easy, simply use get_queried_object_id() You can try something like this to display archives for the currently viewed category add_filter( ‘getarchives_join’, … Read more

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