WordPress.org

Ready to get started?Download WordPress

Forums

Customizr
[resolved] Adding Links to Slider Images (15 posts)

  1. omerbaturay
    Member
    Posted 4 months ago #

    Hey guys,

    Im trying to link each slider image to different parts of my website on my homepage but am failing to do so. I've looked at the snippet available for this purpose but it only works for one slider image. The "array" code given is also failing to link any of the slider images anywhere.

    The website is omerbaturay.com and the array snippet is currently active with no links being present on any slider images. The code is in functions.php and it is as follows:

    add_filter('tc_slide_link_url' , 'my_slide_custom_link', 208, 214, 213, 209);
    function my_slide_custom_link( $slide_link , $image_id ) {
        //custom links array : image_id => link
        $image_links = array(
            '208' => 'https://vimeo.com/81040719',
            '214' => 'http://www.eddhawkes.co.uk/wp-content/uploads/2014/01/Union-Jack-Final.jpg',
            '213' => 'https://vimeo.com/81078747',
            '209' => 'https://vimeo.com/'
        );
    
        //does nothing if the requested image_id is not a key of the array
        if ( ! array_key_exists( $image_id, $image_links ) )
            return $slide_link;
    
        //else returns the custom link
        return $image_links[$image_id];
    }

    Any ideas? Thank you very much.

  2. d4z_c0nf
    Member
    Posted 4 months ago #

    Yes, for example:

    add_filter('tc_slide_link_url' , 'my_slide_custom_link', 208, 214, 213, 209);

    This is wrong, look:
    http://codex.wordpress.org/Function_Reference/add_filter

    Shoult be something like

    add_filter('tc_slide_link_url' , 'my_slide_custom_link', 10, 2);

    which means:
    add_filter('filter_name', 'function', 'priority', 'number_of_accepted_args');

  3. ElectricFeet
    Member
    Posted 4 months ago #

    @omerbaturay: I presume you saw this?

  4. omerbaturay
    Member
    Posted 4 months ago #

    @ Electric - yeah I posted there too just to get an answer as soon as possible.

    @d4z - Thank you, I will try it tonight and let you know. :)

  5. omerbaturay
    Member
    Posted 4 months ago #

    @d4z_c0nf - Thank you for your input but the following change does not do anything to adding links to the sliders.

    As an alternative, is there a possibility of hyper linking the text that appear on the sliders?

  6. d4z_c0nf
    Member
    Posted 4 months ago #

    @omerbaturay that snippet (and I just told you how to proper use wordpress filters) just replaces the call to action link with a custom url. That means that replaces the url of the button, if you have a button in the slide. I don't see any button in your sliders.
    Am I missing something?

  7. omerbaturay
    Member
    Posted 4 months ago #

    @d4z_c0nf - Yessir. I'm trying not to use call to action buttons (I know how to change those links) but instead link the images to a custom link to the image on the slider without having the button.

    OR as an alternative, hyperlink the text on the slider.

  8. d4z_c0nf
    Member
    Posted 4 months ago #

    Ok so you're using the wrong snippet, or better, the wrong filter.
    That snippet is to use call to action button, if you don't want that, you don't have to use that.

    You should use the first one here: http://www.themesandco.com/snippet/setting-a-custom-external-url-to-a-slide/
    Linking the whole slide’s picture to a custom external url

  9. omerbaturay
    Member
    Posted 4 months ago #

    Thank you d4z_c0nf. It's not working for me.

    Do you have any idea of hyperlinking the test possibly?

    As a last resort - could you provide a snippet for changing the size of the linking button?

  10. d4z_c0nf
    Member
    Posted 4 months ago #

    There's another snippet:
    http://www.themesandco.com/snippet/linking-the-whole-slides-picture-to-a-pagepost-in-customizr/

    Anyway, could you paste the exact code you're using in pastebin.com and copy the url here?
    I really wanna see what's going wrong, 'cause looking at your source clearly it doesn't anything.

  11. omerbaturay
    Member
    Posted 4 months ago #

    I can't believe I missed this!

    Thank you so much. This works perfectly!

  12. omerbaturay
    Member
    Posted 4 months ago #

    I can't believe I missed this!

    Thank you so much. This works perfectly!

  13. d4z_c0nf
    Member
    Posted 4 months ago #

    Finally! :D

    I don't like this part but.. would you mind marking this topic as resolved?

    Thanks, and.. to be sincere I missed that too, I just discovered it today by chance :D

  14. omerbaturay
    Member
    Posted 4 months ago #

    It is for sure resolved! :)

  15. d4z_c0nf
    Member
    Posted 4 months ago #

    :D

  16. d4z_c0nf
    Member
    Posted 4 months ago #

    @omerbaturay , look that your caption has a link to "omberbaturay.com/undefined"

    Try replacing this:

    var link = $( this ).find('a').attr('href');

    with this:

    var link = $( this ).parent().find('a').attr('href');

    Should do the trick.

Reply

You must log in to post.

About this Theme

About this Topic