Home Forums Free Themes Business Hub LInking Slider Images to Pages

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #52690
    evahill
    Participant

    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 🙂

    #52720
    wensolutions
    Keymaster

    Hello @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 .

    #52815
    evahill
    Participant

    Thank 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.

    #52816
    evahill
    Participant

    YIKES!! 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!!!!

    #52817
    evahill
    Participant
    #52818
    evahill
    Participant

    OK, 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.

    #54190
    wensolutions
    Keymaster

    Hello @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!!

    #141366
    crischapman
    Participant

    Got the same issue with slider. Thank you, guys, for the info.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.