Can you exclude child pages of a specific parent within a navigation?

try -: if your page ID = 999 <?php $child_ids = $wpdb->get_col(“SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent = 999 AND $wpdb->posts.post_type=”page” AND $wpdb->posts.post_status=”publish” ORDER BY $wpdb->posts.ID ASC”); $exclude = implode($child_ids,’, ‘); wp_list_pages(‘exclude=” . $exclude . “&title_li=<h2>’ . __(‘Pages’) . ‘</h2>’); ?>

Sub Navigation in Sidebar

Got it working. This is the final code (pulled from http://cssglobe.com/post/5812/wordpress-find-pages-top-level-parent-id with little modification) <?php if ($post->post_parent) { $ancestors=get_post_ancestors($post->ID); $root=count($ancestors)-1; $parent = $ancestors[$root]; } else { $parent = $post->ID; } $children = wp_list_pages(“title_li=&child_of=”. $parent .”&echo=0&depth=1″); if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?>

Add classes + taxonomy terms to wp_list_pages() output

Doesn’t WordPress already at the class current_page_parent, current_page_ancestor and current_page_item (see source). The filter you are using is called on 1046. As for your question, you create the array $content_type and then attempt to make a string out of $the_content_type. Try: function wpse56088_page_css_class( $css_class, $page, $depth, $args, $current_page ){ $terms = get_the_terms( $page->ID, ‘content-type’ ); … Read more

Exclude current page in wp_list_pages

Your code won’t work if you have more than one parent page or multiple levels of child pages. Use get_ancestors to get the top parent page, and use the child_of argument of wp_list_pages rather than exclude to only output pages from that branch.

Getting subpage of subpage – Custom posts

The problem is here $subpages = get_pages( array( ‘child_of’ => $pageId, ‘sort_order’ => ‘asc’, ‘sort_column’ => ‘menu_order’) ); ‘child_of’ parameter also queries for the grandchildren along with children. Use the ‘parent’ parameter instead which will only query for the direct children. Once this is done, you’ll use the same code in your foreach again foreach($subpages … Read more

How to prevent custom walker from creating sub navigation for pages that are not relatives of the current page?

You may find this article I wrote over at WPtuts helpful. The following example I’ve adapted from that article. It lists all the top leve links, but only explores ancestors of the ‘current’ menu item. Hopefully the logic is clear with the comments: class WPSE73358_Ancestors_Only_Walker extends Walker_Nav_Menu { // Only follow down one branch function … Read more

Inset image thumbnail from page into list

You can use get_pages to do that: <?php $pages = get_pages(array(“child_of’ => get_the_ID())); ?> <ul class=”treatments-list h3″> <?php foreach ($pages as $page): ?> <li> <?php echo get_the_post_thumbnail($page->ID, ‘thumbnail’); ?> <h2> <a href=”https://wordpress.stackexchange.com/questions/77151/<?php echo get_permalink($page->ID); ?>” title=”<?php echo esc_attr($page->post_title);?>”> <?php echo $page->post_title; ?> </a> </h2> </li> <?php endforeach; ?> </ul>

Listing Sub-Pages & Sub-Sub-Pages

So it turns out to be a bit easier than I thought: <?php if ($post->post_parent) { $ancestors=get_post_ancestors($post->ID); $root=count($ancestors)-1; $parent = $ancestors[$root]; } else { $parent = $post->ID; } ?> <?php $args = array( ‘depth’ => 0, ‘date_format’ => get_option(‘date_format’), ‘child_of’ => $parent, ‘title_li’ => __(”), ‘sort_column’ => ‘menu_order, post_title’ ); ?> <ul> <?php wp_list_pages( $args … Read more

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