Show child pages when on a child page

Add this code in sidebar.php.this code will help you. global $post; $parent_id = $post->post_parent; if(!empty($parent_id)){ $parent_post=get_post($parent_id); echo ‘<h1 class=”entry-title”>’.$parent_post->post_title.'</h1>’; echo ‘<ul>’; $children = wp_list_pages(‘title_li=&child_of=” . $parent_id . “&echo=0’); if ($children) { echo $children; echo ‘</ul>’; } } else { echo ‘<ul>’; $page =$post->ID; $children = wp_list_pages(‘title_li=&child_of=” . $page . “&echo=0’); if ($children) { echo $children; … Read more

Paginate Child Pages Content on Parent Page

After some searching I was able to find this post: http://wordpress.org/support/topic/add-pagination-to-list-of-child-pages My final code looks like this: <?php $ids = array(); $pages = get_pages(“child_of=”.$post->ID); if ($pages) { foreach ($pages as $page) { $ids[] = $page->ID; } } $paged = (get_query_var(“paged”)) ? get_query_var(“paged”) : 1; $args = array( “paged” => $paged, “post__in” => $ids, “posts_per_page” => … Read more

How to get a list of all recently published child pages?

This will get you the post data for all child pages: $args = array( ‘post_type’ => ‘page’, ‘post_parent__not_in’ => array(0), ‘no_found_rows’ => true, ); $child = new WP_Query($args); var_dump(wp_list_pluck($child->posts,’post_title’)); // debugging only Then pass the IDs to wp_list_pages(): $args = array( ‘post_type’ => ‘page’, ‘post_parent__not_in’ => array(0), ‘no_found_rows’ => true, ); $child = new WP_Query($args); … Read more

Child page in custom post throws 404 page not found

It turns out the WordPress permalink structure works perfectly well for custom types, e.g. example.com/recipes/lunch/sandwich/. This works exactly as expected if you set ‘hierarchical’ => true. What I was originally trying to do was unnecessarily difficult to execute, and requires properly setting up a custom permalink structure to avoid 404 errors. I advise you stick … Read more

What is the optimal way to filter out subpages from admin?

This works for our needs: # Parent filtering function wps_restrict_manage_posts() { global $typenow; # only run this filter on page post type if ( $typenow == ‘konverentsid’ ) { # Parent Page Filter (HTML) $args = array( ‘post_type’ => ‘konverentsid’, ‘child_of’ => 0, ‘show_option_none’ => __(‘Show all pages’), ‘depth’ => 1, ‘name’ => ‘wps_page_filter’, ‘selected’ … Read more

Multiple Conditions for Child Page Title

Based on the comment exchange, here’s what I think you’re after: <h1><?php echo get_the_title( $post->post_parent ? $post->post_parent : $post->ID ) ?></h1> <?php if ( $list = wp_list_pages( “echo=0&child_of=$post->ID” ) ) : ?> <h2>Select a sub-page</h2> <ul> <?php echo $list ?> </ul> <?php elseif ( $post->parent ) : ?> <h2><?php the_title() ?></h2> <?php endif ?>

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