Using Specific Taxonomy on Slider

  • moshguy

    #8039

    I’ve seen posts showing a filter to show only specific post types in the slider. Is there an equally easy way to show only a specific taxonomy in the slider? I have a taxonomy that is specifically for special items for sale. It would be a wonderful way to show off those items. Any help on the matter would be greatly appreciated.

    -Jeremy

    Mod

    Kenneth John Odle

    #40170

    Just set the slider to display posts of that category.

    (I’m assuming that “category” is what you mean when you say “taxonomy”. If not, please explain.)

    moshguy

    #40171

    Kenneth, I appreciate your quick response.

    I’m using custom post types and created their own taxonomies. The problem is that the Graphene slider will only show categories from regular posts, not for custom post types. I used a filter to only show specific post types in the slider but I would like to narrow it down to taxonomies from that custom post type.

    Admin

    Syahir Hakim

    #40172

    You can use the graphene_slider_args filter hook to modify the final arguments for getting the posts for the slider:

    function my_graphene_slider_args( $args ){
    $args['tax_query'] = array(
    array(
    'taxonomy' => 'my_tax',
    'field' => 'id'
    'terms' => 9999
    )
    );
    if ( isset( $args['category__in'] ) ) unset( $args['category__in'] );

    return $args;
    }
    add_filter( 'graphene_slider_args', 'my_graphene_slider_args' );

    You might need to tweak the argument array further, depending on your slider settings. Use disect_it( $args ); to print out what’s contained in the argument array.

    WP Query documentation: http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

    moshguy

    #40173

    That is outstanding! Exactly what I needed. Thanks for all the help.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.