Support

Account

Home Forums Backend Issues (wp-admin) Fields vanishing in wp-admin Reply To: Fields vanishing in wp-admin

  • Looks like all I need to do now is add a custom location rule for “template_id” and I’m done. So now I just need to find out how to access that.

    The examples provided at http://www.advancedcustomfields.com/resources/custom-location-rules/ are great. I just need to figure out how to reference “template_id” and load values for existing templates. I’m a bit stumped there for the moment.

    I’m guessing something like this?

    
    add_filter('acf/location/rule_types', 'acf_location_rules_types');
    function acf_location_rules_types( $choices )
    {
        $choices['Basic']['template_id'] = 'Template ID';
    
        return $choices;
    }
    
    add_filter('acf/location/rule_values/template_id', 'acf_location_rules_values_template_id');
    function acf_location_rules_values_template_id( $choices )
    {
        $template_ids = /* somehow get template IDs here */
    
        if( $template_ids )
        {
            foreach( $template_ids as $template_id )
            {
                /* template ID by template name here */
            }
        }
    
        return $choices;
    }
    

    Thanks so much for all the help. It looks like I’m nearly there!