How to Widgetize a Page, Post, Header or Any Other...

How to Widgetize a Page, Post, Header or Any Other Templat...
http://wpmu.org/how-to-widgetize-a-page-post-header-or-any...
News, Plugins, Themes and Reviews
by Sarah Gooding
How to Widgetize a Page, Post, Header or Any Other
Template in WordPress
January 8th 2010 in Community, How to, Plugins, Themes, development, tutorials, widget, wordpress single user, wpmu
10 Comments
Have you ever found a plugin for a widget that you’d like to use in a page or post, but the only widgetized sections of your theme
are sidebars and footers? Sometimes these plugins will come with shortcodes but sometimes those are not available. You can
always hardcode it into the template by using the template tags provided by the plugin author, but not every user is going to want
that widget on his page. If you want to preserve the option for your blog owners to use it or not use it, you will need to widgetize
that page. In this tutorial we’ll show you how you can make any page completely widgetized for your custom use. The process is
the same for any other template in WordPress as well.
You can add just one widgetized area or you can segment it into different areas. Let’s add a top section and a bottom section within
the content area of the page. Basically what we will need to do is register the areas that we want to be widgetized in our
functions.php file. Then you can make a new page template that contains the new widgets that will be shown when added in the
Appearance >> Widgets section of the dashboard.
Step 1: Register the widget areas in your functions.php file:
You should see this:
if ( function_exists('register_sidebar') ) { register_sidebar(array( 'before_widget' => '<li id="%1$s"
Beneath it, register your two new widget areas by adding this:
1 di 4
18/09/10 15.02
How to Widgetize a Page, Post, Header or Any Other Templat...
http://wpmu.org/how-to-widgetize-a-page-post-header-or-any...
register_sidebars( 1, array( 'name' => 'widgetized-page-top', 'before_widget' => '<div id="%1$s" class=
Step 2: Save a copy of your page.php and give it a different name. Then add this to the top so that WordPress
recognizes it as a new page template:
<?php /* Template Name: Widgetized Page */ ?>
Step 3: Add the widgets to your new page template inside the content div, just below (or above, if you’d
rather) the php that calls the page content:
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("widgetized-page-top") ) : ?> <?php
You can of course split those up and put static or dynamic content in between your multiple widgets. They just need to contain
these basic elements.
Step 4: Create a new page and make sure to select the new page template. Add widgets in the dashboard to
your newly widgetized areas! These will only show up on the custom template you’ve created.
The same can be done for the header area, footers, posts, archives, 404 pages, index, alternate sidebar templates, multiple custom
page templates, virtually anyplace within WordPress that you need to be widgetized.
One innovative use for WPMU might be to make a custom page template called “My Favorites” wherein you or any other blog
owner using the same theme will be able to use the WordPress dashboard to dump in as many widgets as they want to use on that
page. You can separate and style a few different widgetized sections or you can just make the entire content area a mash of widgets.
For example, they can drop in the RSS widget to show the latest posts from their favorite blogs, the Tweet Blender widget to show
their favorite tweeter or Twitter list, a Flickr widget to show their favorite vacation, etc. Certainly all of these can’t fit in one sidebar
widgetized area and some would look better shown on a page. You can enclose the page widgets in a < div > with an ID of
“favorites” and then style them differently than how they might appear in the sidebar. That way the widgets will be “wearing” the
appropriate style for a sidebar appearance or a page appearance, depending on how their parent div’s are styled. How cute is that? :)
Nobody can argue with the simplicity of drag and drop configurable widgets. Preserving this functionality for your users is just one
more way you can allow your blog owners to personalize their blog sites on your network.
ShareThis
Tweet This Post
Mi piace
A 2 persone piace questo elemento. Di' che piace anche a te, prima di
tutti i tuoi amici.
Tagged: custom page template, custom post template, widgetize, widgets, wordpress template
Related Articles
September 17thDaily Tip: Improve WordPress Security by Moving the wp-config.php File
September 17thDiaspora vs. BuddyPress: Open Source Social Networking Matchup
September 16thDaily Tip: WordPress 3.0 Template File Hierarchy Cheat Sheet
September 16th8 WordPress Plugins that Enable Posting and Editing From the Front-End
September 15thDaily Tip: 3 Ways to Remove WordPress Self Pings
Email Addre
10 Comments Already
Subscribe to this post rss feed or comments rss feeds
Joanna in January 8, 2010 at 4:23 pm
2 di 4
Permalink |
18/09/10 15.02
How to Widgetize a Page, Post, Header or Any Other Templat...
http://wpmu.org/how-to-widgetize-a-page-post-header-or-any...
Stef in January 9, 2010 at 3:45 pm
Permalink |
Works perfect! Just what I needed. Thanks!
Smashing Share in January 10, 2010 at 2:24 am
Permalink |
very helpful. thanks for sharing this
tmo in January 25, 2010 at 7:29 pm
Permalink |
great instructions…. worked in two minutes put in top of home page and below posts single!
Vamban in January 29, 2010 at 10:30 am
Permalink |
Really cute and useful instructions to widgetize wordpress blog in any specified location.
Nice work :D
Sharon in March 3, 2010 at 12:12 am
Permalink |
The newbie has a question…this is is what I have been searching for but I am a newbie to all of this and am a bit lost…the new page/template is
confusing me. Where exactly do I save the new page that I create??
Paul in March 29, 2010 at 6:41 am
Permalink |
Thanks for the tips.
If I don’t want to hack my theme core files, how would I achieve the same result using my custom functions.php file? thanks
Don in April 4, 2010 at 6:56 am
Permalink |
Thank you!Works perfect!
Todd Halfpenny in April 21, 2010 at 4:25 am
Permalink |
Hey Sarah,
This is an excellent tutorial, thanks… really helped getting me going on widgets.
I have however come up with a wordpress plugin which lets you define a new “sidebar” (in a similar way to the above) but then allows you to add
this to post/page content through the use of a shortcut rather than having to add code to template files. If you’re interested the “Widgets on Pages”
plugin can be downloaded from http://wordpress.org/extend/plugins/widgets-on-pages/
Jeanne in April 24, 2010 at 9:01 am
Permalink |
This is terrific! It provided a real breakthrough for a problem I was having. Thank you so much for sharing it.
Trackbacks/Pingbacks
3 di 4
18/09/10 15.02
CMS Tool of the Week: WordPress Widgets Wherever You Want Them - WordPress MU and BuddyPress plugins, themes, support, tips and how to's
How to Widgetize a Page, Post, Header or Any Other Templat...
http://wpmu.org/how-to-widgetize-a-page-post-header-or-any...
‘Like’ us to enter a draw to win an annual WPMU DEV membership worth
$419!
WPMU DEV su Facebook
Mi piace
WPMU DEV piace a 1,003 persone
Tony
Kasun
Alan
Judy
Reah
Jason
Don
Scott
Plug-in sociale di Facebook
WordPress MU Tags
bbpress blogs
buddypress buddypress groups buddypress plugin buddypress plugins buddypress theme buddypress themes
buddypress theming categories cms Community custom post types edublogs email How to jquery mu multisite mysql plugin Plugins prizes
wordpress WordPress 3.0
wordpress as a CMS wordpress mu wordpress multisite wordpress plugin wordpress theming wpmu wpmu dev
release SEO sign up sitewide social networking spam splogs theme Themes twitter upgrades widgets
wpmu plugins
Search the WPMU.ORG archives
Search
Search for:
Copyright ©2010 Incsub
4 di 4
All rights reserved
18/09/10 15.02