cabrerahector / wordpress-popular-posts

WordPress Popular Posts - A highly customizable WordPress widget that displays your most popular posts.
https://wordpress.org/plugins/wordpress-popular-posts/
GNU General Public License v2.0
279 stars 83 forks source link

Do no display certain category in the category list #136

Closed djonatanb closed 7 years ago

djonatanb commented 7 years ago

I'm working with the wpp_get_mostpopular template tag. I'm aware of the option of setting 'cat' => -id but the problem is that it won't fetch any posts that belong to that category, I would like to fetch but not to show this specific category tag.

My situation is that I created a 'Featured' category to position some posts in the home page and I'm hiding that category from everywhere.

do you have an idea ?

$featured = -1000;
$args = array(
    'range' => 'all',
    'wpp_start' => '<ul class="list-unstyled trending-posts">',
    'wpp_end' => '</ul>',
    'header' => 'Trending Articles',
    'thumbnail_width' => 82,
    'thumbnail_height' => 71,
    'stats_views' => 0,
    'stats_category' => 1,
    'header_start' => '<h3 class="title">',
    'header_end' => '</h3>',
    'post_html' => $html,
    'cat' => $featured
  );
cabrerahector commented 7 years ago

Hi there!

The short answer: There's no way to do what you want without coding.

The long answer: Problem is WPP displays the first category that WordPress returns. In your case, it happens to be the Featured category. Unfortunately, there's no way to tell WPP "hey, skip this category and show the next one, please." so right now your only alternative is to use either of WPP filter hooks to build your own HTML output.

With version 4.0, WPP will display all categories and assign CSS classes to each of them so you can, for example, hide them using CSS.