• Resolved shirfarhad

    (@shirfarhad)


    Hi,

    I’m using a self-made theme for my wordpress and I want to list five random pages instead of all pages and I thought of starting with this:

    <?php wp_list_pages(‘child_of=135&title_li=&orderby=rand()’); ?>

    But it doesn’t seem to work, I thought this code would show all my pages of category 135 randomly each time but it doesn’t.

    What I want is first to get five pages instead of all subpages of page nr 135 and I want to see five different page links each time I visit my website.

    Anyone knows how to do this?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter shirfarhad

    (@shirfarhad)

    I think I’ve found a plugin that does this for posts:

    http://www.ax697.org/category-magic-on-wordpress-200765.html

    Hopefully someone has a solution for pages.

    Thread Starter shirfarhad

    (@shirfarhad)

    *bump*

    Thread Starter shirfarhad

    (@shirfarhad)

    Ok getting five pages only wasn’t that difficult, I was just trying something out with a foreach statement and made this:

    <?php
    	$pages = (get_pages("orderby=rand()&title_li="));
    	$int = 1;
    	foreach ($pages as $page){
    		if(++$int == 7){
    			break;
    		}
    		echo '<li><a href="'.$page->post_name.'">'.$page->post_title.'</a></li>';
    	}
    ?>

    That gives me five pages only.

    Now I want to sort it randomly each time, so it would be possible to see page A,C,E,F,G one time and B,F,D,Z,J the other time.

    This shouldn’t be too difficult, or is it?

    Thread Starter shirfarhad

    (@shirfarhad)

    Ok, great I’ve got it working.

    I created my own plugin and edited the post redirect plugin to get this working.

    Now I can get random pages and set a limit.

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

The topic ‘[wp_link_pages] Getting five random pages’ is closed to new replies.