Home › Forums › General Issues › Return a custom field in functions.php › Reply To: Return a custom field in functions.php
You will need to get know what post or where you’re getting the field from and supply the value in the second of…. and you’ll also need to use get_field() which I just noticed. the_field() echoes the value so first try
add_filter( 'search_autocomplete_modify_url', 'saModifyURL', 10, 2 );
function saModifyURL( $link, $object ) {
$newLink = 'http://website.com/?Click=<?php get_field("id_number"); ?>';
return $newLink;
}
if that does not work then figure out how you’re going to supply the post id
get_field("id_number", $post_id);
side note, use back ticks to include code, or click the code link at the top of the editor.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.