Exclude Category in Recent Posts Widget
-
I am creating a Widget for my sidebar that lists recent posts, but want to exclude one category. I am using the “Executable PHP widget” plugin.
I have been trying to use the function
category__not_in
Yes I have both the underlines after category. It is working but is INcluding ONLY that category… opposite of what the function should be doing. ???Based on this thread, https://www.ads-software.com/support/topic/272893
I tried setting the values as an array (I am still a PHP beginner), same result. The correct number of posts are displayed, just the category is not excluded.<div class="listWidget"><ul> <?php $noCat= array ( 'post_type' => post, 'category__not_in' => news, 'showpost' => 5 ); $posts=get_posts('$noCat'); if ($posts) { foreach($posts as $post) { setup_postdata($post); ?> <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li> <?php } } ?></ul></div>
Am I doing something wrong in my code? Maybe the code doesn’t work correctly in the widget? Other? Thanks for any help.
- The topic ‘Exclude Category in Recent Posts Widget’ is closed to new replies.