1

I'm trying to write an if statement based on the url of the previously click page_id

Something like this:

<?php 
$page_id = " the id or url of the page clicked to get to this page"
if($page_id){
    jr_register_form_jseeker( $redirect, $role ); 
}else{
    jr_register_form( $redirect, $role ); 
}
?>

I've looked at is_page() but that only seems to deal with the current page...?

Any ideas..?

Thanks

4

2 回答 2

1

您可以使用wp_get_referer(). 在文档中阅读更多信息。

或者只是打电话给:$_SERVER['HTTP_REFERER']

于 2012-11-21T16:11:54.043 回答
0

没有返回上一页 id 的 wordpress 函数。但是,您可以使用$_SERVER['HTTP_REFERER']. 它应该包含上一页的 ID 作为参数。结合parse_urlparse_str你应该能够获得ID:

parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $output);
$id = $output['p'];

(未测试)

于 2012-11-21T16:12:49.033 回答