WordPress.org

Support

Support » Plugins and Hacks » Advanced Most Recent Posts Mod » [Plugin: Advanced Most Recent Posts Mod] Show the recent posts in multiple columns?

[Plugin: Advanced Most Recent Posts Mod] Show the recent posts in multiple columns?

Viewing 1 replies (of 1 total)
  • Plugin Author Kailey (trepmal)

    @trepmal

    Volunteer Mod & Reviewer

    Open up <a href="http://plugins.trac.wordpress.org/browser/advanced-most-recent-posts-mod/trunk/adv-most-recent.php?rev=380061">adv-most-recent.php</a> and make the following changes:

    (the line numbers I reference are all from the unchanged file)

    Replace line 385, looks like
    $posts = get_posts($query); //get posts
    With this:

    $posts = get_posts($query); //get posts
    $total = count($posts); //using count instead of $shownum in case there are fewer posts
    $cols = 5;
    $rows = ceil($total/$cols);

    $cols should reflect the number of columns you actually want (sorry, I haven’t added a nice input field to the widget for this)

    Replace line 392, looks like
    foreach ($posts as $post) {
    With this:

    $c = 0; //li counter
    $x = 1; //ul counter
    foreach ($posts as $post) {

    Replace line 458, looks like
    }// end foreach()
    With this:

    ++$c;
    if ($c%$rows == 0 && $c != $total) {
    	++$x;
    	$postlist .= '</ul><ul class="advanced-recent-posts col-'.$x.' '. $cat_slug .'">';
    }
    }// end foreach()

    And lastly, change lines 465-467 which look like

    echo '<ul class="advanced-recent-posts">' . $postlist . '</ul>';
      else
    return '<ul class="advanced-recent-posts">' . $postlist . '</ul>';

    To this:

    echo '<ul class="advanced-recent-posts col-1">' . $postlist . '</ul>';
    else
      return '<ul class="advanced-recent-posts col-1">' . $postlist . '</ul>';
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Advanced Most Recent Posts Mod] Show the recent posts in multiple columns?’ is closed to new replies.
Skip to toolbar