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 = '<?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.