adsense

How to Widgetize the WordPress Body





1. Open your theme's template files in a code editor or Notepad. You need to edit every template where you want a widgetized body, so if you want to widgetize the body of the blog index and single post pages, then edit both index.php and single.php. Edit page.php if you want to widgetize static pages. Open the functions.php file for your theme as well.
2. Add the following code to your functions.php file:if(function_exists('register_sidebar')) {register_sidebar(array('name' => 'Body Widget Area','before_widget' => '
,'after_widget' => '
','before_title' => '
','after_title' => '
');}The above code checks that you can register sidebars and then registers a sidebar called 'Body Widget Area.' That is the name you will see on the 'Widgets' page in the WordPress dashboard. Wherever you place code to include this widgetized 'sidebar,' WordPress will add div tags with a class of 'body_widget.' Each widget title will get wrapped in the H3 tag.

3. Add the following code to any template file where you want a widgetized area to appear in the body of the page:

This if statement checks to see if the 'sidebar' exists or not. If it does not, it executes some fallback code. Place manual calls to widgets between the two lines of code to set your fallback. This code also places the 'sidebar' wherever you place it on the page.
4. Open the style.css file of your theme and add this code:.body_widget {width: XXpx;height: XXpx;}Replace 'XX' with the values you want, in pixels. Add any other CSS code you want for the div containing the widgetized area. The CSS code goes between the curly braces.
5. Upload your edited files to the appropriate theme file under /wp-content/themes/ on your server. Visit the wp-admin directory of your website and log in to the dashboard. Navigate to 'Widgets' and click the down arrow on 'Body Widget Area' to expand the 'sidebar' box. You can now drag and drop widgets in to the body's widgetized area, and they will appear in the body of your WordPress posts and pages.

Comments

0 Responses to "How to Widgetize the WordPress Body"

Post a Comment

Popular Posts

About