the_permalink() is out of place in query_posts() widget
-
I am making a little widget to show post in the “events” category by the “event_date” custom field, using this Date Field plugin.
The posts are selected properly, but when I use “echo the_permalink()” in line to make my link, it jumps to the front of the line before everything else.
This is the code from my widget function:
echo '<ul>'; query_posts( 'category_name=events&meta_key=date_value&orderby=meta_value&meta_compare=>=&meta_value=' . time() . '&order=ASC' ); while (have_posts()) : the_post(); $post_id = get_the_ID(); $link = '<li><a href="'; $link .= the_permalink(); $link .= '">'; echo $link; echo the_title().' - '; echo date("F jS, Y", get_post_meta($post_id, 'date_value', true)).'</a></li>'; endwhile; echo '</ul>';
and it generates the following HTML:
<ul>https://cdri.org/2010/05/native-bee-workshop/<li><a href="">Native Bee Workshop - May 31st, 2010</a></li></ul>
I tried using the $link variable to force the_permalink() into the right place after the usual loop syntax didn’t work.
Any suggestions would be greatly appreciated!
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘the_permalink() is out of place in query_posts() widget’ is closed to new replies.