need help to use get_theme_mod for including a php file
Hello, I’m working on extending the WP Theme Customizer using ‘get_theme_mod’.
Previously, I was using a lot of if statements to parse structure of elements with get_theme_mod options, typically in my header.php file to have different layouts and classes for the header.
What I’m trying to do now is actually simplify it a little bit by using a php include for different header.php files for easier structuring of different layouts. I have a sub folder called “masthead-layouts” and files like “masthead-full.php” or “masthead-small.php”. I figured this would be a cleaner way to have different header structures rather than just using CSS & classes to organize elements and their positions.
Here’s ideally what I would like to happen, but i’m not the best at parsing php.
<?php include("header-layouts/<?php echo get_theme_mod( 'page_font_script'); ?>"); ?>
I know this isn’t formatted properly, but you should get the idea of what I’m trying to accomplish.
In my theme options, I have a get_theme_mod with radio options for “header-full.php” and “header-small.php”. This option is placed in the header.php file, then should grab the structure of the masthead layout that is desired.
Maybe including masthead.php files aren’t really the best way, but just trying to keep it easier to make variations in the future by making new masthead.php layouts.
- The topic ‘need help to use get_theme_mod for including a php file’ is closed to new replies.