Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #86275
    corkiesmom
    Member

    I would like to disable the links to the pages on the slider images. In other words, I would like to use the slider, but I would not like for the images to be links. How can I disable the links?

    #86295
    Mahesh
    Participant

    Hi @corkiesmom,

    You’ll need to create a child theme for that. You can find more details on creating child theme HERE. Then in your child theme’s functions.php add the following code and it will remove the links from the slider image.

    function catchresponsive_page_slider( $options ) {
    	$quantity		= $options['featured_slide_number'];
    	$more_link_text	=	$options['excerpt_more_text'];
    
        global $post;
    
        $catchresponsive_page_slider = '';
        $number_of_page 		= 0; 		// for number of pages
    	$page_list				= array();	// list of valid page ids
    
    	//Get number of valid pages
    	for( $i = 1; $i <= $quantity; $i++ ){
    		if( isset ( $options['featured_slider_page_' . $i] ) && $options['featured_slider_page_' . $i] > 0 ){
    			$number_of_page++;
    
    			$page_list	=	array_merge( $page_list, array( $options['featured_slider_page_' . $i] ) );
    		}
    
    	}
    
    	if ( !empty( $page_list ) && $number_of_page > 0 ) {
    		$get_featured_posts = new WP_Query( array(
    			'posts_per_page'	=> $quantity,
    			'post_type'			=> 'page',
    			'post__in'			=> $page_list,
    			'orderby' 			=> 'post__in'
    		));
    		$i=0;
    
    		while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
    			$title_attribute = the_title_attribute( array( 'before' => __( 'Permalink to: ', 'catch-responsive' ), 'echo' => false ) );
    			$excerpt = get_the_excerpt();
    			if ( $i == 1 ) { $classes = 'page pageid-'.$post->ID.' hentry slides displayblock'; } else { $classes = 'page pageid-'.$post->ID.' hentry slides displaynone'; }
    			$catchresponsive_page_slider .= '
    			<article class="'.$classes.'">
    				<figure class="slider-image">';
    				if ( has_post_thumbnail() ) {
    					$catchresponsive_page_slider .= get_the_post_thumbnail( $post->ID, 'catchresponsive-slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class'	=> 'attached-page-image' ) );
    				}
    				else {
    					//Default value if there is no first image
    					$catchresponsive_image = '<img class="pngfix wp-post-image" src="'.get_template_directory_uri().'/images/gallery/no-featured-image-1200x514.jpg" >';
    
    					//Get the first image in page, returns false if there is no image
    					$catchresponsive_first_image = catchresponsive_get_first_image( $post->ID, 'catchresponsive-slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'attached-page-image' ) );
    
    					//Set value of image as first image if there is an image present in the page
    					if ( '' != $catchresponsive_first_image ) {
    						$catchresponsive_image =	$catchresponsive_first_image;
    					}
    
    					$catchresponsive_page_slider .= $catchresponsive_image;
    				}
    
    				$catchresponsive_page_slider .= '
    				</figure><!-- .slider-image -->
    				<div class="entry-container">
    					<header class="entry-header">
    						<h1 class="entry-title">
    							<a title="Permalink to '.the_title('','',false).'" href="' . get_permalink() . '">'.the_title( '<span>','</span>', false ).'</a>
    						</h1>
    						<div class="assistive-text">'.catchresponsive_page_post_meta().'</div>
    					</header>';
    					if( $excerpt !='') {
    						$catchresponsive_page_slider .= '<div class="entry-content"><p>'. $excerpt.'</p></div>';
    					}
    					$catchresponsive_page_slider .= '
    				</div><!-- .entry-container -->
    			</article><!-- .slides -->';
    		endwhile;
    
    		wp_reset_query();
      	}
    	return $catchresponsive_page_slider;
    }

    Regards,
    Mahesh

    #86367
    corkiesmom
    Member

    Thank you so much for taking the time to help me with this! I will try it as soon as I possibly can. It makes me happy to know it is possible to disable the links!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Disable links on slider images’ is closed to new replies.