can you explain a little further? I added in stuff the other day for it to show a listing a based on a category. Haven’t tagged it to a new version yet as I’m working on other goodies before I do.
%category% – or – %categories% should be one of the tags accepted by the template. That’s what I mean. I guess it could get a lil complicated if a post is associated to multiple categories.
I just added an update with a new template api. you can add the tag yourself by adding this to your functions.php. after that you can use it however you like.
add_action( 'tbt_template_functions', 'add_category_to_tbtestimonials' );
/**
* add a 'category' variable to tbt
*
* @param mixed $twig
*/
function add_category_to_tbtestimonials( $twig ){
$twig->addGlobal( 'category', call_user_func( 'my_category_func' ) );
}
/**
* callback for category tag
*
*/
function my_category_func()
{
$categories = wp_get_object_terms( get_the_ID(), 'tbtestimonial_category' );
if( isset( $categories[0]->name ) )
return $categories[0]->name;
}
or you could return $categories ( wp_get_object_terms() call ) and then do a loop in the template to display more than 1 category.
Template Example:
{% if category %}
Categories:
{% for cat in category %}
<span class="category">{{ cat.name }}</span>
{% endfor %}
{% endif %}
New my_category_func for functions.php that returns array
/**
* callback for category tag
*
*/
function my_category_func(){
return wp_get_object_terms( get_the_ID(), 'tbtestimonial_category' );
}
I didn’t want to open a new discussion, because the title would be the same, however…
I can’t seem to output the shortcode for a testimonial “category” like such:
[testimonial cat='Technology' template='shortcode']
But this works, without the category filter:
[testimonial id='all' template='shortcode']
I am testing with only 1 testimonial. I am positive that 1 testimonial has been assigned the category ‘Technology’. I’m thinking this should work, but there is no output.
Tryin cat=”technology” just for giggles
Hey Travis. Thanks for the quick reply!
Trying [testimonial cat=”technology”] did not work either.
Let me know if you’d like me to try other things.
Cheers,
Marty