How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?

I would use a custom query like this: $amsterdamstore_args = array( ‘post_type’ => ‘store’, // This is your custom post type ‘tax_query’ => array( array( ‘taxonomy’ => ‘city’, // This is your custom taxonomy ‘terms’ => ‘Amsterdam’, // The term you search for ‘field’ => ‘name’, // Check against the term’s name (you might use … Read more

Empty tax_query array returns an empty array

As already hinted by @Milo, check if you have terms before appending your tax_query You can try the following: (Requires PHP 5.4+ due to short array syntax, revert to old syntax if necessary) $args = [ ‘post_type’ => ‘product’, ‘posts_per_page’ => 15, ‘paged’ => $paged, ‘post__not_in’ => $exclude, ‘s’ => $filter, ]; // Append our … Read more

How many queries are normal to execute on a WP site?

I wouldn’t say it’s not “normal”, but it’s above typical. The common minimum of queries would go like: main query (set of posts) functionality (menus, widgets, etc) data (terms and such) On a WP test data that would make something under 50 queries on home page. With object cache it will fall under 10 on … Read more

Two differents queries in archive page

You’ve added the filter lm_exclude_bio to pre_get_posts. So when you need to run another query you can remove the filter to get normal query. You can remove the filter like below- // Here we’re removing the filter first. Then we are running the query. remove_filter( ‘pre_get_posts’, ‘lm_exclude_bio’ ); $args = array( ‘post_type’ => ‘bio’, ‘posts_per_page’ … Read more

WordPress ajax function parameter value not being passed

First of all you should read the codex on AJAX_in_Plugins Secondly you should look at wp_localize_script to get the value for the admin-ajax url to your javascript. $data = array( ‘ajax_url’ => admin_url( ‘admin-ajax.php’ ) ); wp_localize_script( ‘ajax-script’, ‘ajax_object’, $data ); In your javascript, you are then meant to reference the localized data jQuery(“.selectbox”).change(function(){ var … Read more

Is it possible to dynamically get queried term AND taxonomy?

In a taxonomy template, the queried object is an instance of WP_Term, one of whose fields will be the taxonomy the term comes from. So, you can start your taxonomy.php as follows: $queried_object = get_queried_object () ; $args = array ( ‘post_type’ => ‘inventory’, ‘tax_query’ => array ( array ( ‘taxonomy’ => $queried_object->taxonomy, ‘field’ => … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)