• Resolved ivyowl

    (@ivyowl)


    Hi all,

    Just wondering if anyone could shed some light on this.

    I’m using a function created to be used with shortcode,

    it pulls data from custom posts type event within the category specified.

    I’m getting the data back how i want it but just too many,

    4 of 1, 5 of another and 4 again duplicate results from the 3 posts i’m testing with.

    I’ve got some text on a page, with the shortcode below it.

    using this loop to call it all:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php the_content()?>
    <?php endwhile; endif; ?>

    The function code’s here:

    https://pastebin.com/maxfQ9Df

    and its based on a tutorial by Noel Tock here

    Any ideas?

    Many thanks for any advice.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Really difficult to tell without seeing all the code and the output, but the line below seems odd to me because the postmeta table is named in the FROM clause and here. Try taking it out of the function.

    LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)

    Thread Starter ivyowl

    (@ivyowl)

    worked a treat,

    many thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Duplicate posts from custom loop within a function’ is closed to new replies.