button link shortcode -> open in new window?

resolved (8 posts) (6 voices)

  1. Suivi

    Hi there - the button link shortcode is great
    [button link="#"]Click Me[/button]

    But it always opens the link in the same window! Is there a way to open the link in a new window/new tab? I tried to add

    but it doesn't work!
    Thanks for your help!

    Posted 6 years ago #
  2. Ruderic


    Go to the theme folder and open the file "lib/functions/shortcode.php".

    In line #26, replace this code:

    $out = "<a class=\"button_link\" href=\"" .$link. "\"><span>" .do_shortcode($content). "</span></a>";

    With this new one:

    $out = "<a class=\"button_link\" href=\"" .$link. "\" target=\"_blank\"><span>" .do_shortcode($content). "</span></a>";

    Try that and let us know the results.

    Posted 6 years ago #
  3. Suivi

    awesome! It works perfectly now! THANK YOU

    Just one more question - Can i make a decision button by button if the link shouldbe opened in an extra window or in the same window? Because when it's defined in the shortcode.php - file every button-link is opened in a new window, right?

    Posted 6 years ago #
  4. Ruderic


    In that same file, replace all the content between the "Buttons" label (lines #21 to #36) with this new one:

    function webtreats_button( $atts, $content = null ) {
            'link'      => '#',
    		'blank'     => 'false'
        ), $atts));
    	$blank_link = '';
    	if ( $blank == 'true' )
    		$blank_link = "target=\"_blank\"";
    	$out = "<a class=\"button_link\" href=\"" .$link. "\"" .$blank_link."><span>" .do_shortcode($content). "</span></a>";
        return $out;
    add_shortcode('button', 'webtreats_button');

    Now, if you want the button to open in a new tab, you have to add the attribute "blank" to the shortcode, and set it's value to "true".

    For example:

    [button link="google.com" blank="true"]...[/button]

    Try that and let me know the results.

    Posted 6 years ago #
  5. JReese

    Just came looking for this very same thing. Very nice feature and even better with the option to open the link in a blank window. The updated code works perfectly for me.


    Posted 6 years ago #
  6. Awesome product support. Can't wait for the new theme!

    Posted 6 years ago #
  7. OceanGrand

    I am trying to get this open in a new window to work in both dejavu and myriad. In dejavu I do not see lib/functions/shortcode.php

    Posted 5 years ago #
  8. Elliott

    In our new framework we have an option for this in the shortcode, http://mysitemyway.com/docs/index.php/Fancy_Links_and_Buttons#Fancy_Buttons.

    Use our shortcode generator to easily customize and insert shortcodes, http://mysitemyway.com/docs/index.php/Using_the_Shortcode_Generator.

    Posted 5 years ago #


You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme