WordPress.org

Ready to get started?Download WordPress

Forums

Related Posts Thumbnails
Setting different amount of posts for two get_related_posts_thumb (2 posts)

  1. cip6791
    Member
    Posted 1 year ago #

    I m using <?php get_related_posts_thumbnails(); ?> twice on the same page. How can I define the number of posts it retrieves? I don't mind if the first function gets the number of posts I define in the admin settings, but I would like to have the second get less.

    get_related_posts_thumbnails(5); <-- Just an example

    http://wordpress.org/extend/plugins/related-posts-thumbnails/

  2. gastonius
    Member
    Posted 1 year ago #

    Hey, a little late, but as I needed the same today, I modified the plugin a bit and will probably serve for someone in the future:

    Edit related-posts-thumbnails.php file

    Search for global $wpdb; (around line #90), and before that line add:

    if (!empty($this->options)) {
    	foreach ($this->options as $option => $value) {
    		$$option = $value;
    	}
    }

    Then, search for function get_related_posts_thumbnails() (around line 830) and modify it to look like this:

    function get_related_posts_thumbnails( $options = false )

    And two lines below (right after global $related_posts_thumbnails;), add this:

    if (!empty($options)) {
    	$related_posts_thumbnails->options = $options;
    }

    And that's it!

    Now, you can overwrite any admin option on the call:

    Want to show 5 related posts?

    <?php get_related_posts_thumbnails(array('posts_number' => 5 )); ?>

    Again, I can send diff files to the developer or anyone who ask for them.

    Have a great day!
    Gaston Gorosterrazu

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic