Help with template to pull custom field data
-
I’m looking for some help putting together some code that checks all of the posts in the database for a custom field. If the custom field exists, then it gets the data assigned to that custom field.
Here is the code I’ve been working with, but I can’t get it to work. Help!
<?php /* Template Name: Rest List */ ?> <?php get_header(); ?> <div id="content"> <div id="contentleft"> <ul> <?php $postslist = get_posts('numberposts=-1&order=ASC&orderby=title'); foreach ($postslist as $post) : $customPostID = get_post_custom($post->ID); if(isset($customPostID['restlist'])) : setup_postdata($post); echo '<li><a href="' . get_the_permalink() . '">' . $customPostID['restlist'] . '</a></li>'; endif; endforeach; ?> </ul> </div> <?php include(TEMPLATEPATH."/sidebar_right_page.php");?> </div> <!-- The main column ends --> <?php get_footer(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Help with template to pull custom field data’ is closed to new replies.