Looping structures in posts confusing Post ID
-
I’ve been sneaking Loop-style structures into pages on my site with not much trouble except that the ‘Edit this entry’ link becomes a link to the edit post page for the last item displayed in the loop.
Here’s an example page:
http://www.thelitreview.com/the-lit-reviews-top-10-listWhen I try to put something like this in a post it looks like everything below the loop, including meta data, comments and some sidebar items that depend on the post ID, thinks the post ID is the ID of the last link displayed in the loop.
Here’s the function:
while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; // using tables resolved some display issues we were having echo("<tr valign=\"top\"> <td class=\"bookthumb\"><a href=\""); echo(get_permalink()); echo("\" rel=\"bookmark\" title=\"Permanent Link to Book Reviews & Literary Criticism for "); echo(the_title_attribute()); echo("\">"); echo(the_excerpt()); // the excerpt is the image (a real bad solution, I know) // for some reason, there's a link being thrown before // the image as well as around it. Could this be the // source of the problem echo("</a></td> <td class=\"bookinfo\"><div "); echo(post_class()); echo("id=\"post-"); echo(get_the_ID()); echo("\"><strong><a href=\""); echo(get_permalink()); echo("\" rel=\"bookmark\" title=\"Permanent Link to Book Reviews & Literary Criticism for "); echo(the_title_attribute()); echo("\">"); echo(the_title()); echo("</a></strong></div> <div class=\"avgScore\"><strong>Average Score:</strong> "); $thisBook = get_the_ID(); listAvgScore($thisBook); echo("</div> <p class=\"postmetadata\">Genres: "); echo(the_category(', ')); echo(" | "); echo(edit_post_link('Edit', '', ' | ')); echo(" "); echo(comments_popup_link('No Comments »', '1 Comment »', '% Comments »')); echo("</p> </div> <div class=\"clear\"> </div> </td> </tr>"); endwhile;Any idea what I’m doing wrong and how I can go about fixing it? Thanks.
The topic ‘Looping structures in posts confusing Post ID’ is closed to new replies.