Support » Plugin: Promotion Slider » [Plugin: Promotion Slider] rel="" for promo slider?

  • Resolved artsfantasy


    Hi there, great plugin i love it!

    I am trying to hack the plugin so i can define a rel attribute for a link and… i need a bit of help 😀

    I am not a master in PHP, but im not a beginner eather, but i would appreciate some guidance here before ill break the plugin.

    So in plugins index.php i have found the output that the plugin is generating, and then i have discovered that this wont be so easy. here is what the output looks like

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Now you can see that the link is being outputed with a ‘fetch_link_settings’ function. That looks like this:

    function fetch_link_settings(){
    			global $post;
    			// If the destination url is set by the user, use that.  Otherwise, use the permalink
    			$destination_url = get_post_meta($post->ID, '_promo_slider_url', TRUE);
    			if( !$destination_url ) $destination_url = get_permalink($post->ID);
    			// If the target attribute is set the user, use that.  Otherwise, set it to _self
    			$target = get_post_meta($post->ID, '_promo_slider_target', TRUE);
    			if( !$target ) $target = '_self';
    			// Setup the disable links variable
    			$disable_links = get_post_meta($post->ID, '_promo_slider_disable_links', TRUE);
    			return compact('destination_url', 'target', 'disable_links');

    now im a bit confused as to how to add a PHP code that in human language would sound something like this:

    If custom field x value is true then output custom field value to links rel, else do nothing.

    any help here?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Micah Wood


    Sorry, part of your code was moderated so I am not sure I am fully getting what you are trying to do.

    I believe you would just add something to this effect:

    global $post;
    $custom_field = get_post_meta( $post->ID, '_my_custom_field', true );
    if( $custom_field ) {
        // DO STUFF

    Hi woodent, thanks for your help! You should receive a WordPress medallion for all the help that you have done here in the wordpress community.

    This unfortunately does not do the trick.

    Let me clarify what i want to do.
    The Promotion Slider outputs a link, i want to add to that output of that rel parameter of that link.

    <a href="$destination_url" target="$target" rel="custom field defined rel">

    I have enabled custom fields for the Promotion Slider, now what i think i need to do is edit the above

    function fetch_link_settings()

    so it actually will output the rel parameter as well.

    Plugin Author Micah Wood


    Right. So I guess you would add this to your function:

    $custom_field = get_post_meta( $post->ID, '_my_custom_field', true );

    Then make sure and pass $custom_field back via your array. Then you just check if disable links is false before outputting your html. If $custom field is false, then wouldn’t output your rel attribute, otherwise you would.

    You could build your html in this type of fashion:

    $link = '';
    $link_settings = fetch_link_settings();
    if( ! $link_settings['disable_links'] ) {
        $link .= '<a href="'.$link_settings['destination_url'].'" target="'.$link_settings['$link_settings['target']'].'"';
        if( $link_settings['custom_field'] ) {
            $link .= ' rel="'.$link_settings['custom_field'].'"';
        $link .= '>YOUR LINK CONTENT</a>';
    echo $link;

    looks solid.

    i guess my confusion comes from looking at the plugin code, and not finding any <a href=”do php stuff here …

    Is it possible that php generates the whole link structure without using any echo or print?

    I thought that there is some global attribute that generates the link structure ( by looking at that php code ).

    Basically i though there is some black magic involved here.

    Anywhays, here is a paste bin with the plugin code that i was looking at.

    And yes – thank you again. I will have to delve deeper into the plugin files to figure this thing out it seems and find that <a output.

    Thank you again!

    Plugin Author Micah Wood


    Ah… you would probably want to look in the /includes/function.php file on line 88.

    You should probably be using the ‘promoslider_content’ action hook to remove the ‘promoslider_display_title’ function and replace it with your own (see line 7 of the same file).

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Promotion Slider] rel="" for promo slider?’ is closed to new replies.