essentially I need to be able to add a class to a post when it show in the list (say index.php) so when in the back end you can say oneCol, twoCol, threeCol and it will then output this within the loop post class.
This is to enable a tighter control of the layout. using this line of code for the output?
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>
Thanks in advance!
You can setup a Custom fileds for that – See usage, then use
get_post_meta()
function to fetch it and show where you wantExample –
This will output the class name set in the
meta_key
.OR ( Update #1 ) –
Pass the variable into
Post Class
There’s a filter for that.
Example:
Edit
Assuming you’ll be using custom post meta data to determine the layout string to add as a post class, you’d do something like follows:
To incorporate that into your filter callback: