• Hi,

    I’m using this bit of code to try and pull through a post with its title and content.

    SELECT post_title post_content FROM $wpdb->posts WHERE post_type='%s' AND post_status='publish' ORDER BY ID ASC

    The problem is that it is only pulling through the post title and not the content. If I delete ‘post_title’ or ‘post_content’ then the other will show, but i can’t get them to work together.

    I’ve tried using ‘AND’ and a comma between them but then it breaks.

    Anyone help?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Why aren’t you using WP_Query()?

    Thread Starter Creatrix

    (@chrisl_57)

    I’m actually helping someone on fixing this and the majority of the code has already been written, so rather than go rewriting i’m looking for a fix.

    Any ideas?

    You missed out a comma in the query

    SELECT post_title, post_content FROM $wpdb->posts WHERE post_type='%s' AND post_status='publish' ORDER BY ID ASC

    If I were you I wouldn’t be querying the DB like this. Make sure “%s” is properly sanitized.

    You’ve been warned!!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show post title and content’ is closed to new replies.