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">
    <?php       
        global $post;
        $post_slug = $post->post_name;
        query_posts(array( 
            '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">
                <?php 
                    $counter = 0; 
                    while (have_posts()) : the_post();
                    $counter++;
                ?>

                    <li class="rotate testimonial">

                        <ul class="testimonial-content">

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

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

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

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

                    <?php endif; ?> 

            </ul>
        </div>
    </div>
</div>

I appreciate any help

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


Solution:

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: