Php 如何检索以前访问过的WordPress的帖子ID和自定义字段
我有几个帖子会重定向到感谢页面。 在我的感谢页面中,我想检索以前或上次访问的Php 如何检索以前访问过的WordPress的帖子ID和自定义字段,php,wordpress,Php,Wordpress,我有几个帖子会重定向到感谢页面。 在我的感谢页面中,我想检索以前或上次访问的post\u id,以便检索post\u id的自定义字段值,以使我的条件生效 $postid = get_the_ID(); $tags= get_field('product_tags', $postid); if(tags == 'action' && !is_user_logged_in()) { echo 'Not For you'; } else { echo
post\u id
,以便检索post\u id
的自定义字段值,以使我的条件生效
$postid = get_the_ID();
$tags= get_field('product_tags', $postid);
if(tags == 'action' && !is_user_logged_in()) {
echo 'Not For you';
}
else {
echo 'Welcome';
}
结果是:
您已经访问了“自定义字段”下的“上次访问的帖子标题”,我们有一些选项可供选择 1) 您可以使用$\u服务器['HTTP\u REFERER']查找帖子id。您可以通过上一页的slug找到post_id,您可以从$_服务器['HTTP_REFERER']获得它 2) 当重定向到感谢页面时。您可以在查询字符串中包含帖子id。大概 wp_重定向(site_url('Thankyu?id='.$post->id)); 退出 或者,如果您使用javascript进行重定向,则可以获得类似的结果 希望能有帮助