• Hello guys!

    First of all I’m a total beginner ! I have two weeks with wordpress and the same with PHP and HTML.

    So pretty much this code was totally made with effort and trying and not much of a technique so I’m sorry if it doesn’t follow the best practices but somehow it’s starting to work.

    function test_shortcode(){
    $content = '
    [simple_tooltip content="<strong>Marca Superior de Dano de Ataque:</strong><br />
    Nível: <span style="color: #00ff00">20</span><br />
    <span style="color: #ff0000;">+0.95</span> de Dano de Ataque"]
    
    <img src="http://leagueoflegendsbrasil.com/wp-content/uploads/2014/11/runaataque.png" alt="leagueoflegends" width="50" height="50" />
    
    [/simple_tooltip]';
    
    echo do_shortcode($content);
    }
    
    add_shortcode('test', 'test_shortcode');

    The problem is that the the image is being showed two times and also the colors from the span style are not working.

    Any hint how to fix that?

    Thanks in advance

    [bump moderated]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    What exactly are you trying to do here?

    That code doesn’t make a whole lot of sense. You would not want a do_shortcode call inside a shortcode, for example.

    Thread Starter ravock

    (@ravock)

    I’m trying to create images with a nice looking tooltips, so I can use the same image with the same tooltips in many pages.

    And in case I need to change some of the information I just change the shortcode and not codes all over the site.

    That’s why the shortcode has a simple and easy to remember name so I can use it easily later since I plan to shortcode lots of different items.

    For instance the character A,B,C and D use the Item test I created so I simply add [test] wherever I want to add the image+tooltip.

    Thanks.

    Thread Starter ravock

    (@ravock)

    I edited the code to:

    function test_shortcode(){
    return '
    [simple_tooltip content="<strong>Marca Superior de Dano de Ataque:</strong><br />
    Nível: <span style=&quot;color: #00ff00&quot;>20</span><br />
    <span style=&quot;color: #ff0000;&quot;>+0.95</span> de Dano de Ataque"]
    
    <img src="http://leagueoflegendsbrasil.com/wp-content/uploads/2014/11/runaataque.png" alt="leagueoflegends" width="50" height="50" />
    
    [/simple_tooltip]';
    
    }
    
    add_shortcode('test', 'test_shortcode');

    Now it only shows one image but still the span style color is not working, can someone help me just with that?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    You can’t return shortcodes from inside a shortcode. They won’t be processed.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘do_shortcode() question!’ is closed to new replies.