Slider showing way too many featured posts...?

Hi,

I updated my theme yesterday and have noticed a number of problems. First and foremost, my slider has gone from showing 4 posts to showing all of my posts since the beginning of time. I liked it showing my last 4 posts from “all” categories. How can I limit the number of featured posts displayed in my slider?

My site is http://practicalwanderlust.com

Hi @liasaun1,

I hope you are well today and thank you for your question.

In the latest version of theme we have removed the slider posts restriction so it displays all the slider posts having slider category.

You can control which posts to display in the slider by adding or removing slider category from the posts.

Best Regards,
Movin

Is there any way for me to add back in the restriction? Having to manually add and remove posts from a category to keep my category at 5 or less posts is a lot of manual work. I’d much rather have a way to restrict the number of posts that are shown automatically.

Is there also a way to hide a category? I created a “featured” category but the posts have nothing in common with each other … I’d rather it not show up in my category lists.

You can try achieving this by using the solutions posted in the last reply of following topics.

https://colorlibsupport.com/t/slider-11/#post-74425
https://colorlibsupport.com/t/exclude-slider-category-on-home-page-and-post-page/

I have installed the child theme, but I’m not sure what piece of code I need to look for to make this change, can you please advise?

You have asked me two questions in your previous reply so please tell me do you want to restrict slider posts or want to hide featured category so that i can help you?

Also which child theme have you installed?

As far as the child theme, the style.css and functions.php file are just from colorlib-child-theme with no version number. Then, I recently updated header.php and replaced it with the code from version 83.

I guess I can continue to manage the slider posts manually using a category I’ve created (Which is what I’m currently doing). However, I’d like to hide that category from showing up elsewhere on the site.

hey, i had this same issue which bothered me.

here’s my fix… not sure if it’s frowned upon. basically it’s as easy as stopping the loop from displaying images after whatever amount you prefer.

in extras.php:

if ( ! function_exists( 'activello_featured_slider' ) ) :
/**
 * Featured image slider, displayed on front page for static page and blog
 */
function activello_featured_slider() {
  if ( ( is_home() || is_front_page() ) && get_theme_mod( 'activello_featured_hide' ) == 1 ) {
		
		wp_enqueue_style( 'flexslider-css' );
		wp_enqueue_script( 'flexslider-js' );
		
    echo '<div class="flexslider">';
      echo '<ul class="slides">';

        $slidecat = get_theme_mod( 'activello_featured_cat' );
        //DECLARE THE COUNTER HERE.
        $kyle_count = 0;
        $query = new WP_Query( array( 'cat' => $slidecat,'posts_per_page' => -1 ) );
        if ($query->have_posts()) :
          while ($query->have_posts()) : $query->the_post();
            //THE NUMBER AT THE END OF THIS CONDITIONAL STATEMENT IS HOW MANY SLIDES WILL DISPLAY.
            if ( (function_exists( 'has_post_thumbnail' )) && ( has_post_thumbnail() ) && ($kyle_count < 6)) :

                echo '<li>';
                      echo get_the_post_thumbnail( get_the_ID(), 'activello-slider' );

                    echo '<div class="flex-caption">';
                      echo get_the_category_list();
                        if ( get_the_title() != '' ) echo '<a href="' . get_permalink() . '"><h2 class="entry-title">'. get_the_title().'</h2></a>';
                        echo '<div class="read-more"><a href="' . get_permalink() . '">' . __( 'Read More', 'activello' ) .'</a></div>';
                    echo '</div>';

                echo '</li>';
            endif;
            //THIS INCREASES THE COUNTER.
            $kyle_count++;
        endwhile; 
        wp_reset_query();
        endif;

      echo '</ul>';
    echo ' </div>';
  }
}
endif;

Hope this helps. My comments are in all caps. :slight_smile:

@liasaun1

I guess I can continue to manage the slider posts manually using a category I’ve created (Which is what I’m currently doing). However, I’d like to hide that category from showing up elsewhere on the site.

Could you please tell me which category on your site http://practicalwanderlust.com/ you want to hide so that i can help you?

I’ve named the category “featured”.

Ok then you can try hiding it by adding the following CSS code in the Custom CSS option of your theme on the below path.

Admin Area -> Appearance -> Customize -> Activello Options -> Other -> Custom CSS

.post-categories a[href="http://practicalwanderlust.com/category/featured"],
.post-inner-content li.cat-item.cat-item-81,
.tagcloud a.tag-link-81 {
    display: none;
}