slider image order

Hey guys, first off, thank you. This theme is pretty cool and your support forum is very active. I have been able to solve my issues relatively easily and have even been able to help a few other of your users out.

I do have a few questions that I have not been able to answer.

  1. Short of choosing the category used by the slider, how is order the slider displays images determined? Does it show it in descending order or post date?

  2. Can that be modified? I am hoping to get it in random order, so it displays the featured image of the chosen category in random order.

I am already using a child theme that adds multiple categories on the front page and posts so if I need to add something to the functions.php I can add it to the child theme’s functions.php. Thank you in advance.

Hi Frank,

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

The slider displays the slider images of posts in the descending order of post date.

You can display them randomly by adding the following custom code in the functions.php file of your child theme.

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">';

        $count = 4;
        $slidecat = get_theme_mod( 'activello_featured_cat' );

        $query = new WP_Query( array( 'cat' => $slidecat,'posts_per_page' => $count, 'orderby' => 'rand' ) );
        if ($query->have_posts()) :
          while ($query->have_posts()) : $query->the_post();
            if ( (function_exists( 'has_post_thumbnail' )) && ( has_post_thumbnail() ) ) :

                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>';


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

Best Regards,

Thank you

You are most welcome here :slight_smile: