Monthly Archives: July 2014

Display random list of Posts

<ul><li><h2>A random selection of my writing</h2> 
$rand_posts = get_posts('numberposts=5&orderby=rand'); 
foreach( $rand_posts as $post ) : 
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> 
<?php endforeach; ?> 

Display Latest Posts

<?php query_posts('showposts=5'); ?> 
<?php while (have_posts()) : the_post(); ?> 
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li> 
<?php endwhile;?> 

Child pages of parent page menu in sidebar

You can also use this plugin:
if u want add main title as main page then use this plugin:
by default all childpages short by name, if u want add desiding order then:
got to plugin’s => edit => and replace this line
$pages = wp_list_pages(‘depth=0&title_li=&child_of=’.$id.’&echo=0&sort_column=menu_order’);

past in sidebar.php 

<?php global $post;?>
$parent_title = get_the_title($post->post_parent);
$children = wp_list_pages(“depth=1&title_li=&child_of=”.$post->post_parent.”&echo=0″); // append the list of children pages to the same $children variable
if ($parent_title) { ?>
<h2 class=”widgettitle”><?php echo $parent_title; ?></h2>
<?php }

if ($children) { ?>
<ul class=”submenu”>
<li><?php echo $children; /*print list of pages*/ ?></li>
<?php } ?>

%d bloggers like this: