wp_reset_postdata not working
wp_reset_postdata not working
wp_reset_postdata not working
You are missing the point of restoring the context to original state. Yes, your loops do work without reset. But anything that tries to access queried post after them will hit leftovers of your custom queries in global variables, rather than post from main query. In a literal sense the reset after your first query … Read more
wp_reset_postdata() wp_reset_postdata() will restores the global $post variable to the current post in the main query. This is useful when using WP_Query to customize loops or create multiple loops on the same page. This Answer will solve all your queries about wp_reset_postdata() & WP_Query & get_posts
You can get the category id and the fetch the permalink by using get_category_link($Id);
wp_reset_postdata() restores the post from main query, which you do not seem to be using here at all. So before final the_title() call you jump out all the way to that post. Your code seems to be tad problematic to me because both your outer and inner loops continuously rewrite $post global. If you move … Read more
The difference between the two is that wp_reset_query() – ensure that the main query has been reset to the original main query wp_reset_postdata() – ensures that the global $post has been restored to the current post in the main query. Indeed, looking at the source you’ll see that the wp_reset_query() calls wp_reset_postdata(). The only difference … Read more