Advanced Most Recent Posts Mod
Show the recent posts in multiple columns? (2 posts)

  1. Zavarzin
    Posted 5 years ago #

    Is there a way to split the recent posts showing up in 2 or 3 or 4 columns?


  2. Kailey (trepmal)
    Volunteer Mod & Reviewer
    Plugin Author

    Posted 5 years ago #

    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:

    if ($c%$rows == 0 && $c != $total) {
    	$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>';
    return '<ul class="advanced-recent-posts">' . $postlist . '</ul>';

    To this:

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Most Recent Posts Mod
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic