Forums

Add Sidebar Widget to Page Content (2 posts)

  1. jwahkan
    Member
    Posted 1 month ago #

    Hi All,

    Is there any way go about added sidebar widgets to a particular static page?

    I basically want my landing page to feature the widgets because its not a "blog."

    I guess if the above is not possible might it be possible to move the formatting of the sidebar to the center of a static page but have it in the regular sidebar position for the other pages.

    Possible? Sort of?

    Thanks.

  2. apljdi
    Member
    Posted 1 month ago #

    Just put a 'sidebar' in the location you want it and use CSS to format it.

    Put this...

    if ( function_exists('register_sidebar') ) {
      /// This sidebar appears on all pages above the following sidebars
      register_sidebar(
        array(
          'name' => 'Middleofthepage',
          'before_widget' => '<li id="%1$s" class="widget %2$s">',
          'after_widget' => '</li>',
          'before_title' => '',
          'after_title' => '',
        )
      );
    }

    ... in your theme's functions.php. The name is arbitrary but has to match the value used in 'dynamic_sidebar' below, and the 'before_widget', 'after_widget', etc can be changed to work with the page layout.

    Put this...

    if (function_exists('dynamic_sidebar')) {
                  dynamic_sidebar('Middleofthepage');
              }

    ... in your page template where you want the sidebar to appear. The code needs to be inside PHP <?php and ?> tags. Depending upon where you put it there may already be tags there or you may have to add them.

    Add some widgets via wp-admin->Appearance->Widgets.

    Now use CSS to fiddle with the appearance.

Reply

You must log in to post.

About this Topic