WordPress.org

Ready to get started?Download WordPress

Forums

Yet Another Related Posts Plugin (YARPP)
[resolved] Add arguments to a custom template (4 posts)

  1. aidecms
    Member
    Posted 1 year ago #

    Hello, I would like to add an "offset" and display only "post type", and makes 5 posts appears instead of 3.

    is it possible to custom the following template to make it runs ?

    <?php
    
    if (have_posts()) {
    	$output .= '<ul class="icon-list ">';
    	while (have_posts()) {
    		the_post();
    		$output .= '<li style="margin-left:30px;"><div class="icon16 iconSymbol heart"></div><a href="'.get_permalink().'" rel="bookmark">'.get_the_title().'</a>';
    //		$output .= ' ('.round(get_the_score(),3).')';
    		$output .= '</li>';
    	}
    	$output .= '</ul>';
    } else {
    	$output .= '<p><em>'.__('No related posts.','yarpp').'</em></p>';
    }

    http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/

  2. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    The number of posts can be controlled in the YARPP settings page without changing your custom template code.

    I'm not sure what you mean by an offset.

  3. aidecms
    Member
    Posted 1 year ago #

    I already have a custom template with only 3 posts (from settings) and thumbnails, but now I want to create a new template for the widget sidebar.

    for that I want to use an offset option to display 5 related post from the fourth (One to Three are displays at the bottom of the article)

    Then How to exlude pages ?

    Any idea ?

    Thanks a lot

  4. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    I see what you mean by an offset. What you probably want to do is set a counter in PHP, like $i = 0; then $i++ in each iteration, then check for the value of $i in the loop, and only print if it's past a certain number.

    Excluding pages is done in the YARPP options. Unselect the "display results from all post types" option.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic