Support » Plugins and Hacks » Add widget to end of page

  • Hi,

    I want to add the widget (or another way) if possible for my latest 3 posts to the end of a page.

    I tried using a plugin but it caused trouble with my users not being able to edit sites.

    Is there any easy way to add the side widget for recent posts to the end of a page?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Karun

    (@karunshakya45)

    Put the following code in your functions.php file

    register_sidebar( array(
    ‘name’ => ‘Widget Name’,
    ‘id’ => ‘widget-id’,
    ‘description’ => __( ‘Widget Description’),
    ‘before_widget’ => ‘<article class=”grid_4 alpha”>’,
    ‘after_widget’ => “</article>”,
    ‘before_title’ => ‘<h2>’,
    ‘after_title’ => ‘</h2>’,
    ) );

    And put the following code where you want your widget to be displayed

    <?php if ( is_active_sidebar( ‘widget-id’ ) ) : ?>
    <?php dynamic_sidebar( ‘widget-id’ ); ?>
    <!– #first .widget-area –>
    <?php endif; ?>

    Thanks I have done that but how do I find the widget-id?

    I presume I only need to change that on the code for the page where I want the widget inserted and leave the top snippet as posted?

    Karun

    (@karunshakya45)

    For widget-id you can give any unique name you want like sidebar-2 , sidebar-right, etc

    I have added the code as you said and doesn’t is being displayed.
    Am I missing something?

    Code inserted below:

    register_sidebar( array(
    'name' => 'Homepage Newsfeed',
    'id' => 'homepage-newsfeed',
    'description' => __( 'This is the news for the homepage below the text'),
    'before_widget' => '<article class="grid_4 alpha">',
    'after_widget' => "</article>",
    'before_title' => '<h2>',
    'after_title' => '</h2>',
    ) );
    <!--?php if ( is_active_sidebar( 'homepage-newsfeed' ) ) : ?-->
    <!--?php dynamic_sidebar( 'homepage-newsfeed' ); ?-->
    <!-- #first .widget-area -->
    <!--?php endif; ?-->

    @karunshakya45 Am i doing something wrong has still been trying this and cannot get it to work?

    check if the php opening tags are
    <?php ... ?>
    and not
    <!-- .... -->

    Thanks for the reply Carlos

    <?php if ( is_active_sidebar( 'homepage-newsfeed' ) ) : ?>
    <?php dynamic_sidebar( 'homepage-newsfeed' ); ?>
    <!-- #first .widget-area -->
    <?php endif; ?>

    This is what I have on my page and nothing is displayed but when I view the source code for the page I see the following

    <p><?php if ( is_active_sidebar( 'homepage-newsfeed' ) ) : ?><br />
    <?php dynamic_sidebar( 'homepage-newsfeed' ); ?><br />
    <!-- #first .widget-area --><br />
    <?php endif; ?></p>

    Would it seem that the php isn’t being processed?

    Are you putting it when you edit the page content?
    You have to put it in the template code. Appearance>Editor

    I had it in the page content that what must have been confusing me but I have placed it in the index.php template and the page.php template and it’s still not appearing. I only want on my home page so was concentrating on index.php template.

    Thanks for the support

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Add widget to end of page’ is closed to new replies.