dyadica.net

Fun and Games in the Dyadic Sea

Posts Tagged ‘intro’

permalink image comments image
Thursday, 8 November '07: Adding An Intro to Wordpress Pages

Yup I have been modding wordpress again.

Here is a little snipit that some of you might find useful. You can use the get_post_meta() call to add additional fields to your wordpress posts.

Whist developing the latest theme I decided that I needed an equivalent to the_excerpt() for pages, or an into as so to speak.

All you need to do is add the following or an equivalent to your page loop, the div class and style are bespoke:

<?php
$key=”post-intro”;
$intro = get_post_meta($post->ID, $key, true);
if ($intro){
echo “<div class=’post-body’ style=’clear:both;’>”;
echo $intro;
echo “</div>”;
}
?>

Then if your page has a custom field of “post-intro” the value will be outputted.

Read..

Tags: , , , , ,

poll tags

css | xhtml | dyadica.net © admin 2010 | powered: wordpress | fuel: ps-wii-elite | top | sign-up