For the last couple of weeks I have been working on my wife’s blog, trying to give it more functionality and ability to present more in the sidebars and such. It has been a learning process. In an earlier post I said that I would be bringing out the details of some of the knowledge I gained in this process. Here is a little bit of that knowledge.
One of the problems I was trying to solve was how to make different widgets and content show up on different pages. I didn’t want a cookie cutter approach where all my sidebar content looked exactly the same on every page. My solution? Two very useful WordPress plugins. They were “Custom Post Widget” and “Widget Logic”.
The “Custom Post Widget” is a great tool that allows the webmaster or author to create individually saved bits of content that can each be moved over to the sidebar area in admin as needed. The best part about the widget is that it allows the content to be authored using the Visual editor in WordPress. This allows formatting of the fonts, uploading images and everything else you can do with the visual editor. This is a much better solution than using the standard “Text” widget which does not allow easy formatting of the content.
That is great, but what about the ability to make these content blocks appear on different pages and posts and in different locations on those pages and posts? This is where “Widget Logic” comes in. “Widget Logic” puts an extra field in the bottom of each widget that you put in the sidebar area of your blog that allows you to tell the widget with a little piece of code which pages it can show up on. The bits of code are called, “Conditional Tags”. Conditional tags allow me to point the widget to only the pages or posts that meet the conditions of the tag. For instance, say I want a block of text to only show up on my Home page and my About Me page but nowhere else. I would drag the content block over to the sidebar area in my admin that contains that text content. I would enter the code, is_home() in the widget logic field in the bottom of that widget, and then click save. I would add another content block with the same text to the sidebar, and enter the code, is_page('about-me'), where “about-me” is the title slug for my About Me page, and click save.
Viola! I’m done. Took me about 30 seconds, and the text in that widget is only showing up on my Home page and my About Me page.
For further information about Conditional Tags go to the link, http://codex.wordpress.org/Conditional_Tags. To get the two plugins mentioned, just go to your plugins page, go to “Add New”, type in the names of the plugins into the search field, and install each when it comes up.
Hope this was a help. Happy blogging Lafayette and all!
