• What PHP code can I use to query my WordPress MySQL database and return a value into a template – e.g. the content of a post.

    Also, is it possible to do this inside a page if I install one of the PHP plugins?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter fxfuture

    (@fxfuture)

    I’ve tried this but it’s not working and just says Array.

    $mytext = $wpdb->get_results("SELECT post_content FROM $wpdb->posts WHERE ID = 160");
    
    echo $mytext;

    Any ideas?

    Thread Starter fxfuture

    (@fxfuture)

    Got it working! Here’s the correct code.

    $mytext = $wpdb->get_results("SELECT post_content FROM $wpdb->posts WHERE ID = 160");
    
    echo $mytext->post_content;
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Query and return value from the database?’ is closed to new replies.