Results 1 to 3 of 3

 

Thread: Wordpress random post code.

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Jul 2009
    Posts
    38
    Thanks
    0
    Thanked 1 Time in 1 Post


    Here is a dead simple bit of code that creates random posts on the frontpage of Wordpress. Instead of installing a whopping big plugin to do the same thing I wrote this instead.

    Code:
    <?php
       if (is_home()) {
          query_posts("showposts=1&cat=18&orderby=rand");
       }
    ?>
    Place the above inside the loop and it will randomly output a post from your choice of category. In the above I have chosen category 18 for my choice of posts. Easily customized: showposts = number of posts and cat= your choice of category. You can alter the is_home to make it work on different pages such as is_page. The above is working on my Wordpress version 2.8.4.

    Regards
    Mark

  2. #2
    Mogga's Avatar
    Chocaholic

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Oldham
    Posts
    8,452
    Thanks
    519
    Thanked 228 Times in 176 Posts
    What SEO benefit does that have?
    --
    Gifts -/ wine,vouchers/Chocolate -/Garden
    Got a bingo site? Want a link. Get in touch.

  3. #3
    Registered User

    Status
    Offline
    Join Date
    Jul 2009
    Posts
    38
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Mogga View Post
    What SEO benefit does that have?
    I never really considered Seo with regard to this. On my own site I have listed all the post titles that belong to the 'Featured' category where the random posts come from so there are links to the content so maybe that helps. I have also added the titles into the meta tags. I suppose random stuff is bad news with regard to Seo. I might have to rethink the random post display but it does make the site seem more interesting in my eyes.



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Wordpress: Expired post notification code
    By d33man in forum Programming
    Replies: 10
    Last Post: 28-07-09, 08:29 PM
  2. CSV to Wordpress Post V2
    By matty281k in forum Affiliate Marketing Lounge
    Replies: 7
    Last Post: 01-05-09, 02:31 AM
  3. Cant post in Wordpress
    By findlite in forum Affiliate Marketing Lounge
    Replies: 0
    Last Post: 17-09-08, 02:16 PM
  4. Wordpress Coding Random Strangeness
    By Frostie in forum Programming
    Replies: 3
    Last Post: 29-01-08, 11:23 AM
  5. Wordpress or code my own
    By mrjibbles in forum Affiliate Marketing Lounge
    Replies: 7
    Last Post: 23-01-08, 03:49 PM

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
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2