WordPress.org

Ready to get started?Download WordPress

Forums

TBTestimonials
[resolved] Display just one testimonial (3 posts)

  1. mjpg
    Member
    Posted 3 years ago #

    I am calling:

    tbtestimonial('random');

    and expected just one testimonial, but all seem to be output.

    I looked in tb-testimonials.php line 736 and assumed that:

    $q = new WP_Query( array( 'post_type' => 'testimonial', 'post_status' => 'publish', 'orderby' => 'rand', 'showposts' => 1 ) );

    would only output one due to 'showposts' => 1 but I assume my knowledge of WP is not correct.

    (saw this on the WP class reference:

    Display one random post:
    $query = new WP_Query( array ( 'orderby' => 'rand', 'posts_per_page' => '1' ) );

    ['posts_per_page' is preferred to 'showposts']

    Or is there another way to achieve this with tbtestimonial?

    Thanks

  2. Travis Ballard
    Member
    Plugin Author

    Posted 3 years ago #

    showposts should still work, i'll look intot his one fo ryou tonight and get back to you.

  3. mjpg
    Member
    Posted 3 years ago #

    Travis

    Thanks for your reply.

    It is working now. Not sure what changed. The code I am using in my theme index.php is:

    <?php
    // add testimonial - output set from TBTestimonials Output Settings admin page
    tbtestimonial('random');
    ?>

    Seems fine. Sorry to trouble you.

    Martin

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic