Forums

[resolved] Duplicate posts from custom loop within a function (3 posts)

  1. ivyowl
    Member
    Posted 1 year ago #

    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:

    http://pastebin.com/maxfQ9Df

    and its based on a tutorial by Noel Tock here

    Any ideas?

    Many thanks for any advice.

  2. vtxyzzy
    Member
    Posted 1 year ago #

    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)

  3. ivyowl
    Member
    Posted 1 year ago #

    worked a treat,

    many thanks

Topic Closed

This topic has been closed to new replies.

About this Topic