The function below is called from my index.php just below the main content block. Its purpose is to write out a link list of the latest posts. However, I need to reset the post object once this function has completed (or the sidebar query that follows thinks that the current post is the last post that gets executed by this function.)
How should I reset the post back to the current post of the page?
I've tried adding wp_reset_query() at the end of the function, but its not producing the results I want (produces multiple posts in the content area). Any help much appreciated.
function myFunction(){
$catHidden=get_cat_ID('hidden');
$myquery = new WP_Query();
$myquery->query(array('cat' => "-$catHidden",'post__not_in' => get_option('sticky_posts')));
$myrecentpostscount = $myquery->found_posts;
if ($myrecentpostscount > 0){ ?>
<div>
<h4>Menu Title</h4>
<ul>
<?php
global $post;
$myrecentposts = get_posts(array('post__not_in' => get_option('sticky_posts'), 'cat' => "-$catHidden",'numberposts' => get_option('latest_count')));
foreach($myrecentposts as $idxrecent=>$post) { ?>
<li class="page_item">
<a href="<?php the_permalink(); ?>"><?php if(has_post_thumbnail() && get_option('show_thumbs')) the_post_thumbnail('thumbnail', array('class' => 'alignleft', 'style' => 'margin:0 10px 0 0;')); ?><?php the_title(); ?></a>
<?php
if(has_post_thumbnail() && get_option('show_thumbs')) echo '<div style="clear:both"> </div>';?>
</li>
<?php }
echo "</ul></div>";}}