Skip to content

Instantly share code, notes, and snippets.

@dexit
Forked from phucdohong96/Function.php
Created December 2, 2020 21:34
Show Gist options
  • Select an option

  • Save dexit/27c1fa3a0f8871a8d9e1c99ae1c4b707 to your computer and use it in GitHub Desktop.

Select an option

Save dexit/27c1fa3a0f8871a8d9e1c99ae1c4b707 to your computer and use it in GitHub Desktop.
Get ID from previous page
<?php
function get_featured_image_func() {
$postid = url_to_postid( $_SERVER['HTTP_REFERER'] );
$image = get_field('featured_image', $postid);
$image = '<img src="'.$image["url"].'" />';
return $image;
}
add_shortcode( 'get_featured_image_shortcode', 'get_featured_image_func' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment