Monthly Archives: July 2014

Display random list of Posts

<ul><li><h2>A random selection of my writing</h2> 
<ul> 
<?php 
$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; ?> 
</ul> 
</li></ul>

Display Latest Posts

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

Child pages of parent page menu in sidebar

You can also use this plugin:
http://wordpress.org/plugins/child-page-navigation/
if u want add main title as main page then use this plugin:
https://wordpress.org/plugins/children-pages/screenshots/
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;?>
<?php
if($post->post_parent){
$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>
</ul>
<?php } ?>

%d bloggers like this: