How can I clone/copy all fields (post and meta) from parent CPT post to child (with synced fields?)
How can I clone/copy all fields (post and meta) from parent CPT post to child (with synced fields?)
How can I clone/copy all fields (post and meta) from parent CPT post to child (with synced fields?)
They aren’t “files” or “folders” per se, but you could achieve that URL structure. Custom code to create custom post types and taxonomies would be the ideal way, as that could then be filtered, searched, etc. However, you could also do this in a no-code way by adding Pages at each level. It’s difficult to … Read more
Just change the ‘child_of’ => $post->ID argument to ‘child_of’ => 61, or whatever the ID of the parent page is.
You need to look at get_ancestors() to get the top level parent of a page. Just a note, for reliability, use get_queried_object() (or even better $GLOBALS[‘wp_the_query’]->get_queried_object()) to get the current post/page object on singular pages, $post can be quite unreliable You can try the following in your shortcode: $post = $GLOBALS[‘wp_the_query’]->get_queried_object(); // Make sure the … Read more
Maybe array_slice($subpages, 0,5) to cut the array after 5 entries?
you can use the number param to limit the number of pages you want and get the custom field in the foreach loop 🙂 (child of = your parent page, or the current page) $mypages = get_pages( array( ‘child_of’ => $post->ID, ‘sort_column’ => ‘post_date’, ‘sort_order’ => ‘desc’, ‘number’ => 3, ) ); foreach( $mypages as … Read more
Here is the code that ended up working for me: <?php $mypages = get_pages( array( ‘child_of’ => $post->ID, ‘sort_column’ => ‘menu_order’, ‘sort_order’ => ‘asc’ ) ); foreach( $mypages as $page ) { $content = $page->post_content; $content = apply_filters( ‘the_content’, $content ); $price = get_post_meta( $page->ID, ‘price’, true ); ?> <div class=”service”> <h4><a href=”https://wordpress.stackexchange.com/questions/126795/<?php echo get_page_link( … Read more
I modified my code based on this posting’s answer, and the page displays everything I want now. <div id=”masonry-loop” class = “group”> <?php global $post; $child_pages_query_args = array( ‘post_type’ => ‘page’, ‘post_parent’ => $post->ID, ); $child_pages = new WP_Query( $child_pages_query_args ); if ( $child_pages->have_posts() ) : while ( $child_pages->have_posts() ) : $child_pages->the_post(); ?> <?php $images … Read more
How to display child pages with in a limited child content?
The sort_column parameter of wp_list_pages() does allow items to be returned in random order using the rand option. sort_column (string) Comma-separated list of column names to sort the pages by. Accepts ‘post_author’, ‘post_date’, ‘post_title’, ‘post_name’, ‘post_modified’, ‘post_modified_gmt’, ‘menu_order’, ‘post_parent’, ‘ID’, ‘rand’, or ‘comment_count’. Default ‘post_title’. add_shortcode( ‘wpb_childpages’, ‘wpb_list_child_pages’ ); function wpb_list_child_pages() { global $post; if … Read more