WordPress.org

Support

Support » How-To and Troubleshooting » Random page title with link

Random page title with link

  • Hey all,

    Thanks to the new beta I’m a bit confused what to do:

    My website was in beta 1 fully pages, all menu’s worked but I was looking for a way to show 1 random page title + link. Eventually this was impossible somehow.. so I changed all my pages into posts.

    Now beta 2 has screwed my menu, No posts can be added as a child under a category parent. So now I need to change back all content to pages again just to let my menu work.

    So.. Is it possible to random one page title? Or should I stay with posts wich I can’t use in my main menu.. Please help?!

Viewing 1 replies (of 1 total)
  • The code snippet below will show one random page title:

    <?php
    $args = array('post_type' => 'page',
       'posts_per_page' => 1,
       'orderby' => 'rand',
       );
    query_posts($args);
    if (have_posts()) {
       while (have_posts()) { the_post();
          the_title();
       }
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Random page title with link’ is closed to new replies.
Skip to toolbar