You might have to echo restlist as an array by doing this:
PHP Code:echo '<li><a href="' . get_the_permalink() . '">' . $customPostID['restlist'][0] . '</a></li>';
You might have to echo restlist as an array by doing this:
PHP Code:echo '<li><a href="' . get_the_permalink() . '">' . $customPostID['restlist'][0] . '</a></li>';
Kyle,
Tried your code and I at least got an error message this time!
Parse error: syntax error, unexpected T_IF -- says the error is on line 17.
Code:<?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(); ?>
Add a semicolon at the end on
$customPostID = get_post_custom($post->ID);
We reLoad™ Premium WordPress themes
Sorry ScottHack, I realized the error when I decided to test it on my own install, but then forgot to add it back in. Just add the semi-colon as reLoadedThemes suggests.
That brings me back to just a blank page with no code able to be viewed.
Getting closer.
This code now loads. Gives no errors. However, instead of it using the custom field meta data as the anchor text, it puts "Array"
Help!
Code:<?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&meta_key=restlist'); foreach ($postslist as $post) : $customPostID = get_post_custom($post->ID); if(isset($customPostID['restlist'])) : setup_postdata($post); echo '<li><a href="' . get_permalink() . '">' . $customPostID['restlist'] . '</a></li>'; endif; endforeach; ?> </ul> </div> <?php include(TEMPLATEPATH."/sidebar_right_page.php");?> </div> <!-- The main column ends --> <?php get_footer(); ?>
Woohoo! Thanks reLoad!