WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin : YD Recent Posts Widget] Need Help with PHP (2 posts)

  1. mr_erk
    Member
    Posted 3 years ago #

    I'm new to php and can't figure this out.
    I already managed to increment values inside my code...What I need is also to decrement the $offset inside the loop...Can anyone help me with this? Here's my code;

    <?php
    for ($id=1; $id<=19; $id++)
      {
      echo '<div id="content_' . $id . '"><div class="text"><h2>' . $id . '</h2>';
    rewind_posts();
    display_yd_previous_posts_here('posts_per_page=1' . '&offset=$offset');
    echo '</div></div>';
    }
    ?>

    Thanks in advance...

  2. mr_erk
    Member
    Posted 3 years ago #

    resolved...

    <?php
    for ($id=1,$offset=-1; $id<=19,$offset>=-19; $id++,$offset--)
      {
      echo '<div id="content_' . $id . '" class="tab_view"><div class="text"><h2>' . $id . '</h2>';
    rewind_posts();
    $args = array(
    	'posts_per_page'      => 1,
    	'offset'     => $offset
    );
    display_yd_previous_posts_here($args);
    echo $offset;
    echo '</div></div>';
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic