Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need some tools to handle page/post layout in some specific cases -- for example, some post should render post thumbnail on the right side (not left), some "related post" item should not be linked in some posts etc.

Now I guess that I could create 'layout_tax' taxonomy with values 'right_thumb', 'hide_pieces_link' etc-etc. And then I would use it to "trigger" needed behavior.

Please, what are drawbacks of this approach? For example, each of these taxonomies do not need to have archive page, appear as keyword in <head> or like that.

What would be better way instead?

Thanks!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Taxonomies are sort of overkill in this case. Taxonomies are not required to have an archive page (they can be used for internal things only). Your nav menus, for example, are terms in a taxonomy -- just a way of grouping content that belongs together. What you're talking about is a bit outside of that scope.

I'd suggest you create a little meta box. Give yourself whatever options you need, and filter post_class to change the styling. You can also, of course, include or not include things based on a postmeta value. Here's an example.

Then you just style with css, using selectors like .post.left_thumb or something similar.

Or you could grab the meta value in your single.php and change the layout based on that.

<?php
$layout = get_post_meta( $post->ID, '_wpse32973_layout', true );

if( 'left_thumb' == $layout )
{
    // do stuff
}
else
{
    // do other stuff
}

You could also use template parts and avoid some if statements in your templates.

<?php
$layout = get_post_meta( $post->ID, '_wpse32973_layout', true );

// make sure layout always has a value.
$layout = $layout ? $layout : 'some_default_thing';

get_template_part( 'content', $layout );

Anyway, lots of options to avoid a taxonomy, which I think is not a great choice for this situation.

share|improve this answer
    
thank you a lot, i'll dig.. –  brownian Nov 5 '11 at 14:57
    
Thank you for rich examples. –  brownian Nov 6 '11 at 18:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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