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!
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.