I am trying to get the ID of a referring WordPress page and show link based on the specific previous page. I know that we can use server http referrer but it would be more suitable for me to get the referring WP page/post ID and echo some html content on the page by if statement.
I have a following code example put together from various parts (it is not structurally correct but I hope you got the idea):
$visitorcamefrom = $_SERVER['HTTP_REFERER'];
if ( $visitorcamefrom == icl_object_id(17, 'page', true) ) { echo <a href="<?php echo(get_permalink(icl_object_id(8, 'page', true))); ?>" class="absolute-top-left left-arrow btn btn-lg btn-primary visible-lg"><span class="icon1"></span></a> }
else { echo <a href="<?php echo(get_permalink(icl_object_id(12, 'page', true))); ?>" class="absolute-top-left left-arrow btn btn-lg btn-primary visible-lg"><span class="icon2"></span></a> };
Aucun commentaire:
Enregistrer un commentaire