Are widgets meant to be used outside of sidebars?

My case: I have this html block which I want to use every time I display a post with category of "Story". I was going to make a widget to reduce duplicate code. Is there a better way to apply this html block to every displaying of a "Story" post?

link|improve this question

69% accept rate
feedback

4 Answers

up vote 1 down vote accepted

If the category is Story, then make a template file, and name it as category-story.php (make sure the slug is 'story'). Put your code in this file. WordPress will automatically display the posts from Story category using this template. (More about category templates here). And yes, you can use widgets outside of the sidebar, read how.

link|improve this answer
feedback

I frequently use widgets outside sidebars. It's a fantastic way to make editing content in WordPress easier, however in your situation you may wish to use a file named 'category-story.php' or use the is_category() conditional tag to display content when a given category is viewed.

link|improve this answer
feedback

Widgets are just placeholders with enhanced functionality. I build a plugin once to add widgets to the head and footer sections of an HTML document.
I’d say it depends on your needs: If you need some configuration use a widget. Otherwise shortcodes or special templates may do the same job.

link|improve this answer
feedback

Yes, one common use is the Widgetized Footer. The typical ones enable one to put three or four columns in the footer which you populate via widgets.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.