我尝试更新wordpress元字段,然后在成功提交表单后显示该新值。
该字段实际上正在更新,但似乎Wordpress在重新加载页面时缓存旧值。
这是我的代码......
<?php
if (!isset($_GET['pid']))
header('Location: ' . get_bloginfo('wpurl'));
$query = new WP_Query(array('post_type' => 'vacancies', 'p' => $_GET['pid']));
$meta = get_post_meta($_GET['pid']);
$date = DateTime::createFromFormat('Y-m-d', $meta['closing-date'][0]);
if (isset($_POST['closing-date']) && $_POST['closing-date'] != '' )
{
if ($_POST['confirmation'] == $confirmation)
{
$dt = DateTime::createFromFormat('d/m/Y', $_POST['closing-date']);
update_post_meta($_GET['pid'], 'closing-date', $dt->format('Y-m-d'));
echo 'Success';
}
else
{
echo 'There was an error';
}
}
?>
<form method="post" action="http://<?php echo $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ?>">
<input name="closing-date" type="text" value="<?php echo $date->format('d/m/Y') ?>" class="datepicker form-control" />
<input name="confirmation" type="text" class="form-control" />
<input type="submit" id="gform_submit_button_14" class="button button-secondary" value="Submit">
</form>
谁能告诉我发生了什么以及如何清除它?我尝试过重置WP_Query对象,但似乎没有用。
由于