I have created a custom page template which outputs testimonials if the slug for the testimonial category matches the page slug.

What I want to do is if a parent page has the testimonials it outputs the same testimonials on all child pages.

Code below:

<div class="service-testimonials-area">
<div class="container12">
    <div class="column12">
        global $post;
        $post_slug = $post->post_name;
            'post_type' => 'testimonial', 
            'testimonials' => $post_slug,
            'post_parent' => $post_slug,
            'order' => 'ASC', 
            'posts_per_page' => -1 
        <?php if ( have_posts() ): ?>
        <div class="service-testimonials">

            <ul class="service-testimonials-rotator">
                    $counter = 0; 
                    while (have_posts()) : the_post();

                    <li class="rotate testimonial">

                        <ul class="testimonial-content">

                            <li class="testimonial-name">
                                <a href="<?php the_permalink(); ?>">
                                    <?php the_title(); ?>

                            <li class="testimonial-text">
                                <?php the_content(); ?>

                    <?php //comments_template( '', true ); // Remove if you don't want comments ?>

                    <?php endwhile; ?>
                    <?php wp_reset_query();   ?>
                    <?php else: ?>

                    <?php endif; ?> 


I appreciate any help

Read more here: Custom WordPress Page that shows parent content on child pages


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: