[Plugin: Widget Logic] Filter function that filters widget content by category
-
Hi!
I would appreciate help with a filter function that I want to use with widget logic. I’ sure this is rather easy for someone who knows just a little PHP.I have added category pages to the navigation bar on my site. Now I would like some of the widgets on these category pages only to display posts that are categorized in the same category as the category page. For instance I want the widget “Recent posts” on the category page “A” only to show recent posts of category “A” and omit posts of all other categories. Widget Logic seams to be a very nice solution for this. But the code I tried to put to gether doesn’t work. Can someone help me with the code?
function my_filter_function($content='', $widget_id='') { global $content; if (is_category('3')) query_posts($content . 'cat=3'); elseif (is_category('4')) query_posts($content . 'cat=4'); return $content; $widget_id='recent-posts-4'; } add_filter('widget_content', 'my_filter_function', 99, 2);
/Andreas
- The topic ‘[Plugin: Widget Logic] Filter function that filters widget content by category’ is closed to new replies.