WordPress.org

Ready to get started?Download WordPress

Forums

Widget Help (pretty urgent) (11 posts)

  1. CurtisT
    Member
    Posted 4 years ago #

    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,

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    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.

  3. CurtisT
    Member
    Posted 4 years ago #

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

    My site is http://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.

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    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.

  5. CurtisT
    Member
    Posted 4 years ago #

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

    thanks,

  6. esmi
    Forum Moderator
    Posted 4 years ago #

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

  7. CurtisT
    Member
    Posted 4 years ago #

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

  8. CurtisT
    Member
    Posted 4 years ago #

    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?

  9. CurtisT
    Member
    Posted 4 years ago #

    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.

  10. CurtisT
    Member
    Posted 4 years ago #

    Can anyone point me in the right direction

    thanks a lot

  11. esmi
    Forum Moderator
    Posted 4 years ago #

    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().

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.