WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Add arguments to a custom template

[Resolved] Add arguments to a custom template

  • 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/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author mitcho (Michael Yoshitaka Erlewine)
    Member

    @mitchoyoshitaka

    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.

    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

    Plugin Author mitcho (Michael Yoshitaka Erlewine)
    Member

    @mitchoyoshitaka

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Add arguments to a custom template’ is closed to new replies.