WordPress.org

Ready to get started?Download WordPress

Forums

Testimonials by WooThemes
How do i query by testimonial Category (2 posts)

  1. jrstaatsiii
    Member
    Posted 1 year ago #

    I am trying to filter our testimonials by specific categories. We choose the category from the page editor using Advanced Custom Fields, and I have a variable set up to pass that information to the Testimonial Query. Here is the code I am using:

    https://gist.github.com/jrstaatsiii/5876225

    However, this does not seem to be working, as all testimonials are still showing up.

    http://wordpress.org/extend/plugins/testimonials-by-woothemes/

  2. DesignerEthan
    Member
    Posted 1 year ago #

    I'm not sure why you would use a custom field for a category rather then use the default category.

    You can adjust the query used by filtering the query. Here is a snippet you can expand on to get your desired result.

    http://pastebin.com/ZStFxE5E

    Currently that snippet just takes the testimonials and displays them in a random order. You can remove the "'orderby' => 'rand'," piece and edit the "'category' => 0" section to use your category ID. So if you using the default categories with the testimonials and the cat ID is 42 you simply change 'category' => 0 to 'category' => 42.

    Hope that helps / works.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.