Categories
CMS Mastering Development Wordpress

How to ignore posts in pre_get_posts?

I’m using pre_get_posts and looking for a way to exclude posts in the main query. I’m using query_vars to query posts from a specific category and looking for a solution to exclude those posts in the main query. My code: // function to setup query_vars function ctrl_dly_podcast( $query_vars ){ $query_vars[] = ‘ctrl_podcasts_status’; return $query_vars; } […]

Categories
CMS Mastering Development Wordpress

Can query_vars be used to exclude posts in the main query in pre_get_posts?

Is there a way to exclude posts in the main query in pre_get_posts that are already in query_vars? For example: I have three $query_vars that work to get posts depending on the category. Is there a way to have the main query exclude posts in the three $query_vars? Here’s my pre_get_post function: // set up […]

Categories
CMS Mastering Development Wordpress

WP_Query to output chosen term and posts with no term assigned

I’m trying to build a query to filter a list of employees by a location taxonomy. Some staff are fixed, in that they’ll only ever work out of a single office, but others are flexible and work from them all. If a user chooses to filter by Office 1, I want to display staff members […]

Categories
CMS Mastering Development Wordpress

How to exclude woocommerece product category in search results?

I’m looking for a way to exclude a product category from search results with Woocommerce using the pre_get_posts action and $query->set(). I am searching using the WordPress ?s=keyword search. I know that the function will begin like this: add_action(‘pre_get_posts’, ‘exclude_product_category’); function exclude_product_category( $query ) { global $wp_the_query; if ( ( ! is_admin() ) && ( […]

Categories
CMS Mastering Development Wordpress

tax_query for same level of a post_type

There is a post type ‘payment_methods’, which has two taxonomies , ‘category’ and ‘restricted-country’ So i want to query for ‘payment_methods’ which has taxonomy ‘category’ = ‘Online_Banking’ and ‘restricted-country’=’USA’ , there is case that ‘restricted-country’ taxonomy is not selected for a payment_method… $name=’Online_Banking’; $country_name = ‘USA’; $args_p = array( ‘posts_per_page’ => $number, ‘post_type’ => ‘payment_methods’, […]

Categories
CMS Mastering Development Wordpress

Woocommerce Multisite global search how to mod ajax function?

I created an installation of my multisite ecommerce to differentiate the men’s and women’s departments. Often, however, it happens that in the men’s department they do research related to women’s articles or vice versa. Consequently, my site says it cannot find an article, obviously it is not so. How can I implement a global search […]

Categories
CMS Mastering Development Wordpress

Taxonomy query instead of category_name and such

I’m a bit stumped and was hoping for some insight. I’m just learning to code and am trying to modify a plugin (WP Loop) from referencing category_name and category__not_in to referencing a custom taxonomy I’ve made using Pods. Below is the original: $custom_query_args = wp_parse_args(array( ‘posts_per_page’ => $showposts, ‘nopaging’ => 0, ‘post_status’ => ‘publish’, ‘ignore_sticky_posts’ […]

Categories
CMS Mastering Development Wordpress

Exclude categories from wp query not working

Im using this code to exclude a category but it still show all posts. $posts = get_posts(array( ‘post_type’ => ‘exhibition’, ‘taxonomy’ => ‘categories_for_exhibitions’, ‘field’ => ‘slug’, ‘terms’ => array(‘current’), ‘operator’ => ‘NOT IN’, ));

Categories
CMS Mastering Development Wordpress

WordPress shortcode for a section Template

I have made a Section Template called section-countriesinfo.php in the Folder frontpage in the Theme Folder and I have put this Code <div class=”card-deck”> <?php while ( have_posts() ) : the_post(); ?> <?php $args = array( ‘post_type’=> ‘grants ‘ , ‘scholarship_degree’=> ‘bachelor’, ‘status’=>’publish’, ‘posts_per_page’ => -4, ‘tax_query’ => array( array( ‘taxonomy’ => ‘expired’, ‘field’ => […]

Categories
CMS Development Wordpress

Exclude a category and post_type from wp_query

I’m trying to figure out a simple way to exclude a particular category from a wp_query on my homepage. this particular code is already excluding a post_type (videos) from displaying, and I’m not exactly sure how to implement code for excluding a category as well. Here’s the current code: <div data-st=”st-six”> <div class=”feed-heading”><h4>News &amp; Updates</h4><a […]