Small problem with display list of custom fields with links back to each Post
-
I have 2 custom fields in each Post in category 1 named “Guest Name” and “Guest Description”. I want to output a list of the custom fields with a link back to each of their respective Posts.
My code below works 90% but still has some errors. The code accurately shows the list of Guest Name and Guest Descriptions, but I need to fix 2 problems:
1) The links to their posts are not displaying. I tried get_the_permalink and the_permalink but neither seems to work. Any ideas what I should do?
2) I want to sort the list ASC by the “Guest Name” field. I can’t figure out how to do that code correctly. Any ideas?
<?php //get all posts in category 1, then for each post, get custom fields, //and display that info as a link $args=array( 'showposts' => 500, 'category__in' => array(1), 'caller_get_posts'=>1 ); $posts=get_posts($args); if ($posts) { foreach($posts as $post) { setup_postdata($post); $guestdescription = get_post_meta($post->ID, 'Guest Description', true); $guestname = get_post_meta($post->ID, 'Guest Name', true); if ($guestname){ echo '<a href='<?php the_permalink() ?>'>'.$guestname.'</a>: '.$guestdescription.'<br /><br />'; } } } ?>
Thank you~
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Small problem with display list of custom fields with links back to each Post’ is closed to new replies.