• I try to use the snippet approach to call information from my WP databases, using $wpdb. This leads to a fatal error.
    Please find below the sippet coding and the error message.

    <?php
    $posts = $wpdb->get_row(“SELECT ID, post_title FROM wp_posts WHERE post_status = ‘publish’
    AND post_type=’post’ ORDER BY comment_count DESC LIMIT 0,1″);
    // Echo the title of the most commented post
    echo $posts->post_title;
    ?>

    Fatal error: Call to a member function get_row() on null in C:\xampp\apps\wordpress\htdocs\wp-content\plugins\php-code-for-posts\PHPPostCode.php(85) : eval()’d code on line 6

    Any advice / suggestion how I can resolve this?
    Regards

    https://ww.wp.xz.cn/plugins/php-code-for-posts/

The topic ‘$wpdb->get_row not working’ is closed to new replies.