Slider on all pages

How can i add the Activello slider to all pages and not only the homepage.

Thanks for your great work.

BartP

Hi BartP,

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

You can achieve this by using the attached child theme of Activello theme that contains some custom code.

Best Regards,
Movin

Movin,

Thanks for your beautiful answer, and i hope you have a very good week.

Thank you !!

BartP

You are most welcome here :slight_smile:

Hello,
A long time ago I got some help from you with adding the flexslider to all pages on the site. I notice that with the latest version of WordPress and Activello, this now causes a problem with all of the slider images appearing under each other.
I just wondered if you can suggest an update to the code?
I believe it was this chunk of code in the child theme’s functions file that used to work but doesn’t any more.
Thanks,
Kitka

/**

  • Featured image slider, displayed on front page for static page and blog
    */
    function activello_featured_slider() {
    if ( get_theme_mod( ‘activello_featured_hide’ ) == 1 ) {

     wp_enqueue_style( 'flexslider-css' );
     wp_enqueue_script( 'flexslider-js' );
    

    echo ‘’;
    echo ‘

      ’;

     $count = 4;
     $slidecat = get_theme_mod( 'activello_featured_cat' );
    
     $query = new WP_Query( array( 'cat' => $slidecat,'posts_per_page' => $count ) );
     if ($query->have_posts()) :
       while ($query->have_posts()) : $query->the_post();
    
       echo '<li>';
         if ( (function_exists( 'has_post_thumbnail' )) &amp;&amp; ( has_post_thumbnail() ) ) :
           echo get_the_post_thumbnail( get_the_ID(), 'activello-slider' );
         endif;
    
           echo '';
     							echo get_the_category_list();
               if ( get_the_title() != '' ) echo '<a href="' . get_permalink() . '">'. get_the_title().'</a>';
               echo '<a href="' . get_permalink() . '">' . __( 'Read More', 'activello' ) .'</a>';
           echo '&lt;/div&gt;';
    
           endwhile; wp_reset_query();
         endif;
    
       echo '</li>';
    

    echo ‘

’;
echo ’ </div>’;
}
}

/**

  • Enqueue scripts and styles.
    */
    function custom_activello_scripts() {
    // Add slider CSS only if slider is enabled
    if( get_theme_mod(‘activello_featured_hide’) == 1 ) {
    wp_enqueue_style( ‘flexslider-css’, get_template_directory_uri().’/inc/css/flexslider.css’ );
    }

// Add slider JS only if slider is enabled
if( get_theme_mod(‘activello_featured_hide’) == 1 ) {
wp_register_script( ‘flexslider-js’, get_template_directory_uri() . ‘/inc/js/flexslider.min.js’, array(‘jquery’), ‘20140222’, true );
}

}
add_action( ‘wp_enqueue_scripts’, ‘custom_activello_scripts’ );

You can resolve the issue by using attached modified child theme that contains following updated custom code.


/**
 * Featured image slider, displayed on front page for static page and blog
 */
	function activello_featured_slider() {
		if ( get_theme_mod( 'activello_featured_hide' ) == 1 ) {

			wp_enqueue_style( 'flexslider-css' );
			wp_enqueue_script( 'flexslider-js' );

			echo '';
			echo '<ul>';

			$slidecat = get_theme_mod( 'activello_featured_cat' );
			$slidelimit = get_theme_mod( 'activello_featured_limit', -1 );
			$slider_args = array(
				'cat' => $slidecat,
				'posts_per_page' => $slidelimit,
				'meta_query' => array(
					array(
						'key' => '_thumbnail_id',
						'compare' => 'EXISTS',
					),
				),
			);
			$query = new WP_Query( $slider_args );
			if ( $query->have_posts() ) :

				while ( $query->have_posts() ) : $query->the_post();
					if ( ( function_exists( 'has_post_thumbnail' ) ) && ( has_post_thumbnail() ) ) :
						echo '<li>';
						if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
							$feat_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
							$args = array(
								'resize' => '1920,550',
							);
							$photon_url = jetpack_photon_url( $feat_image_url[0], $args );
							echo '<img src="' . $photon_url . '">';
						} else {
							  echo get_the_post_thumbnail( get_the_ID(), 'activello-slider' );
						}
								echo '';
							  echo get_the_category_list();
						if ( get_the_title() != '' ) { echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>';
						}
								echo '<a href="' . get_permalink() . '">' . __( 'Read More', 'activello' ) . '</a>';
								echo '</div>';
								echo '</li>';
						endif;
					endwhile;
				wp_reset_query();
			endif;
			echo '</ul>';
			echo ' </div>';
		}// End if().
	}

/**
 * Enqueue scripts and styles.
 */
function custom_activello_scripts() {
      // Add slider CSS only if slider is enabled
	
  if ( get_theme_mod( 'activello_featured_hide' ) == 1 ) {
		wp_enqueue_style( 'flexslider-css', get_template_directory_uri().'/assets/css/flexslider.css' );
		wp_enqueue_script( 'flexslider-js', get_template_directory_uri() . '/assets/js/vendor/flexslider.min.js', array('jquery'), '20140222', true );
  }

}
add_action( 'wp_enqueue_scripts', 'custom_activello_scripts' );


Thank you Movin!
Kitka

You are always welcome here :slight_smile: