I have set the default layout, so that on theme activation the default layouts shows on front-end without having to save anything in the database. But the problem is the default layouts doesn't show on theme activation. It shows blank page.
//File - default.php
<?php function prefix_option_defaults() {
//default values
$defaults = array(
'frontpage_layouts' => 'layout_3',
);
$options = get_option('prefix',$defaults);
//Parse defaults again - see comments
$options = wp_parse_args( $options, $defaults );
return $options; }
Calling the defaults at the top of header.php file
//File - header.php
global $prefix;
$prefix= prefix_option_defaults();
Here's the code I'm calling the layouts from -
//File - landing-page.php
if ( get_option( 'frontpage_layouts' ) === 'layout_1' ) {
get_template_part( 'frontpage/content', 'cta' ); }
elseif ( get_option( 'frontpage_layouts') === 'layout_2' ) {
get_template_part( 'frontpage/content', 'cta2' ); }
elseif ( get_option( 'frontpage_layouts' ) === 'layout_3' ) {
get_template_part( 'frontpage/content', 'cta3' ); }
else ( get_option( 'frontpage_layouts' ) === NULL ); {
get_template_part( 'frontpage/content', 'cta3' ); }
My customizer options are saved as -
I'd appreciate if anybody can help meget_option('frontpage_layouts')