0

I am having


index.php -> This renders the latest post with sidebar
page.php-> This renders the page layout : Templates are fullwidth,sidebarleft& sidebarright
single.php-> This renders the single post layout : Templates are fullwidth,sidebarleft& sidebarright


whether a template can be provided for index.php? How can i provide option for full width, sidebarleft& sidebarright options for index.php?

  • In Settings->Reading, you can define any page as a template for both your front page and your posts page. – Michael Sep 24 '18 at 23:12
1

whether a template can be provided for index.php?

There's no built-in capability for selecting a custom template for archives.

How can i provide option for full width, sidebarleft& sidebarright options for index.php?

You can add a generic Customizer control with options for which template to use for archives, then inside index.php you would just check the saved value of that control with get_theme_mod() and change the template accordingly, or include another template file, for example:

switch ( get_theme_mod( 'layout' ) ) {
    case 'fullwidth':
        get_template_part( 'index', 'fullwidth' );
        break;
    case 'sidebarleft':
        get_template_part( 'index', 'sidebarleft' );
        break;
    case 'sidebarright':
        get_template_part( 'index', 'sidebarright' );
        break;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.