Home Forums General Issues get field values from query


get field values from query

  • While using a front end form, could get values from a query?

    Something like this:, so when you click on the link that will take you to the form, the field called foo_name will be fille by default with the value bar.

  • Hi @gabyferman,

    Hmm… I believe that this should be possible using the acf/load_value filter. The code should be as shown below:

    add_filter('acf/load_value/key=<field_key>', 'my_text_value', 10, 3);
    function my_text_value($value, $post_id, $field) {
    	$value = isset($_GET['foo_name'])?$_GET['foo_name']:'default_value';
    	return $value;

    Have a look at the documentation for more information on this filter:

  • Hi,

    I tried this approach, and while it work with the form it messes up all the other entries, they all get default_value as the foo_name field value

  • duh, I though default_value was a type of variable for ACF :$ I just change it for $value and it worked.

    function my_text_value_group_type( $value, $post_id, $field ) {
    	$value = isset( $_GET['foo_name'] ) ? $_GET['foo_name'] : $value;
    	return $value;
    add_filter('acf/load_value/key=<field_key>', 'my_text_value_group_type', 10, 3);

    Thank you

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘get field values from query’ is closed to new replies.