displaying child pages in columns when on a parent page
displaying child pages in columns when on a parent page
displaying child pages in columns when on a parent page
I’m outlining a solution for you, it uses get_children to determine if there are any, then conditionally sets up the post id $p_id for the child_of parameter, so that the list of child pages from a certain parent always can be shown, by making use of wp_list_pages(). Code: function wpse125273_child_page_nav() { global $post; $args = … 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
Add following function into your functions.php file: function is_child_of() { global $post; return is_page() && in_array( $post->post_parent, func_get_args() ); } And use it in your template like this: if ( is_child_of( 5860, 1047 ) ) { // is child of 5860 or 1047 }
How can I give WordPress child custom post type the same title and slug as its parent?
Custom Post Type Child Pages
I think you can use a different approach: write a custom sql query that get the ids of the thumbnails attachment of the children pages, and if found call wp_get_attachment_image_src on this ids to retrieve the urls: function my_get_thumbnails( $post = NULL, $which=”both” ) { // first we get the post, if no post is … Read more
I think that the very helpful user gave you a wrong answer. Here a example which I think is better: //The ID of the parent page, for example 4. Change to the correct ID. //For example, if you are in the page loop, you can use get_the_ID() to get ID of current page $parent_id = … Read more
When you register a new post type for the first time, you need to visit Settings -> Permalinks so WordPress can set up the permalink rules for it. You don’t even need to hit save, visiting the page is enough.
The publish_page action is listed as deprecated. You can use the ‘transition_post_status’ hook to check if a page was published. function publish_page_interception( $new_status, $old_status, $post ) { if ( ($new_status != $old_status) && ($post->post_status == ‘publish’) && ($post->post_type == ‘page’) ) { if($post->post_parent > 0) { //do stuff } } } add_action( ‘transition_post_status’, ‘publish_page_interception’, 10, … Read more