Hacking topic pages in Wordpress
March 11, 2009 11:41 AM Subscribe
Wordpress gurus: I'd like to create robust topic pages for my categories, and I'm trying to figure out the best way to go about this. Help!
For a project I'm building, I decided to go with Wordpress because it was the most flexible (yet robust) CMS that met most of my needs. But I'm running into trouble trying to build sophisticated topic pages for each of my blog categories, and any brainstorming help you can offer would be helpful.
For each category, I want to create a page that might include several elements. (You can view an example of a prospective topic page here.) The page might include:
Some techniques I'm imagining:
For a project I'm building, I decided to go with Wordpress because it was the most flexible (yet robust) CMS that met most of my needs. But I'm running into trouble trying to build sophisticated topic pages for each of my blog categories, and any brainstorming help you can offer would be helpful.
For each category, I want to create a page that might include several elements. (You can view an example of a prospective topic page here.) The page might include:
- An overview introducing the basics of the subject to visitors that don't know much about it. This might include a video or a map.
- A background section summarizing recent events related to the subject, possibly including a graphic timeline.
- A list of related subtopics or issues, with a few paragraphs describing the issue.
- Titles and excerpts of the most recent posts in the category, as in a typical category archive.
Some techniques I'm imagining:
- Create specialized templates for each category. This is so lame and un-maintainable I've removed it from serious consideration.
- Extend the category archive page to pull in pages that have the category ID listed in a custom field. For example, I might create an "Overview" page for each category that includes the overview information, a "Background" page that includes the background info, and a "Related Issues" page. For each of these pages, I'd specify a custom field that matched the desired category ID, then possibly another custom field with the type of information included in the page (e.g. "overview," "background," "related"). This would have the benefit of keeping everything in Wordpress, so you could ostensibly find and maintain the content without having to dip into code. On the other hand, it seems somewhat cumbersome and technically daunting, and the technical structure would be difficult to maintain. If I were to go to these lengths, I may as well try my hand at plugin-building.
- Create pages that have the various sections appropriately styled, that pull in posts from a specified category using a shortcode. This would be simpler to maintain, but it would take quite a bit of work to replace all the references to category archives with these pages. Plus, pages are hidden from search engines. Also, pages aren't all that flexible from a design perspective. (I don't think, for example, we can give classes to divs inside the Wordpress editor.)
- Use a custom write panel plugin like Flutter or Pods. Flutter's promising, but it's so new I worry it's not stable yet, and the documentation isn't great. And Pods offers a lot of functionality, but much of that functionality is so far outside the Wordpress core functionality (and so thinly integrated with it), that seems to almost negate the benefits of using Wordpress in the first place.
categories are tough ones... what about putting stuff in the category description and pulling that for the introduction/background bit AND making subtopics "children" of the parent category and then you can list just "children of" there?
posted by yonation at 11:57 AM on March 11, 2009
posted by yonation at 11:57 AM on March 11, 2009
I think I'm missing something here - why would using category-specific templates be lame and un-maintainable?
posted by Jairus at 12:01 PM on March 11, 2009
posted by Jairus at 12:01 PM on March 11, 2009
Response by poster: I thought about trying to hijack the category description, but I've decided against it for a few reasons: 1) I want to use that field for its intended purpose elsewhere on the site, so when I'm linking to topics, I can give a brief summary of them. 2) That field alone isn't robust enough to accommodate all the content I'd fling at it.
As for making the subtopics children, I considered this too, but that would create a lot of unpredictable category bloat; also, for most of those related issues, I don't actually want to create topic pages for them.
posted by grrarrgh00 at 12:05 PM on March 11, 2009
As for making the subtopics children, I considered this too, but that would create a lot of unpredictable category bloat; also, for most of those related issues, I don't actually want to create topic pages for them.
posted by grrarrgh00 at 12:05 PM on March 11, 2009
I'm not talking about the category description, I'm talking about Category Templates. So, category-1.php is your template for News, category-2.php is your template for Articles, category-3.php is your template for Photos, etc.
posted by Jairus at 12:08 PM on March 11, 2009
posted by Jairus at 12:08 PM on March 11, 2009
grra.. (sorry too hard to repeat your name) i see your point, but even though I love WP and feel like it can be taken to the limit and compete /w drupal/joomla and even beat them (esp on the user, content-entry side) you may be hitting up against a wall... you're wanting many fields and subfields with specific data and WP just doesn't have that capability yet.. yuo can do stuff in PHP like call an of the filename of the category dot php, but you're running against a similar problem as the category-specific templates...
posted by yonation at 12:08 PM on March 11, 2009
posted by yonation at 12:08 PM on March 11, 2009
Jairus: *i* was talking about the description... i'm assuming the OP doesnt want many templates because he has many categories AND users will add categories??
posted by yonation at 12:09 PM on March 11, 2009
posted by yonation at 12:09 PM on March 11, 2009
As you may have noticed, each category of posts in Wordpress can easily get its own template. Just by giving the .php file the ID of the category it has to show. So you use the category.php template for the ordinary categories of texts. And if your category 'needs special lay-out' has the ID of 3, you name that file category-3.php.
So I just would not ignore this road completely if I were you.
[Providing you'll want to do it they easy way. It is also possible to change styles or even CSS-es by using an IF->THEN loop in the head of the .php-page].
Ideally what you would want is a normal category-page with an text field on top that can be changed like any other blogpost. And that's what I've done, since you can use the Wordpress loop not only to sift all posts from the category wanted, but also to show a post with a certain ID. That is, if you use two loops in the template.
So, I've hardcoded different templates for several different categories, while keeping them as flexible as possible. And to make supervision as simple as possible, have also introduced one special category only used for introductory texts, not shown in any menu outside the backoffice.
posted by ijsbrand at 12:10 PM on March 11, 2009
So I just would not ignore this road completely if I were you.
[Providing you'll want to do it they easy way. It is also possible to change styles or even CSS-es by using an IF->THEN loop in the head of the .php-page].
Ideally what you would want is a normal category-page with an text field on top that can be changed like any other blogpost. And that's what I've done, since you can use the Wordpress loop not only to sift all posts from the category wanted, but also to show a post with a certain ID. That is, if you use two loops in the template.
So, I've hardcoded different templates for several different categories, while keeping them as flexible as possible. And to make supervision as simple as possible, have also introduced one special category only used for introductory texts, not shown in any menu outside the backoffice.
posted by ijsbrand at 12:10 PM on March 11, 2009
Response by poster: Jairus: Tons of specific content would be embedded in the templates themselves, which means lots of significant content outside of the content management system. These topic pages would be updated fairly often (every few weeks, at least), and embedding content in the php files would mean I'd be the only one who could change them. Also, there will be quite a number of topic pages (a few dozen at the minimum). Figuring out which one to update at any given time would be an arduous process of identifying the category ID, picking the relevant file out of the haystack, and making sure I don't break any PHP along the way.
posted by grrarrgh00 at 12:11 PM on March 11, 2009
posted by grrarrgh00 at 12:11 PM on March 11, 2009
yonation, sorry, I totally missed your post.
grrarrgh00: I would probably use pages, in that case, and pull them into the category template file via ID or custom fields.
posted by Jairus at 12:16 PM on March 11, 2009
grrarrgh00: I would probably use pages, in that case, and pull them into the category template file via ID or custom fields.
posted by Jairus at 12:16 PM on March 11, 2009
Response by poster: A couple of plugins I've found that start to get at the functionality I need:
posted by grrarrgh00 at 12:20 PM on March 11, 2009
- Category intro for archive
- Category page (only tested up to 2.5; didn't work for me in 2.7)
posted by grrarrgh00 at 12:20 PM on March 11, 2009
I would do something similar to your second choice but instead of pages for each element I would make pages for each category with each secondary element as a custom field and, if there's an element that all the categories use, I would make it the main text. That way you have all the information of a category in one place and there would be no need to specify what elements are included in any given category.
Then, in the category.php template I would make
posted by Memo at 12:21 PM on March 11, 2009
Then, in the category.php template I would make
if
queries to check if an element exists, rendering it if it does.posted by Memo at 12:21 PM on March 11, 2009
Tons of specific content would be embedded in the templates themselves, which means lots of significant content outside of the content management system. These topic pages would be updated fairly often (every few weeks, at least), and embedding content in the php files would mean I'd be the only one who could change them
They're PHP pages, have them pull the customized information from elsewhere.
If you want everything doable from within Wordpress then why not put that changing content into a particularly named page or post that is set with its visibility to private? It won't show up in the main archives but you can retrieve its content programmatically.
Or do what we did at We Love DC; if you go to the site you see a list of pages iterated at the top, About, Archives, Authors, Suggest a Story. About happens to have a child page, Commenting Policies, but the code in our template that builds the pages uses the exclude parameter in wp_list_pages to leave that one out.
So we're free to link directly to that page in our footer, but you won't get to it any other way. You could do the same kind of thing and make that page your customizable content. Give permission to the people who you want to be able to edit it and call it from your template with the get_page function.
posted by phearlez at 2:29 PM on March 11, 2009 [1 favorite]
They're PHP pages, have them pull the customized information from elsewhere.
If you want everything doable from within Wordpress then why not put that changing content into a particularly named page or post that is set with its visibility to private? It won't show up in the main archives but you can retrieve its content programmatically.
Or do what we did at We Love DC; if you go to the site you see a list of pages iterated at the top, About, Archives, Authors, Suggest a Story. About happens to have a child page, Commenting Policies, but the code in our template that builds the pages uses the exclude parameter in wp_list_pages to leave that one out.
So we're free to link directly to that page in our footer, but you won't get to it any other way. You could do the same kind of thing and make that page your customizable content. Give permission to the people who you want to be able to edit it and call it from your template with the get_page function.
posted by phearlez at 2:29 PM on March 11, 2009 [1 favorite]
Response by poster: Phearlez, I like the idea of using posts and marking them to private. That would allow me to use the category infrastructure already built into posts to extend the category archive pages, without having disaggregated blobs of content free-floating around my site.
I'm also taking a look at a Custom fields for categories plugin. It's rough, but might be a good foundation.
posted by grrarrgh00 at 3:53 PM on March 11, 2009
I'm also taking a look at a Custom fields for categories plugin. It's rough, but might be a good foundation.
posted by grrarrgh00 at 3:53 PM on March 11, 2009
"pages are hidden from search engines"--Maybe my site is different, but my most powerful suck-them-in-from-Google item is a page, not a post.
I'm mostly clueless about PHP and didn't understand some of the suggestions, which is why I would try to hack something like this together:
1. Create a regular page for the topic, entering the custom text there.
2. Set up an RSS feed for each category.
3. Use one of the many display-your-blog-feed gizmos to embed a feed of the correct category in the topic page.
4. Link directly to the page in the site menu, and redirect category links to that page? Or something.
This keeps the text in an easy-to-edit place and gives you a potentially slick (depending on the widget) way to show the posts that relate to that topic. However, this completely ignores and almost turns off the WordPress category functionality.
posted by PatoPata at 4:29 PM on March 11, 2009
I'm mostly clueless about PHP and didn't understand some of the suggestions, which is why I would try to hack something like this together:
1. Create a regular page for the topic, entering the custom text there.
2. Set up an RSS feed for each category.
3. Use one of the many display-your-blog-feed gizmos to embed a feed of the correct category in the topic page.
4. Link directly to the page in the site menu, and redirect category links to that page? Or something.
This keeps the text in an easy-to-edit place and gives you a potentially slick (depending on the widget) way to show the posts that relate to that topic. However, this completely ignores and almost turns off the WordPress category functionality.
posted by PatoPata at 4:29 PM on March 11, 2009
This thread is closed to new comments.
posted by grrarrgh00 at 11:45 AM on March 11, 2009