Creating a unique design for each post is something I’ve become increasingly interested in, and obviously I’ve been searching for the best way to do this with my platform of choice, WordPress. In this post I’ll go through a number of ways to achieve unique blog design and the pros and cons of each.
The ways of doing it
For me, there are 5 ways of doing this:
- Custom field with inline styling.
- Custom field with link to stylesheet.
p class
on each paragraph – do this with a plugin.div class
on groups of paragraphs – create own visual editor buttons to do this.- Shortcodes which output paragraph or div class.
- Write out code in text editor then copy across.
- Post templates
Clearly, these need to be combined to create one overall awesome way of doing things and I think one must look at all the different ways of doing things and choose a personal favourite.
Using custom fields & inline styling
<?php if (is_single()) { ?>
<?php $css = get_post_meta($post->ID, 'css', true);
if ($css) {
?>
<style type="text/css">
<?php echo get_post_meta($post->ID, "css", true); ?>
</style>
<?php } else { ?>
<?php } ?>
<?php } ?>
This is the way I like to do things. A custom field with the value of some inline styling. If it doesn’t exist, nothing happens, if it does then the inline styling takes priority over what is in the stylesheet and you get a fancy new background image or whatever.
It’d be done with something like the code on the left; you’d need to create a custom field ‘css’ and then in it pop your styling. As we’re in an if statement, if you don’t create a custom field, then nothing gets displayed. Of course, there are some pros and some cons:
Pros
Easy to do.
Quick way to add in simple changes.
Doesn’t complicate things at all.
Cons
Can’t reuse code in different posts (easily).
Not practical for large amounts of styling.
Good for?
So this method is best for the occasional unique designer. Good for those who are only going to do this occasionally.
a
Pros
Cons.