Support » Developing with WordPress » Need to get data from plugin table

  • Hi,

    I have been battling this for hours and canot find the solution

    I need to return some text from a plugins table using the following php

    <?php $post_id = get_the_ID(); echo $wpdb->get_var( $wpdb->prepare(“SELECT message_before FROM {$wpdb->prefix}mlw_quizzes WHERE quiz_id = %d”, $post_id ) ); ?>

    I know the variable works as

    <?php echo $post_id= get_the_ID(); ?>


    I’ve resused similar code and just cannot get it to work.

    Any help appreciated.

Viewing 1 replies (of 1 total)
  • Topher


    Try storing the query in a variable, and then print the variable, so you see query as it’s being sent to the database.

    Then try running the query directly in phpMyAdmin or something like it and see if the query works. If the query works then it’s something else in your code.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.