Bug when trying to wp_update within Anspress

4.17K viewsIssues
0

Hi,

I have put the following code in functions.php (for testing purposes, I will need to update the database) :

$metaval=”8″;
echo $metaval;
$wpdb->update( wp_2_postmeta,
array( ‘meta_value’ => $metaval),
array(‘post_id’=>720,
‘meta_key’ => ‘_ap_vote’
)

);

If I call it in footer.php, it works.

But if I call it in answer.php, it gives me a huge error :

Fatal error: Uncaught Error: Call to a member function update() on null in /home/path/site.com/wp-content/themes/wp-pravda/anspress/answer.php:71 Stack trace: #0 /home/path/site.com/wp-content/themes/wp-pravda/anspress/answers.php(57): include() #1 /home/path/site.com/wp-content/plugins/anspress-master/includes/question-loop.php(434): include(‘/home/path/si…’) #2 /home/path/site.com/wp-content/themes/wp-pravda/anspress/question.php(126): ap_question_the_answers() #3 /home/path/site.com/wp-content/plugins/anspress-master/includes/common-pages.php(118): include(‘/home/path/si…’) #4 /home/path/site.com/wp-content/plugins/anspress-master/includes/theme.php(445): AnsPress_Common_Pages::question_page() #5 /home/path/site.com/wp-content/plugins/anspress-master/includes/shortcode-basepage.php(68): ap_page() #6 /path/site.com/wp-includes/shortcodes.php(326): AnsPress_BasePage_Shortcode->anspress_sc(”, ”, ‘anspress’) #7 [internal function]: do_shortcode_tag(Array) #8 /home/path in /home/path/site.com/wp-content/themes/wp-pravda/anspress/answer.php on line 71

 

How come and how can I fix this ?

Thanks beforehand for your answer !

0

Hey, any idea why@Rahul ? Thanks.