Recent Global Posts wpdb->prepare error

function get_post_types() {
global $wpdb;

$sql = $wpdb->prepare( "SELECT post_type FROM " . $wpdb->base_prefix . "site_posts GROUP BY post_type" );

$results = $wpdb->get_col( $sql );

return $results;
}

Needs to be updated and fixed so the warning goes away. Should be:

function get_post_types() {
global $wpdb;

$sql = $wpdb->prepare( "SELECT post_type FROM %ssite_posts GROUP BY post_type", $wpdb->base_prefix );

$results = $wpdb->get_col( $sql );

return $results;
}

  • Paul Barthmaier
    • Code Wrangler

    HI there, ivn!

    Thanks for the heads up. I wonder, though, where you are seeing this 'error.' We have seen this type of warning, ie not actually an error, since 3.5 was released, but the function get_post_type is usually one that gets called in theme files. I also didn't see that function used in Post Indexer. Let us know what you find.

    Cheers,
    Paul

  • Mason
    • DEV MAN’s Sidekick

    Hiya,

    Just checking in to see if this ticket is now resolved? As we haven't heard back, I'm hoping it is and am marking it accordingly, but if you have any questions on this in the future, feel free to re-open it and let us know.

    Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.