• I’ve recently added the Automatic Sidebar widgets plugin to my wordpress blog and I’ve been using it successfully. However, I noticed that it now adds the sidebar to all pages!

    is there a way to tweak it such that the sidebar would be visible only on the HOME page and not the rest of the pages?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Depending on your template structure, you can copy the sidebar.php and call it mainsidebar.php and upload to your current theme folder on your server.

    If you use MainIndex as the “homepage”, you can call this new sidebar.php into that template, which will display only what you want it to display on the homepage, and no other page… again, depending on what files you do have.

    Original Code:
    <?php get_sidebar(); ?>

    Replace with:
    <?php include ('mainsidebar.php'); ?>

    You’ll also need to read this, to help you work out what template is used and when.

    https://codex.www.ads-software.com/Template_Hierarchy

    Why not add this to each portion of the sidebar: <?php if (is_home()) { ?>

    ?

    Thread Starter hitman1

    (@hitman1)

    brandon206

    Can I still do that when I’ve installed the sidebar widgets plugin? it seems after I done so the sidebar.php is no longer functional

    Katgirl,
    Where does “sidebar widgets” get called? the original sidebar.php is no longer being used after I install the sidebar widgets plugin

    Where does “sidebar widgets” get called? the original sidebar.php is no longer being used after I install the sidebar widgets plugin

    Sorry hitman1 – I don’t understand your message. Can you elaborate, just a tad?

    it seems after I done so the sidebar.php is no longer functional

    sidebar.php is still in use in your theme. It’s just that a bit of *special code* inserted into the sidebar.php template allows the Widgets plugin, when activated, to override any sections you normally have in it.

    Where does “sidebar widgets” get called? the original sidebar.php is no longer being used after I install the sidebar widgets plugin

    Again, it’s that bit of special code in sidebar.php that allows Widgets to take over. This page (the “How do I fix up my theme?” section) describes what exactly in a sidebar.php allows that to happen:

    https://automattic.com/code/widgets/themes/

    Thread Starter hitman1

    (@hitman1)

    I found this line in my sidebar.php

    <?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar()) : else : ?>

    I changed it to:

    <?php if (is_home()): if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar()) {;} else {;} else: ?>

    and it seems to have done the trick pretty well. Now the sidebar only appears on the homepage. Is this proper html code? I’m asking because I’ve done it with trial&error only.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Sidebar widgets in home page only’ is closed to new replies.