Title: [Plugin: Advanced Most Recent Posts Mod] Problems getting current category
Last modified: August 19, 2016

---

# [Plugin: Advanced Most Recent Posts Mod] Problems getting current category

 *  [migueleste](https://wordpress.org/support/users/migueleste/)
 * (@migueleste)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-advanced-most-recent-posts-mod-problems-getting-current-category/)
 * Hi,
 * I’m using the Advanced Most Recent Posts Md Plugin for quite a while.
    I use 
   it to have a list of recent posts on a sidebar, restricted to the current category.
 * Recently, I noticed that the feature of restricting to the current category when
   viewing a single post started producing erratic results.
 * After quite a while of troubleshooting I understood what0s going on..but I’m 
   lacking some simple way to solve it.
 * So, in the same sidebar I’m using to show advanced recent posts, I’m showing 
   some “featured posts” (posts belong to a special category).
    These “featured 
   posts” are shown above (that is before..) the advanced recent posts.
 * What’s happening is that when this plugin tries to get the current category, 
   it gets the category of the last post displayed on the “featured posts” section
   and not of the post being shown.
 * I’ve read through the manuals and located the relevnat code section…but whatever
   I do I always get ID’s, categories, etc..related to last posts shown on “featured
   posts” section.
 * How do I work around this? How can I ensure that the advanced recent posts gets
   the main post being displayed and not the last one from some peevious query?
 * Any help would be much appreciated.
 * cheers,
    miguel
 * [http://wordpress.org/extend/plugins/advanced-most-recent-posts-mod/](http://wordpress.org/extend/plugins/advanced-most-recent-posts-mod/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [migueleste](https://wordpress.org/support/users/migueleste/)
 * (@migueleste)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-advanced-most-recent-posts-mod-problems-getting-current-category/#post-2048579)
 * Well, maybe nobody is reading this… but in case you get the same problem, my 
   solution was, to change the call to get_the_category().
    After the change it 
   looks like this (changes in bold)
 * >  if (($actcat) && (is_single())) {
   >  **global $wp_query;** $cats = ”; foreach(
   > get_the_category(**$wp_query->post->ID**) as $catt) { $cats .= $catt->cat_ID.’‘;}
   > $cats = str_replace(” “, “,”, trim($cats)); }
 * cheers,
    Miguel

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Advanced Most Recent Posts Mod] Problems getting current category’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/advanced-most-recent-posts-mod.svg)
 * [Advanced Most Recent Posts Mod](https://wordpress.org/plugins/advanced-most-recent-posts-mod/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-most-recent-posts-mod/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-most-recent-posts-mod/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-most-recent-posts-mod/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-most-recent-posts-mod/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-most-recent-posts-mod/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [migueleste](https://wordpress.org/support/users/migueleste/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-advanced-most-recent-posts-mod-problems-getting-current-category/#post-2048579)
 * Status: not resolved