• I´m going mad trying to find a plugin or code to randomize post within specific tags or categories..

    For exemple,

    I have 3 posts: Number 1, Number 2, Number 3 under “Lucky Numbers´category”

    And a link somewhere: “whats your lucky number today” – so when clicked, the random code is able to retrieve a post within “Lucky Numbers´category” only.

    If someone else know some plugins or wp/code for this, please let me know!

Viewing 3 replies - 1 through 3 (of 3 total)
  • <?php
    $lucky_num = rand  ( 1 , 3  );
    $post_slug = 'Number '. $lucky_num;
    $args= array(
    	'category_name' => 'Lucky Numbers',
    	'name' => $post_slug,
    	posts_per_page = 1
    );
    query_posts($args);
    //The Loop
    if ( have_posts() ) : while ( have_posts() ) : the_post();
     ..
    endwhile; else:
     ..
    endif;
    ?>
    Thread Starter photoshopx

    (@photoshopx)

    Thank you gonna try this!!

    Thread Starter photoshopx

    (@photoshopx)

    Hello, your code works really nice, but that is for category.php/archive.php files isn´t?!

    In fact, I was looking for a plugin/code able to retrieve a random post within a specific category or tag. So whenever the visitors click the link, they will be send to a random post. I can´t find anything simple like that! Just a code for send visitor to a random link within a category/tag .

    I solved this issue the worst I could figure out ( I think).

    Using your code, I create categories just for show random posts and then I link the category in posts or pages.

    So i have some 3 or 4 categories files for the post show up randomly.

    Still, I want know if someone else know to solve that without creating categories files.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Random posts’ is closed to new replies.