- This topic has 12 replies, 3 voices, and was last updated 8 years, 3 months ago by Mahesh.
-
AuthorPosts
-
July 21, 2016 at 7:02 am #95852TravParticipant
I’m using Catch Kathmandu Pro, and trying to remove the links which are associated with the Slider. It’s a homepage slider, type ‘Category Slider’.
Is the answer similar to this one, for a different theme?
https://catchthemes.com/support-forum/topic/remove-permalink-from-featured-images/Are there any options to alter the slider, and remove the text, only have the image?
Thanks heaps
July 21, 2016 at 12:30 pm #95862MaheshParticipant@nextgenf: For that you’ll need to create a child theme. You can find more details on creating child theme HERE. Then in your child theme’s functions.php, add the following code:
function catchkathmandu_category_sliders() { //delete_transient( 'catchkathmandu_category_sliders' ); global $post; global $catchkathmandu_options_settings; $options = $catchkathmandu_options_settings; if( ( !$catchkathmandu_category_sliders = get_transient( 'catchkathmandu_category_sliders' ) ) && !empty( $options[ 'slider_category' ] ) ) { echo '<!-- refreshing cache -->'; $catchkathmandu_category_sliders = ' <div id="main-slider" class="container"> <section class="featured-slider">'; $get_featured_posts = new WP_Query( array( 'posts_per_page' => $options[ 'slider_qty' ], 'category__in' => $options[ 'slider_category' ], '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 pageid-'.$post->ID.' hentry slides displayblock'; } else { $classes = 'post pageid-'.$post->ID.' hentry slides displaynone'; } $catchkathmandu_category_sliders .= ' <article class="'.$classes.'"> <figure class="slider-image">'. get_the_post_thumbnail( $post->ID, 'slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ). '</figure> <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">'.catchkathmandu_page_post_meta().'</div> </header>'; if( $excerpt !='') { $catchkathmandu_category_sliders .= '<div class="entry-content">'. $excerpt.'</div>'; } $catchkathmandu_category_sliders .= ' </div> </article><!-- .slides -->'; endwhile; wp_reset_query(); $catchkathmandu_category_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_category_sliders', $catchkathmandu_category_sliders, 86940 ); } echo $catchkathmandu_category_sliders; } // catchkathmandu_category_sliders
Removing text from slider, you can use Custom CSS. Go to Dashboard=> Appearance=> Customzie=> Theme Options=> Custom CSS and add the following CSS:
#main-slider .entry-container { display: none; }
Regards,
MaheshJuly 27, 2016 at 10:48 pm #96137RolandParticipantHi Mahesh,
I would also like to remove the links associated with my slider images, however I’m using the post-slider option rather than the category-slider. Can I simply substitute all instances of “category” with “post” in your code or is that too simplistic?
Thanks
Roland
July 28, 2016 at 9:40 am #96155MaheshParticipant@rolandallen: Thought you were using Category Slider. 🙂
For Post Slider, add the following code intead: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"> '. get_the_post_thumbnail( $post->ID, 'slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ).' </figure> <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">'.catchkathmandu_page_post_meta().'</div> </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
Regards,
MaheshJuly 28, 2016 at 1:29 pm #96177RolandParticipantHi Mahesh,
Thanks for responding so quickly.
Unfortunately this doesn’t seem to work, probably because I have wrongly inserted your code. Here’s my functions.php with your code inserted:
<?php
/**
* Child Theme functions and definitions
*
*/
add_action( ‘wp_enqueue_scripts’, ‘catchkathmandu_child_enqueue_styles’ );
function catchkathmandu_child_enqueue_styles() {
wp_enqueue_style( ‘catchkathmandu-parent-style’, get_template_directory_uri() . ‘/style.css’ );
}
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”>
‘. get_the_post_thumbnail( $post->ID, ‘slider’, array( ‘title’ => esc_attr( $title_attribute ), ‘alt’ => esc_attr( $title_attribute ), ‘class’ => ‘pngfix’ ) ).’
</figure>
<div class=”entry-container”>
<header class=”entry-header”>
<h1 class=”entry-title”>
‘.the_title( ‘<span>’,'</span>’, false ).’
</h1>
<div class=”assistive-text”>’.catchkathmandu_page_post_meta().'</div>
</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”>
<
>
</div>
<div id=”controllers”></div>
</div><!– #main-slider –>’;set_transient( ‘catchkathmandu_post_sliders’, $catchkathmandu_post_sliders, 86940 );
}
echo $catchkathmandu_post_sliders;
} // catchkathmandu_post_sliders/**
* Loading Parent theme stylesheet
*
*/Kind regards,
Roland
July 28, 2016 at 8:10 pm #96192RolandParticipantHi Mahesh,
I’m afraid I can’t get this to work, perhaps I’ve inserted it incorrectly into the child theme functions.php? Here’s the file:
<?php /** * Child Theme functions and definitions * */ add_action( 'wp_enqueue_scripts', 'catchkathmandu_child_enqueue_styles' ); function catchkathmandu_child_enqueue_styles() { wp_enqueue_style( 'catchkathmandu-parent-style', get_template_directory_uri() . '/style.css' ); } 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"> '. get_the_post_thumbnail( $post->ID, 'slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ).' </figure> <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">'.catchkathmandu_page_post_meta().'</div> </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 /** * Loading Parent theme stylesheet * */
Kind regards,
Roland
July 29, 2016 at 10:05 am #96229MaheshParticipant@rolandallen:
Hi Roland,What seems to be the problem. I tried your code in our server and it is working fine.
Let me know further. Please post in your site URL.Regards,
MaheshJuly 29, 2016 at 1:24 pm #96238RolandParticipantHi Mahesh,
Apologies, I’ve checked again and the image redirection has now been suppressed – many thanks!
However when I click on the the text label I still get redirected to the image on its own page. I’d like to keep the label but stop it hyperlinking to the image page?
The web site is currently “under construction” and is only accessible via administrator login.
Kind regards,
Roland
July 29, 2016 at 4:51 pm #96248MaheshParticipant@rolandallen: For that, you’ll need to do a little change in the above code. In the above code replace the following line:
<h1 class="entry-title"> <a title="Permalink to '.the_title('','',false).'" href="' . get_permalink() . '">'.the_title( '<span>','</span>', false ).'</a> </h1>
With the code below:
<h1 class="entry-title">' . the_title() . '</h1>
Regards,
MaheshJuly 29, 2016 at 9:55 pm #96258RolandParticipantHi Mahesh,
This seems to work, however the down side is that I can no longer see the coloured overlay box with the post title in it. I now see a thin horizontal portion of the original box, without the text?
Sorry for the protracted nature of this issue – your help is much appreciated.
Kind regards,
Roland
July 31, 2016 at 9:45 am #96312MaheshParticipant@rolandallen: Sorry, my mistake, the code should be as follows:
<h1 class="entry-title">' . get_the_title() . '</h1>
Let me know if any problem.Regards,
MaheshAugust 1, 2016 at 12:08 pm #96376RolandParticipantHi Mahesh,
All working fine now – many thanks indeed.
Kind regards,
Roland
August 1, 2016 at 4:36 pm #96388MaheshParticipant@rolandallen: Thank you for your appreciation. Have a nice day!
Regards,
Mahesh -
AuthorPosts
- The topic ‘Slider – remove links’ is closed to new replies.