WordPress.org

Ready to get started?Download WordPress

Forums

Random page title with link (2 posts)

  1. robinvd
    Member
    Posted 4 years ago #

    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?!

  2. vtxyzzy
    Member
    Posted 4 years ago #

    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();
       }
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.