Home Forums Backend Issues (wp-admin) ACF field value from query string


ACF field value from query string

  • I have custom fields setup for my products post type. In the backend on new product page, I would like to populate a field from the value in a query string in the URL. I am using a custom admin menu with custom links. What is the code thats needed to set a custom field value based on the value of the query string.

    I know how $_GET works, I just need to know the custom function to store the value of the query string to the custom field.


  • I have made it work. See my example code:

    add_filter('acf/load_value/name=product_type', 'my_acf_load_value', 10, 3);
    function my_acf_load_value( $field ) {
    	if (isset($_GET['product_type'])) {
        $product_type = $_GET['product_type'];
        $field = $product_type;
      return $field;
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.