I’ve just had one questions solved over here: How to display posts from a single category within a custom taxonomy
Now I’m wondering how to take this code:
<?php
$args = array(
'posts_per_page' => 1,
'post_type' => 'inventory',
'tax_query' => array(
array(
'taxonomy' => 'inventory-category',
'field' => 'slug',
'terms' => array(
'bulk-racks'
)
)
)
);
query_posts( $args ); while ( have_posts() ): the_post();
// do stuff here
?>
<?php endwhile; ?>
and call it using shortcodes, for example to display the bulk-racks category by using this or something similar [inventory-category=”bulk-racks”]
I know how to create a basic shortcode but I don’t know how to write the function that would return the posts based on the shortcode category name input.
Once again any help would be greatly appreciated.
Take a look at category post shortcode to get an idea and here is the plugin with minor modifications to call your post type and taxonomy:
usage:
just put this shortcode in your post or pages
post to display. default is -1
for multiple slugs