• Resolved jsites

    (@jsites)


    I’m using this plugin extensively across a site, and in most cases, it is working great. But on a specific page template, it is returning multiple instances of the same post, and not returning other posts.

    Here is my shortcode, that is appearing outside the Loop in a custom page template:

    [ajax_load_more container_type="div" css_classes="people-list-holder" repeater="template_1" post_type="qd_people" posts_per_page="16" orderby="menu_order" scroll="false" button_label="Load More" button_loading_label="Loading People..."]

    And here is “template 1”:

    <div class="singlePerson">
    	<a href="<?php echo get_permalink(); ?>">
    		<?php $headshot = get_field('qd_ppl_headshot'); ?>
    		<?php if($headshot){ ?>
    			<img src="<?php echo $headshot['sizes']['square-img']; ?>" alt="<?php echo $headshot['alt']; ?>" />
    		<?php }else{
    			echo '<div class="noImage"></div>';
    		} ?>
    		<div class="personText">
    			<div class="personName"><?php the_title(); ?></div>
    			<?php $jobTitle = get_field('qd_ppl_job_title');
    			if($jobTitle){
    				echo '<div class="personTitle">'.$jobTitle.'</div>';
    			} ?>
    		</div>
    	</a>
    </div>

    These posts were imported in from an existing WordPress site. I thought that might have something to do with it, but the other post types that are working are not experiencing this same problem.

    • This topic was modified 8 years ago by jsites.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @jsites,
    I think you should start by adjusting the functions in repeater to get content via $post->ID;

    Try the following, if that doesn’t work. Can you share a link?

    <div class="singlePerson">
       <?php global $post; ?>
    	<a href="<?php echo get_permalink($post->ID); ?>">
    		<?php $headshot = get_field('qd_ppl_headshot', $post->ID); ?>
    		<?php if($headshot){ ?>
    			<img src="<?php echo $headshot['sizes']['square-img']; ?>" alt="<?php echo $headshot['alt']; ?>" />
    		<?php }else{
    			echo '<div class="noImage"></div>';
    		} ?>
    		<div class="personText">
    			<div class="personName"><?php the_title(); ?></div>
    			<?php $jobTitle = get_field('qd_ppl_job_title', $post->ID);
    			if($jobTitle){
    				echo '<div class="personTitle">'.$jobTitle.'</div>';
    			} ?>
    		</div>
    	</a>
    </div>
    Thread Starter jsites

    (@jsites)

    I just tried that code, and I’m getting the same results.

    Here’s the page it is occurring on:

    https://aimconsulting.quantumdynamix.net/who-we-are/our-team/

    Let the first 16 people load initially. Then, click the button, and some of the first 16 will appear a second time in that next group. And as more load, some duplicates load a third time. The odd thing is that there are 43 posts in this custom post type, and 43 posts are returned on this page, but some don’t load, and others load multiple times.

    Plugin Author Darren Cooney

    (@dcooney)

    I see the issue.
    Strange one… Can you confirm your ajax load more shortcode is NOT inside another wp_query loop?

    Also, can you try deactivating any post order plugins (just to test)? Im wondering if that might be the issue.

    Thread Starter jsites

    (@jsites)

    Here’s my entire template:

    <?php
    /*
    Template Name: People List Page
     */
    get_header(); ?>
    <?php include('library/snippets/featuredImage.php'); ?>
    <div id="content">
    	<div id="inner-content" class="wrap cf">
            <?php include('library/snippets/breadcrumbs.php'); ?>
    		<main id="main" class="m-all t-2of3 d-5of7 cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="https://schema.org/Blog">
    			<?php if (have_posts()) :
                          while (have_posts()) :
                              the_post(); ?>
    				<article id="post-<?php the_ID(); ?>" <?php post_class( 'cf' ); ?> role="article" itemscope itemtype="https://schema.org/BlogPosting">
    					<section class="entry-content cf" itemprop="articleBody">
    						<?php the_content(); ?>
    					</section>
    				</article>
    			<?php endwhile;
                      endif; ?>
    		</main>
        </div>
        <div id="lower-content" class="wrap cf">
            <div id="peopleListStuff">
                <div id="peopleList">
                    <?php if ($_SERVER['REQUEST_METHOD'] == 'POST'){
                        //Build shortcode using filters:
                        $filterTags = implode(', ', $_POST['pplFilter']);
                        if($filterTags){
                            $tagShortcode = 'taxonomy="qd_people_filter" taxonomy_terms="'.$filterTags.'" taxonomy_operator="IN"';
                        }
                        $filterSearch = $_POST['pplSearchField'];
                        if($filterSearch){
                            $searchShortcode = 'search="'.$filterSearch.'"';
                        }
                        $pplShortcode = '[ajax_load_more container_type="div" css_classes="people-list-holder" repeater="template_1" post_type="qd_people" posts_per_page="16" orderby="menu_order" scroll="false" button_label="Load More" button_loading_label="Loading People..." '.$tagShortcode.' '.$searchShortcode.']';
                        
                        //use jQuery to show active filters: ?>
                        <script type="text/javascript">
                            jQuery(document).ready(function ($) {
                                <?php if($filterSearch){ ?>
                                    $('#peopleFilters #pplSearchField').val('<?php echo $filterSearch; ?>');
                                <?php } ?>
                                <?php if($filterTags){
                                    $terms = $_POST['pplFilter'];
                                    foreach($terms as $term){ ?>
                                        $('#peopleFilters input[value="<?php echo $term; ?>"]').prop('checked', true);
                                    <?php }
                                } ?>
                            });
                        </script>
                    <?php }else{
                        //Build default shortcode:
                        $pplShortcode = '[ajax_load_more container_type="div" css_classes="people-list-holder" repeater="template_1" post_type="qd_people" posts_per_page="16" orderby="menu_order" scroll="false" button_label="Load More" button_loading_label="Loading People..."]';
                    }
                          //echo $pplShortcode;
                    echo do_shortcode($pplShortcode); ?>
                </div>
                <?php include('sidebar.php'); ?>
            </div>
    	</div>
        <?php include('library/snippets/flexblocks.php'); ?>
    </div>
    <?php get_footer(); ?>
    

    All of the additional stuff to build out a different shortcode is for some filtering options. When using those, everything’s working great, no duplication. It’s just when I’m calling all posts in the People post type that i get my duplicates. And it is always the same duplicates.

    Plugin Author Darren Cooney

    (@dcooney)

    Template looks fine.

    Are you using a post order plugin? I’ve seen this cause issues in the past. Im only asking becuase I seen orderby=”menu_order” in the shortcode.

    Thread Starter jsites

    (@jsites)

    I am using a post order plugin. I tried disabling that, and all the other plugins except for Ajax Load More (2.14.0) and Ajax Load More: Custom Repeaters v2 (2.2.4) and I still got the duplicate posts.

    Plugin Author Darren Cooney

    (@dcooney)

    I can’t think of anything else without access to site.

    If you want open a ticket here and we can talk privately.

    Cheers,

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Duplicate Posts Returned’ is closed to new replies.