Parent and child pages in permalink
-
I want to display child page preview with excerpt on a parent page. The child page will always have the same title, but the parent will be different.
At the moment Im using this code:
$page = get_page_by_title( 'Child Title' ); $page_excerpt = $page->post_excerpt; <header class="wpb_wrapper"> <h4 class="gp-element-title xcpt"> <a href="<?php echo esc_url( get_permalink( $page ) ); ?>"> <?php echo $page_data->post_title; ?> </a> </h4> </header> <div class="gp-entry-content xcpt page-layout"><?php echo $page_excerpt; ?><br/> <a href="<?php echo esc_url( get_permalink( $page ) ); ?>">Read More...</a> </div>
This code sits in the parent page template and every time I create new parent page the parent link stays the same, but I want it take the slug from the new parent page. So for example now there is https://www.example.com/parent/child and when I create new parent page called “new parent” I want it to be https://www.example.com/new-parent/child.
Also the excerpt doesnt work and I have to manually enter the text into metabox in admin, is there a way to display the excerpt dynamically? Thanks for any help!
- The topic ‘Parent and child pages in permalink’ is closed to new replies.