Hi there! Your theme is great. I have an existing wordpress site which has a custom post type “dog” and custom taxonomy “listing-type.” I want to use your blocks which are added to visual composer, but they only support entering the custom post type, not a custom query or custom taxonomies. Is there any workaround for this? I’m great with wordpress coding and could easily add a filter or something to the functions.php file if you have code for adding another field to the “filter” section for the custom taxonomy. I’ve also seen some VC blocks for post grids where they allow you to write your own query string like “post_type=dog&taxonomy=listing-type&term=available&count=1&orderby=title”
Thanks!
Hi
We had similar requests before but we didn’t manged to add support for custom taxonomy yet. This is a very complex task which involve many customizations and block’s structure must be changed in order to complete it. We still investigate this and maybe in feature updates we will find a proper implementation.
Thanks!
I know what you mean about finding that perfect implementation. Take a look at the post grid that comes with VC. That thing is pretty flexible, and I think that by implementing that both for the post type for display, as well as the filters, that you’d have not only a good implementation but one that follows a standard to some degree.
Incidentally, here’s the only code I could come up with to make this work. It is only OK on my site because my home page block 14’s are all dog post types and don’t need the filters because i am filtering to a specific listing-type taxonomy.
// ---------------------------- FILTER HOME PAGE QUERIES FOR DOG LISTINGS!
function home_dog_queries( $query ) {
if ( $query->is_home() ) {
$pt = $query->get( 'post_type' );
if ( is_array ( $pt ) ) {
if ( in_array( 'dog', $pt ) && count( $pt ) == 2 ) {
//echo 'POSTTYPE';
//print_r( $pt );
$query->set( 'tax_query', array(
array(
'taxonomy' => 'listing-type',
'field' => 'slug',
'terms' => $pt[1],
)
) );
}
}
}
}
add_action( 'pre_get_posts', 'home_dog_queries', 1 );
In the post type, I had to list the CPT and tax value to filter in the CPT field e.g. dog, german-shepherds. Kinda crazy but worked. I originally tried putting the tax value german-shepherd into the taxonomy tag filter value, but apparently your code first checks to see if that filter yields any results somehow before it issues a standard query.
Hi,
Good job you got it going. Thanks for posting the solution also as it will help other users who seek a similar implementation. I will pass this information on to the development team and see if we ca find a solution for implementing custom taxonomies in a future version of the theme. I can’t promise anything though as the dev. team decides what gets implemented.
Thank you!
