Trying to make an advanced taxonomy query like this:
array( ‘post_type’ => ‘coupon_type’, ‘tax_query’ => array( array( ‘order’ => ‘DESC’, ‘posts_per_page’ => ’10’, ‘taxonomy’ => ‘coupons’, ‘field’ => ‘slug’, ‘terms’ => ‘expired’, // exclude expired. ‘operator’ => ‘NOT IN’)
Though it appears this is not possible via the Recent Listings Layout object. Is there any way to create such a query without hacking the core?
will it not work via a string?
That was the first thing I tried though specific taxonomy terms don’t appear to be passed within the query string format.
I’ll keep playing.
Cant get it to work at all. Looking at the php files, it appears the query already passes the post type and sets “field=slug” before the user inputted string
So something like this does not work:
It makes it difficult to query custom post types and taxonomies.
Talking to myself mode: Had a brain freeze and just remembered that string will never work due to the fact you need to capture the current term as a variable before even making a query – which also requires querying two separate taxonomies.
It all depends ‘where’ are you querying it. If you explain in more detail on what are you trying to achieve, we might be able to help you better.
Richard _____________________________________________________________________ Wide range of PremiumPress and WordPress Plugins and add-ons PremiumPress customisation services and Website Design Selection of PremiumPress Child Themes
In the Stores page, Expired Coupons are displayed. In order to get around this you can exclude a specific taxonomy term when creating a custom query, previously you could just enter cat=-232 where 232 is the category you want to exclude.
Unfortunately terms do not work the same way and don’t appear to be able to be passed as a query string. It works fine as an array however.
Have you tried tax_query? You can find more in here: https://codex.wordpress.org/Class_Reference/WP_Query
Thanks Richard, it works as an array as per my first post but cannot be passed as a string. I can do it by editing core files though so this will have to suffice.
This bit on the codex:
tax_query takes an array of tax query arguments arrays (it takes an array of arrays) pretty much sums up the dilemma.
Interesting that WordPress recommends against using Query Strings due to the need to parse that query before it can be used.
Start your new website today!