Add custom field to specific page / template admin conditionally – based on customizer value

Question

I’m just learning to use customizer and want to be able to display the meta boxes for specific custom fields in the admin section for specific pages or page templates, based on a value that has been input into customizer e.g. if a specific checkbox is checked.

I’m able to achieve this in the front end of the site easily with something like:

<?php 
    if (get_theme_mod('my-customizer-setting')) {
?>

// show field

<?php
    }
?>

but it seems an awful lot more complicated to get the metabox to show the admin section for a specific page based on this condition. I’ve scoured around the web and haven’t really been able to find anything that addresses this. Can anyone point me in the right direction?

Thanks in advance.

0
Stef 4 weeks 2021-05-15T02:03:37-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse