Something a little different: I'm looking for some tips on how best to set up this configuration (plugins etc), rather than specific code to do things:
1) I have the default post type set up and running for my main blog posts - these are tagged (according to country) and categorised (by industry) - no problems there.
2) I need to set up a second post type (I assume) to handle 'Features' - this will include:
-- Galleries
-- Interviews
-- In depth
Galleries are fine - I'm using the 'Attachments' plugin to drop them in, and styling with galleria.js. Interviews and In Depth can both take a fairly standard blog post format.
My question: what's the easiest way to get these three 'categories' displaying and archived - I'm going to display 'features' on the homepage sidebar, so it'll need to say 'Gallery: Latest photos from our place' , 'Interview: With someone or other', and display the most recent 3 entries in the features post type.
If I can pin a new group of categories, with just the 3 (Galleries, Interviews, In Depth) categories in it, that could work, I guess. Ideally there'd be a way to set these 3 options up as post types (and to show this on the frontend).
Tips/advice/workflows?
Denzel Chia answers:
Hi,
There is no need for any type of custom post or custom taxonomy.
Just set them up as normal categories.
In your home page, where you want to show any of this category,
just use the WordPress WP_Query to display posts in that category only.
http://codex.wordpress.org/Function_Reference/WP_Query
you can also limit the number of posts this way. No need to worry about pagination problems too.
If you know how to code widgets using WP_Widget, just add WP_Query to your widget output, and with flexible settings, I am sure your widget will be able to output any category, and limit number of posts.
The default, post, page, category and archives is enough to achieve what you want. And sure to work without any problems and backward compatibility if you decided to change themes.
Custom post type or taxonomies will "disappear" when you change themes, you will need to modify your new theme again.
Thanks.
Denzel
Jon comments:
This could be an option, and it would solve the URL issues (as they'd fall under /features) but it's important that the features don't show up in the main blog listing (those posts are a separate type).
If I was to exclude the features posts from the loop as it runs on the regular pages, can I create a duplicate to have an archive of the features as well?
Jon comments:
Theme issues are not an issue - I'm building this from scratch with the Toolbox theme - if I need to add bits to functions.php, I can do.
Denzel Chia comments:
Hi,
<blockquote>
but it's important that the features don't show up in the main blog listing (those posts are a separate type).
</blockquote>
Same issue here. In your main blog list, you will use WP_query to exclude the category or categories that you do not want to show in your "regular" posts.
<blockquote>
If I was to exclude the features posts from the loop as it runs on the regular pages, can I create a duplicate to have an archive of the features as well?
</blockquote>
If you want to have a category page for the features only, you can make use of the wordpress template hierachy. Example category-{slug}.php - If the category's slug were features, WordPress would look for category-features.php. So you just create a file name category-features.php and put a normal wordpress loop in it. I will show only all the posts under category features.
And the same advantage, you will not have pagination problems.
More examples here. http://codex.wordpress.org/Template_Hierarchy
Thanks.
Denzel
Jon comments:
Thanks Denzel - that's got me to where I needed to be. I guess I was overcomplicating things by trying to set up extra custom post types. Template hierarchy info was useful - thanks.
Christianto answers:
When I want to get content from database (post/page) and display it in specific place/specific way, I use to create [[LINK href="http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action"]]new Query[[/LINK]] and custom loop for it. With this, I can controlled what content should appear in the loop by [[LINK href="http://codex.wordpress.org/Function_Reference/WP_Query#Parameters"]]passing the argument[[/LINK]].
Maybe you can create it too by passing the post type parameter and category parameter.