Problem making widget to display newest posts form category
-
Well, I am trying to create widget that displays last posts from selected category. Everzthing works fine exept it always displays title and link to last post on blog, not slected post. Here is some code:
[Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]
Problem is this: get_posts() does return needed posts properly, and in a foreach loop I prepare each post using setup_postdata(). However, the_permalink() and the_title() always return values from the last post on forum, not from post prepared using setup_postdata().
the_excerpt() does return proper exceprt form current post I want to display. So I get pretty messy result.
I’ve spent substantial time trying to figure out what I am doing wrong, but I cannot tell.
Any help?
- The topic ‘Problem making widget to display newest posts form category’ is closed to new replies.