• Is there anyway to have a text widget appear on the home/main page without it appearing on every single page on the site?

    Thanks,

Viewing 10 replies - 1 through 10 (of 10 total)
  • Yes. You can widgetize the index.php file in your theme (for post pages) or page.php (for static pages) in conjunction with the is_home() and is_front_page() conditionals. So something like:

    <?php if ( is_home() || is_front_page() ) :
    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    <?php endif; endif; ?>

    should work.

    Thread Starter curtist

    (@curtist)

    Please excuse me being a newb, but do I just copy and past that code into my index.php?

    My site is https://www.crashthecrease.com

    I have a a text widget on the right hand side the poker one.

    I only want that to appear on the home/main page.

    Sorry for my lack of understanding.

    The index.php file in your theme is the right file. I’d suggest adding it just before, or after, your Google AdSense block if that’s suitable for you.

    Thread Starter curtist

    (@curtist)

    ok, so I paste that code in my editor under index.php then what do I do?

    thanks,

    Go and add widgets to your new area via Admin/Appearance/Widgets.

    Thread Starter curtist

    (@curtist)

    Whenever I paste that code in all it does to my site is add a giant block with all my recent posts.

    Thread Starter curtist

    (@curtist)

    I pasted that code into my index.php again and on my site it added my recent posts and pet everything out of whack.

    Do i paste it somewhere else then?

    Thread Starter curtist

    (@curtist)

    So I tried pasting it in page.php and none of my recent posts came up out of nowhere on the site so thats good but I still did not have a new option under widgets.

    Thread Starter curtist

    (@curtist)

    Can anyone point me in the right direction

    thanks a lot

    Try editing your theme’s function file and replace:

    <?php
    if ( function_exists('register_sidebar') )
        register_sidebar();
    ?>

    with

    <?php
    if ( function_exists('register_sidebars') )
        register_sidebars(2, array('name'=>'%d'));
    
    ?>

    Then try using:

    <?php if ( is_home() || is_front_page() ) :
    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(2) ) : ?>
    <?php endif; endif; ?>

    You may also have to amend your sidebar template to use dynamic_sidebar(1) instead of dynamic_sidebar().

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Widget Help (pretty urgent)’ is closed to new replies.