January 27, 2015
Using large sliding banners with linked content can be both a blessing and a curse. This adds a beautiful level of style and information to the site, but also takes up a lot of space, and provides a lot of repetitive information that can be difficult for new visitors to navigate.
To help visitors navigate with ease, you can target links that repeat throughout your website, and remove them from the transitions / hide those slides entirely on the equivalent urls.
Used within the loop:
$current_id = $post->ID; <?php $current_class = ( $current_id == $post->ID ) ? 'class="current_banner"' : ''; ?> <a <?php if ( $current_class ) echo $current_class; ?> href="<?php the_permalink(); ?>">Learn More ></a>
Complete example using a for loop:
foreach($sliders as $post) : setup_postdata($post); $current_id = $post->ID; ?> <div class="banners"> <?php the_post_thumbnail(); ?> <div class="banner_content"> <h1><?php the_title(); ?></h1> <?php the_content();?> <?php $current_class = ( $current_id == $post->ID ) ? 'class="current_banner"' : ''; ?> <a <?php if ( $current_class ) echo $current_class; ?> href="<?php the_permalink(); ?>">Learn More ></a> </div> </div> <?php endforeach; wp_reset_postdata(); ?>