• Hey all,

    My website is https://www.theviablealternative.com and on the bottom of every page, I get this error I put below that displays on the bottom of every page. How do I correct this?

    Warning: Missing argument 2 for wpdb::prepare(), called in /home1/ikelove/public_html/wp-content/themes/inove/footer.php on line 22 and defined in /home1/ikelove/public_html/wp-includes/wp-db.php on line 1152

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • review https://make.www.ads-software.com/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/

    for your theme, edit footer.php, and change this line:

    $post_datetimes = $wpdb->get_row($wpdb->prepare("SELECT YEAR(min(post_date_gmt)) AS firstyear, YEAR(max(post_date_gmt)) AS lastyear FROM $wpdb->posts WHERE post_date_gmt > 1970"));

    for example into:

    $post_datetimes = $wpdb->get_row($wpdb->prepare("SELECT YEAR(min(post_date_gmt)) AS firstyear, YEAR(max(post_date_gmt)) AS lastyear FROM $wpdb->posts WHERE post_date_gmt > %d", "1970"));
    Thread Starter ikelove

    (@ikelove)

    Thanks, you said “for example,” so I’m a bit confused. Is this the EXACT line of code I use to get rid of the error?

    Thanks again!

    ‘for exampe’ just means that there might be other codes which work as well ;

    yes, the suggested code should get rid of the warning message.

    Thread Starter ikelove

    (@ikelove)

    Hey man, thanks a lot, it totally worked!

    How please, I’m having problems with getting my index.php page (my default page) to show only ONE category (the uncategorized posts) rather than every single category. How do I get it to show only one category? Would you know?

    Thanks again!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How Do I Fix this "Warning: Missing argument 2 for….." on Footer.php File?’ is closed to new replies.