首页 > 解决方案 > 需要重新加载页面以在 Wordpress 中显示 meta_key 的新值

问题描述

我尝试update meta key使用自定义表单wordpress

内容管理系统:WordPress

插件:高级自定义字段

字段类型:中继器字段

这是 single.php 中的代码

if(isset($_POST['submit'])){
  if( have_rows('custom_req') ){
    while( have_rows('custom_req') ){ the_row(); 
      $r_req = get_sub_field('req_fie');
      if ($_POST['radio-b'] == $r_req ) { 
        update_sub_field('rq_answer', 'new_value');
      }
    }
  }
}
if( have_rows('custom_req') ){
  while( have_rows('custom_req') ){ the_row(); 
    the_sub_field('rq_answer'); // This line shows the previous value
  }
}

问题是显示以前的值,必须重新加载页面才能显示新值

这是为什么?我该如何解决这个问题?

谢谢你的帮助

标签: phpwordpressforms

解决方案


推荐阅读