Hi, I’m trying to use get_field to get the field value, and save it as a shortcode by creating a function first.
function get_homepage_excerpt() {
$myfield = get_field(‘homepage_excerpt’);
return $myfield;
}
add_shortcode( ‘homepageexcerpt’, ‘get_homepage_excerpt’ );
This seems simple, yet is not working. Am I missing something?
You have to supply the post ID of the home page if you are trying to do this on a different page
$myfield = get_field('homepage_excerpt', $home_page_id);