Welcome to TalkGraphics.com
Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14
  1. #11
    Join Date
    Nov 2000
    Posts
    4,894

    Default Re: WordPress random posts plug-in

    remi,

    I will be using the code on single pages only and showing only the title of the post. I installed the script and pasted in the code - it all worked fine.

    However, the formatting of the output doesn't look all that great... Don't need all the "before and after stuff".

    I massacred the code a little bit (but left the after title) and it looks a bit closer to what I would like to see.

    Question: How would I go about getting each post in a bulleted list - or if it's too tricky; on a line of their own?

    A bulleted list like this:
    • Post 1
    • Post 2
    • Post 3
    • Post 4
    • Post 5


    The massacred code now looks like this:

    <p>Theoretically related posts</p>

    <?php
    if (function_exists('random_posts')) {
    // Description:
    // The function random_posts displays a configurable list of random posts.

    // Parameters:
    // $limit - No. of posts to show.
    $limit = 5;

    // $len - Lenght of auto-generate excerpt.
    $len = 0;

    // $after_title - Text to appear after the entry title.
    $after_title = '..... ';

    // $show_pass_post = Include/exclude password protected entries (Default: false).
    $show_pass_post = false;

    // $show_excerpt = Show/hide excerpt (Default: false).
    $show_excerpt = false;


    random_posts($limit, $len, $after_title, $show_pass_post, $show_excerpt);

    }
    ?>
    Agains thanks for your help!

    Risto

  2. #12
    Join Date
    Jan 2006
    Posts
    2,439

    Default Re: WordPress random posts plug-in

    It's no big problem to build a list item - exactly therefore are the $before_title/$after_title variables used:

    Code:
    <?php
    if (function_exists('random_posts')) {
    
      // If you print outs the necessary HTML code inside this piece of code,
      // then the following header is only printed, if the "Random Posts" plugin
      // is activated (comfortable, isn't it? ;) )
    
      // Print out the header of this part of your sidebar with <h2> or <p>-tags 
      // (depends on your used template):
      printf("<h2>Theoretically related posts</h2>");
    
      // Print out the starting <ul>-tag to start a list:
      printf("<ul>");
    
      // Parameters for the following function random_posts:
      // $limit - No. of posts to show.
      $limit = 5;
    
      // $len - Lenght of auto-generate excerpt.
      $len = 100;
    
      // $before_title - Text to appear before the entry title.
      // each random post should included within a <li>...</li>-tags
      $before_title = '<li>';
    
      // $after_title - Text to appear after the entry title.
      $after_title = '</li>';
    
      // $before_post - Text to appear before the entry excerpt.
      $before_post = '';
    
      // $after_post - Text to appear after the entry excerpt.
      $after_post = '';
    
      // $show_pass_post = Include/exclude password protected entries (Default: false).
      $show_pass_post = false;
    
      // $show_excerpt = Show/hide excerpt (Default: false).
      $show_excerpt = false;
    
    
      // Execute the function random_posts to display
      // a configurable list of random posts.
      random_posts($limit, $len, $before_title, $after_title, $before_post, $after_post, $show_pass_post, $show_excerpt);
    
      // Print out the closing </ul>-tag to close the list:
      printf("</ul>");
    }
    ?>
    Regards,
    Remi

  3. #13
    Join Date
    Nov 2000
    Posts
    4,894

    Default Re: WordPress random posts plug-in

    remi!

    Thank you so much for your help and time. That's exactly what I was looking for! It works perfectly!

    I'll post a link in the off-topic forum to my "sort of like a blog" when I get the last couple of posts in there (back tracking and changing a few things around).

    Risto

  4. #14
    Join Date
    Jan 1970
    Posts
    3,220

    Default Re: WordPress random posts plug-in

    Cool... good job on getting this resolved guys

 

 

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •