Home › Forums › Free Themes › Business Hub › LInking Slider Images to Pages
Tagged: linking slider images, slide images links
- This topic has 7 replies, 1 voice, and was last updated 3 years, 11 months ago by crischapman.
-
AuthorPosts
-
September 7, 2017 at 5:04 pm #52690evahillParticipant
Is there a way to link my slider images to webpages within my site? I don’t really want a “read more” button, I just want the image itself to link to the webpage pertaining to that slide.
Thank you in advance!
eva 🙂September 8, 2017 at 12:41 am #52720wensolutionsKeymasterHello @evanhill ,
First of all if you want to remove the Read More button go to Admin Panel > Appearance > Customize > Theme option > Slider and unchek the option Show Read More button.
Now to link the image of the slide you have to activate the child theme .
Child theme References :
https://codex.wordpress.org/Child_Themes
You can also activate the child theme using the plugin given below:
https://wordpress.org/plugins/wp-child-theme-generator/
After activating the child theme in your child themes functions.php file paste below given code .
https://gist.github.com/anonymous/c418a6629d90766cfcc381e41b0687fc
Hope this helps .
Best Regards!!
Have a good day .
September 8, 2017 at 1:04 pm #52815evahillParticipantThank you for your reply.
When I add the code you supplied just under the code already there, I get this error:
Parse error: syntax error, unexpected T_STRING in /home/content/87/11933087/html/wp-content/themes/business-hub-child/functions.php on line 17
My entire function.php code looks like this:
<?php
// Exit if accessed directly
if ( !defined( ‘ABSPATH’ ) ) exit;// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED – Do not modify or remove comment markers above or below:if ( !function_exists( ‘chld_thm_cfg_parent_css’ ) ):
function chld_thm_cfg_parent_css() {
wp_enqueue_style( ‘chld_thm_cfg_parent’, trailingslashit( get_template_directory_uri() ) . ‘style.css’, array( ‘meanmenu’,’business-hub-grid’,’owl-carousel’ ) );
}
endif;
add_action( ‘wp_enqueue_scripts’, ‘chld_thm_cfg_parent_css’, 10 );// END ENQUEUE PARENT ACTION
function business_hub_main_slider(){$theme_options = business_hub_theme_options();
$readmore = $theme_options[‘read_more_enable’];
$read_more = $theme_options[‘readmore_text’];
$slider_excerpt = $theme_options[‘slider_excerpt_enable’];
$slider_number = $theme_options[‘slider_number’];
if( ‘slider’ === $theme_options[‘main_slider_type’] && ( 1 === $theme_options[‘slider_enable’]) ){
if(!empty( $theme_options[‘slider_cat’] )){
$slider_args = array(
‘cat’ => absint( $theme_options[‘slider_cat’] ),
‘post_status’ => ‘publish’,
‘posts_per_page’ => absint( $slider_number),
);
} else{$slider_args = array( ‘post_status’ => ‘publish’, ‘posts_per_page’ => 5 );
}$slider_query = new WP_Query( $slider_args );
if ( $slider_query->have_posts() ) : ?>
<div id=”main-slider”>
<div class=”owl-carousel”>
<?php
while ( $slider_query->have_posts() ) : $slider_query->the_post();$image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), ‘full’ ); ?>
<div class=”item slider-linked” data-target=”<?php the_permalink(); ?>” style=”background-image: url(<?php echo esc_url($image_url[0]); ?>); “>
<div class=”caption”>
<h2><?php the_title(); ?></h2>
<?php if( 1 == $slider_excerpt ){ ?>
<div class=”entry-content”>
<p><?php echo esc_html( business_hub_limit_words( get_the_excerpt(), 25 ) ); ?> </p>
</div>
<?php } ?><?php if( 1 == $readmore ){ ?>
<div class=”btn btn-business”>“><?php echo esc_html( $read_more ); ?> <i class=”fa fa-angle-right”></i></div>
<?php } ?>
</div><!– .caption –>
</div><?php endwhile; ?>
</div>
<div class=”scroll-down-wrapper”>
<div class=”scroll-down”>
“>
<div class=”scroll-down-middle”> </div>
<span class=”fa fa-angle-double-down”></span>
</div><!– .scroll-down –>
</div><!– .scroll-down-wrapper –>
</div>
<?php wp_reset_postdata();
endif; ?><?php } elseif( ( 1 === $theme_options[‘slider_enable’]) ){ ?>
<div id=”main-slider” class=”main-banner”>
<?php
$banner_img = $theme_options[‘banner_image’];
if( !empty( $banner_img )){
$banner_img_args = array(
‘p’ => absint( $banner_img ),
‘post_status’ => ‘publish’
);$banner_img_query = new WP_Query( $banner_img_args );
if ( $banner_img_query->have_posts() ) :
while ( $banner_img_query->have_posts() ) : $banner_img_query->the_post();
$banner_img_url = wp_get_attachment_image_src( get_post_thumbnail_id(), ‘full’ ); ?><div class=”item” style=”background-image: url(<?php echo esc_url($banner_img_url[0]); ?>); “>
<div class=”caption”>
<h2><?php the_title(); ?></h2>
<?php if( 1 == $slider_excerpt ){ ?>
<div class=”entry-content”>
<p><?php echo esc_html( business_hub_limit_words( get_the_excerpt(), 25 ) ); ?> </p>
</div>
<?php } ?><?php if( 1 == $readmore ){ ?>
<div class=”btn btn-business”>“><?php echo esc_html( $read_more ); ?> <i class=”fa fa-angle-right”></i></div>
<?php } ?>
</div><!– .caption –>
<div class=”scroll-down-wrapper”>
<div class=”scroll-down”>
“>
<div class=”scroll-down-middle”> </div>
<span class=”fa fa-angle-double-down”></span>
</div><!– .scroll-down –>
</div><!– .scroll-down-wrapper –>
</div><!– .item –><?php
endwhile;
wp_reset_postdata();
endif;
}
?>
</div><!– .main-slider –><?php }
}add_action(‘wp_head’, ‘business_hub_child_custom_script’ );
/**
* [business_hub_child_custom_script Add custom script for slider image click]
* @return [NULL] [description]
*/
function business_hub_child_custom_script(){
?>
<script type=”text/javascript”>jQuery(document).ready(function($){
$(‘.slider-linked’).click(function(){
var link = $(this).attr(‘data-target’);
window.location.href = link;
});
});
</script>
<?php
}Thank you in advance.
September 8, 2017 at 1:08 pm #52816evahillParticipantYIKES!! Now the whole site is down, and I am only getting the:
Parse error: syntax error, unexpected T_STRING in /home/content/87/11933087/html/wp-content/themes/business-hub-child/functions.php on line 17
I can’t even change it back to the business hub theme!!
Please help!!!!
September 8, 2017 at 1:09 pm #52817evahillParticipantMy site is:
September 8, 2017 at 1:25 pm #52818evahillParticipantOK, I looked on youtube on how to fix the parse error, and deleted the child theme from the ftp directory. Yikes!!
How about if we leave the read more button. Can you please show me how to link the read more button to a certain page please.
September 26, 2017 at 5:10 am #54190wensolutionsKeymasterHello @evanhill,
Our sincere apology in delay in replying to you .
The read more button in the slider links to that particular post . The theme does not have the option to include the external link in Read More button .
Hope this clears up the confusion .
Best Regards!!
December 24, 2020 at 6:25 am #141366crischapmanParticipantGot the same issue with slider. Thank you, guys, for the info.
-
AuthorPosts
- You must be logged in to reply to this topic.