Support » Fixing WordPress » wpdb query returns the same titles but different excerpts/content

  • Resolved kingmaico

    (@kingmaico)


    I made a shortcode using custom wpdb query (it’s not complete but i kept it short for the sake of this question:

    /* B1 nieuws shortcode*/
    function b1nieuws_function() {
    global $wpdb;
    $querystr = “SELECT * FROM $wpdb->posts WHERE post_status = ‘publish’ AND post_type=’post'”;
    $bnieuws = $wpdb->get_results($querystr, OBJECT);
    if ($bnieuws) {
    foreach ($bnieuws as $post) {
    setup_postdata($post);
    $return_string .= ‘<div class=”yui3-u-1-2 b1nieuws”><h2>’.get_the_title().'</h2><small>’.get_the_date(‘l j F Y’).’ ‘.get_the_time().'</small>’.get_the_excerpt().'</div>’;
    }
    return $return_string;
    }
    }

    It returns the correct amount of posts, but all titles, post_date and permalink are the same. See http://blikopzeewolde.kingmaico.com
    It’s halfway the page, left side.

    Does anybody have any idea what I’m doing wrong?

    I’ve used similar query before and didn’t have this problem.

    Thanks

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘wpdb query returns the same titles but different excerpts/content’ is closed to new replies.