Excluding a category from frontpage but not from WP_Query
Adding $query->is_main_query() to your if statement in pre_get_posts function. This will check if it’s the main query for the page, and not a custom query.
Adding $query->is_main_query() to your if statement in pre_get_posts function. This will check if it’s the main query for the page, and not a custom query.
Yes, there is such way. To be precise, there are many ways to accomplish that. You can add ‘Category’ page. Make sure that its slug is set to ‘category’. If you go to example.com/category/ then this page will be shown. If there were no custom changes to rewrite rules, then WordPress will first try to … Read more
The function that solves it should do the following : Loops through each product in the category For each item, retrieve the list of categories the product is in. If there is only one category and it’s the ‘restricted’ category, then the product is excluded from the query. Here’s an example : function exclude_category_archive_products( $q … Read more
How to remove the category from the url only for a specific category of articles on wordpress
Add custom text in second paragraph of posts in specific category
Get the category of post from which category page it have been clicked
Exclude a category ID from the following function
Invalid login email notification for password-protected category
You can use the following code snippet to sort posts alphabetically based on a specific parent category in WordPress: <?php $parent_cat=”Parent Category Name”; $parent_cat_id = get_cat_ID($parent_cat); $args = array( ‘category__in’ => array($parent_cat_id), ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘posts_per_page’ => -1 ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( … Read more
I think, you can try this type of code. $args = array( ‘post_type’ => ‘product’, ‘meta_key’ => ‘sorting_weight’, ‘orderby’ => ‘meta_value_num’, ‘posts_per_page’ => – 1, ‘order’ => ‘DESC’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘term_id’, ‘terms’ => 81, // category 1 ), array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘term_id’, … Read more