List child pages of a specific page
To list subpages of a particular page, use wp_list_pages with child_of argument. $parent_page_id = 42; wp_list_pages( array( ‘child_of’ => $parent_page_id ) );
To list subpages of a particular page, use wp_list_pages with child_of argument. $parent_page_id = 42; wp_list_pages( array( ‘child_of’ => $parent_page_id ) );
There’s no way in WordPress to assign the capability for editing (or any action) a specific post to a role. However, you can filter capabilities checks and change them on the fly using the map_meta_cap. When handling post permissions, WordPress ultimately deals in just 4 capabilties: edit_post read_post delete_post publish_post Then whenever an action is … Read more
As @Soulseekah said, you can do this with post_parent. I didn’t test with the following code, but it should work $pages = array( array( ‘name’ => ‘page1’, ‘title’ => ‘Page 1’, ‘child’ => array( array( ‘name’ => ‘page11’, ‘title’ => ‘Page 1.1’ ), array( ‘name’ => ‘page12’, ‘title’ => ‘Page 1.2’ ) ) ), array( … Read more
Here’s a way to get the top page url: $top_page_url = get_permalink( array_slice( get_ancestors( get_the_ID(), ‘page’ ) , -1 ) ); where get_ancestors() returns an array containing all the parents (ID) of the given page. You can read more about it in the Codex here. Here are various ways to get the last array item, … Read more
All right, here it is, fully working: <?php $pagelist = get_pages(“child_of=”.$post->post_parent.”&parent=”.$post->post_parent.”&sort_column=menu_order&sort_order=asc”); $pages = array(); foreach ($pagelist as $page) { $pages[] += $page->ID; } $current = array_search($post->ID, $pages); $prevID = $pages[$current-1]; $nextID = $pages[$current+1]; ?> <div class=”navigation”> <?php if (!empty($prevID)) { ?> <div class=”previous”> <a href=”https://wordpress.stackexchange.com/questions/54422/<?php echo get_permalink($prevID); ?>” title=”<?php echo get_the_title($prevID); ?>”>Previous</a> </div> <?php } … Read more
I’m fairly certain the problem is that some template tags rely on the global $post variable. Using setup_postdata() as you are now, will not alter $post. If you replace all the instances of $pageChild with $post, everything should work. However, I would strongly recommend using the WP_Query class and setting up your post data with … Read more
There is no specifica template for child pages, but you can do this pretty easily with the get_template_part() function. First create a file called “content-child.php”. Second create a file called “content.php”. Next, inside of page.php, place this: if( $post->post_parent !== 0 ) { get_template_part(‘content’, ‘child’); } else { get_template_part(‘content’); } Anything that you want displayed … Read more
I ended up changing the post type to ‘video’ to avoid the slug conflict with page ‘Videos’. I it a WP default behavior to give priority to the post type over the page slug: How to make pages slug have priority over any other taxonomies like custom-post, post or category
you actually don’t need any ajax or server side action, simple see if the user has selected a parent page: add_action( ‘admin_head-post-new.php’, ‘publish_admin_hook_wpse_78690’ ); add_action( ‘admin_head-post.php’, ‘publish_admin_hook_wpse_78690’ ); function publish_admin_hook_wpse_78690() { global $current_screen; if( ‘page’ != $current_screen->post_type ) return; ?> <script language=”javascript” type=”text/javascript”> jQuery(document).ready(function() { jQuery(‘#publish’).click(function() { var parent_id = jQuery(‘#parent_id’).val(); if (parseInt(parent_id) > 0){ … Read more
The best way is using WP_Query. I think your error or plugin error could be that the ‘post_type’ of childs is not define. WP Query : https://codex.wordpress.org/Class_Reference/WP_Query global $post; $args = array( ‘post_parent’ => $post->ID, ‘posts_per_page’ => -1, ‘post_type’ => ‘products’, //you can use also ‘any’ ); $the_query = new WP_Query( $args ); // The … Read more