Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #83835
    Raielene
    Member

    I need about 10 different slider images to link to only one particular page. What do I need to edit to make that happen?

    (At the moment I have them all set to a category I created called “slider”, but of course, they all link to their own post. I want them to link to a static page, and all the same page.)

    #83854
    Mahesh
    Participant

    Hi @Raielene,

    In Catch Kathmandu Free Version, you can only put the post images in the slider, and the link by default points to its relative post. In Catch Kathmandu Pro Version, you have other features in slider image such as post, page, category or custom image (with custom link). I recommend you to upgrade to Pro version.

    Regards,
    Mahesh

    #83898
    Raielene
    Member

    Right, but the way they seem to work is by having one image as the featured image… which is why I’m using about 10 posts to show all the images I want in my slider. But what I want is all 10 slider images to point to just *one* page. The same page. If I could make them point to one post (the same post) that would work too.

    #83917
    Mahesh
    Participant

    Hi @Raielene,

    I understand your issue. But the links in the slider is dynamically generated from the code and always points to the very post that the featured is of. I mean slider image of post1 links to post1 and so on. But you mean to have all the slider link to the same page say Post-X. For that you have to override the theme’s function with child theme and place a static link (hard coded) in the anchor tag. And whenever you want to change the link you have to go through the code.
    That is why I recommend you to upgrade to Pro.
    But if you want to change it within the Free version, create a child theme. You can find more details on creating a child theme HERE. Then in child theme’s functions.php add the following codes.

    /**
     * Change slider's links to one custom link
     *
     */
    function catchkathmandu_post_sliders() {
    	//delete_transient( 'catchkathmandu_post_sliders' );
    
    	global $post;
    	global $catchkathmandu_options_settings;
       	$options = $catchkathmandu_options_settings;
    
    	if( ( !$catchkathmandu_post_sliders = get_transient( 'catchkathmandu_post_sliders' ) ) && !empty( $options[ 'featured_slider' ] ) ) {
    		echo '<!-- refreshing cache -->';
    
    		$catchkathmandu_post_sliders = '
    		<div id="main-slider" class="container">
            	<section class="featured-slider">';
    				$get_featured_posts = new WP_Query( array(
    					'posts_per_page' => $options[ 'slider_qty' ],
    					'post__in'		 => $options[ 'featured_slider' ],
    					'orderby' 		 => 'post__in',
    					'ignore_sticky_posts' => 1 // ignore sticky posts
    				));
    				$i=0; while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
    					$title_attribute = apply_filters( 'the_title', get_the_title( $post->ID ) );
    					$excerpt = get_the_excerpt();
    					if ( $i == 1 ) { $classes = 'post postid-'.$post->ID.' hentry slides displayblock'; } else { $classes = 'post postid-'.$post->ID.' hentry slides displaynone'; }
    					$catchkathmandu_post_sliders .= '
    					<article class="'.$classes.'">
    						<figure class="slider-image">
    							<a title="Permalink to '.the_title('','',false).'" href=" http://your-site/link-to-some-post ">
    								'. get_the_post_thumbnail( $post->ID, 'slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class'	=> 'pngfix' ) ).'
    							</a>
    						</figure>
    						<div class="entry-container">
    							<header class="entry-header">
    								<h1 class="entry-title">
    									<a title="Permalink to '.the_title('','',false).'" href=" http://your-site/link-to-some-post ">'.the_title( '<span>','</span>', false ).'</a>
    								</h1>
    							</header>';
    							if( $excerpt !='') {
    								$catchkathmandu_post_sliders .= '<div class="entry-content">'. $excerpt.'</div>';
    							}
    							$catchkathmandu_post_sliders .= '
    						</div>
    					</article><!-- .slides -->';
    				endwhile; wp_reset_query();
    				$catchkathmandu_post_sliders .= '
    			</section>
            	<div id="slider-nav">
            		<a class="slide-previous"><</a>
            		<a class="slide-next">></a>
            	</div>
            	<div id="controllers"></div>
      		</div><!-- #main-slider -->';
    
    	set_transient( 'catchkathmandu_post_sliders', $catchkathmandu_post_sliders, 86940 );
    	}
    	echo $catchkathmandu_post_sliders;
    } // catchkathmandu_post_sliders

    Note: Please replace http://your-site/link-to-some-post in the above code with your desired link. There are two occurrences.

    Let me know if this helps.

    Regards,
    Mahesh

    #84013
    Raielene
    Member

    It works! It works! Mahesh, you’re brilliant! Thanks so much! 🙂

    #84052
    Mahesh
    Participant

    Hi @Raielene,

    Thank you for your appreciation.

    Regards,
    Mahesh

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘All sliders link to only one page’ is closed to new replies.