I've been hammering at this for a while, and can't make it work.
The WP site has been live for a while and works well. It has pages with a standard have_posts() loop to produce the current query's posts in the main column, and then there's a sidebar with various possible widgets, also doing some post loops.
On a regular category page, it is generating the correct posts in the main Loop displayed in the main content area.
Then in the sidebar, I use get_posts() to retrieve an unrelated set of posts to display. It loops through each post returned by get_posts, retrieves the ID of the post, then displays the Title and Permalink with get_the_title(ID) and get_permalink(ID).
In all cases the Title is correct, but the Permalink is NOT. It keeps using the Permalink of the first Post in the main Query's loop.
I've tried using wp_reset_query before doing the work in the sidebar. I've tried setup_postdata() on each post within the sidebar get_posts(). I've tried passing the Post object rather than the Post ID. Nothing works -- always gets the URL of the main query for the page.
Why would WP sometimes not respect the ID value you pass to it in get_permalink?
We've recently moved the site to a new server. Could there be an issue with the ability to write .htaccess etc.?