Update_Post_Meta Isn’t Working On Functions.php
-
Hi. I wrote a code and added to my functions.php on my WordPress site. Theme is a coupon theme.
If offer URL is filled, it shows a “go to offer” button; if not filled, it doesn’t show.
Also there is a brand of offer; brand has a general homepage URL.
I want to assign brand URL to offer URL when offer URL is blank.
I wrote a code, and too see if it’s working, i added shortcode. it shows the brand URL with shortcode correctly but button doesn’t show. I couldn’t find where the problem is? Please help.
Then i tried with Update_Post_Meta, it didn’t work.
even for manually added ID, still don’t work.update_post_meta( '3110', 'rehub_offer_product_url', $brandurl);here is mysql db screenshot: https://i.ibb.co/BZfchXq/image.png
if(!function_exists('emreboslinkyonlendir')){ add_filter('rh_no_brand_url', 'emreboslinkyonlendir',1000, 2); function emreboslinkyonlendir($offurl, $postid=''){ if(!empty($postid)){ $postaid = $postid; }else{ $postaid = get_the_ID(); //get id of opened post } $offurl = get_post_meta($postaid, 'rehub_offer_product_url', true); $termaids = wp_get_post_terms($postaid, 'dealstore', array("fields" => "ids")); //find brand of the post $termaid = $termaids[0]; //find first of array $brandurl = get_term_meta( $termaid, 'brand_url', true ); //get brand_url column $offurl = esc_url($brandurl); //$offer_url = ( $brandurl ); return $offurl; } add_shortcode( 'offurl' , 'emreboslinkyonlendir' ); //for testing, to see i added a shortcode if it's working }[1]: https://i.stack.imgur.com/kqVAN.png
[2]: https://i.stack.imgur.com/aHPcV.png
[3]: https://i.stack.imgur.com/hgfRp.png
[4]: https://i.stack.imgur.com/PbRWK.png
[5]: https://i.stack.imgur.com/o5vNr.png
The topic ‘Update_Post_Meta Isn’t Working On Functions.php’ is closed to new replies.