• Resolved bcanr2d2

    (@bcanr2d2)


    The issue can be found here: https://oneshc.staging.wpengine.com/
    The preview works: Yes
    It works with other themes: Yes
    It works when I disable all other plugins: Haven’t Tried
    Meta Slider version: 3.4

    I am wondering how I can dynamically change the link on a slide.

    I am looking at the following page, to see if it is possible
    https://www.metaslider.com/documentation/metaslider_type_slider_anchor_attributes/

    I am using a Nivo slider.

    add_filter( ‘metaslider_nivo_slider_anchor_attributes’, ‘metaslider_change_lookup_link’, 10, 4);
    function metaslider_change_lookup_link ($attributes, $slide, $slider_id) {
    //Change the lookup link on slide 5286 to be dynamic
    if ($slide->ID == 5286) {
    //Get member type info
    $member_type = xprofile_get_field_data(‘Member Type’,bp_loggedin_user_id());
    If ($member_type == ‘A’ ){
    Set link here to match this type
    } else {
    Set a different link
    }

    }
    return $attributes;
    }

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    You will need something like the following:

    add_filter( ‘metaslider_nivo_slider_anchor_attributes’, ‘metaslider_change_lookup_link’, 10, 3);
    function metaslider_change_lookup_link ($attributes, $slide, $slider_id) {
    	//Change the lookup link on slide 5286 to be dynamic
    if ($slide->ID == 5286) {
    //Get member type info
    $member_type = xprofile_get_field_data(‘Member Type’,bp_loggedin_user_id());
    If ($member_type == ‘A’ ){
    	$attributes['href'] = 'https://example.com';
    } else {
    	$attributes['href'] = 'https://example.com';
    }
    
    }
    return $attributes;
    }
    Thread Starter bcanr2d2

    (@bcanr2d2)

    Perfect, thanks for that.
    Only thing is that instead of $slide->ID, I had to use $slide[“id”] to get the value from the array

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change slide links programatically’ is closed to new replies.