alternating classes on wp_list_pages

Consider this a complement to toscho’s solution. I believe that … $this->alternate = ($this->alternate != ‘background_1’) ? ‘background_1’ : ‘background_2′; $css_class[] = $this->alternate; … will do what you want. The difference is that toscho’s solution, using the static keyword, will make that variable static for any instantiation of this walker– that is, all instances will … Read more

Add Parent to Subpage List

<?php if($post->post_parent){ $children = wp_list_pages(“title_li=&include=”.$post->post_parent.”&echo=0″); $children .= wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0″); } else { $children = wp_list_pages(“title_li=&include=”.$post->ID.”&echo=0″); $children .= wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″); } if ($children) { ?> <ul class=”subpages”> <?php echo $children; ?> </ul> <?php } ?> Try that. Just have to include the parent much like you do on the child pages, but using the current $post-ID.

Hide Parent if No Children

<?php if ($post->post_parent) { //We are a child, print out sub menu wp_list_pages( array(‘title_li’=>”,’include’=>$post->post_parent) ); wp_list_pages( array(‘title_li’=>”,’depth’=>1,’child_of’=>$post->post_parent) ); } //We are not a child but do we have children $children = wp_list_pages(array(‘child_of’ => $post->ID, ‘echo’ => 0)); if ( !empty($children) ) { //If so print out the sub menu wp_list_pages( array(‘title_li’=>”,’include’=>$post->ID) ); wp_list_pages( array(‘title_li’=>”,’depth’=>1,’child_of’=>$post->ID) ); … Read more

wp_list_page with something like showpost

Just pass number=5 and it should work since wp_list_pages() uses get_pages() which has number parameter, and also if you look at wp_list_pages codex entry at the bottom under change log you can see that it take the number parameter since version 2.8

List subpage of subpage

Here is a function that im using for submenus, maybe there is a better way to do this but i always ends up with this solution. Add this function to your theme functions.php file: function wpse_submenu( $id, $echo = false, $showParent = true, $depth = 0 ) { global $wpdb, $post, $before, $page_for_posts; // if … Read more

List all Posts under heading in wp_list_pages menu

You’ve got the right idea, however; Don’t use query_posts, use get_posts instead Using the wp_list_pages filter will just add the list at the end Using template tags like the_permalink() will echo the output, so you can’t use it in string concatenation You’ll need to use a custom walker (the family of classes for generating hierarchical … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)