• I’m looking for the wordpress file that contains the contents of HomePage. I have actually set a post as the frontpage of my site. I can’t add the code form the post editor because the widget I’ve created will appear at the bottom of the page. Not the Bottom of the screen.

    Also I only want this widget to appear on the homepage. Can anyone help me out with the right place to place this code at?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi

    If you want to add code in bottom of the screen (whole page), not in the bottom of the page content, you must modify the footer.php file. Add a sidebar in the footer but you should use is_front_page too:

    <?php if(is_front_page()) { 
      dynamic_sidebar( 'sidebar-home-footer' );
    } ?>

    And in your function.php

    function my_widget_init() {
      register_sidebar( array(
        'name'          => __( 'Sidebar', 'yourtheme' ),
        'id'            => 'sidebar-home-footer',
        'description'   => __( 'Add widgets here to appear in your home footer sidebar.', 'yourtheme' ),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h2 class="widget-title">',
        'after_title'   => '</h2>',
      ) );
    }
    add_action( 'widgets_init', 'my_widget_init' );

    Hope it helps

    Thread Starter hamxa318

    (@hamxa318)

    Worked like a charm! Thanks for helping.

    go to setting->reading->see the A static page (select below) set the home page

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How To Add Code Only in Homepage’ is closed to new replies.