Use a custom blurb when listing wordpress pages
January 18, 2009 · Print This Article
How to get a list of pages along with a custom key from each page, used to create a description?
The first thing to do is to paste the following code where you want your pages to be listed. It can be your sidebar, or a page template, for exemple.
<?php
$pages = get_pages();
foreach($pages as $page) {
$custom_blurb = get_post_meta($page->ID, 'custom_blurb', true);
echo "<h3><a href=\"".get_page_link($page->ID)."\">$page->post_title</a></h3>";
echo $custom_blurb;
}
?>
Once you saved your file, write some pages and add the custom_blurb custom field. As a value, give a description of the page.
Your pages will now be listed along with a custom description.





















Comments
Got something to say?
You must be logged in to post a comment.