1
votes

I want to modify the output of a shortcode added inside a post edition.

I have this function in shortcodes.php:

function pi_app_store_petit($atts, $content = null)
{
    extract(shortcode_atts(array(
        'url' => 'url=""'
    ), $atts ) );

    return "<a href='$url' target='itunes_store'>".do_shortcode($content)."</a>"; 
}

add_shortcode('app_store_petit', 'pi_app_store_petit');

This only inserts [app_store_petit][/app_store_petit] inside the post edition,
but I want [app_store_petit url=" "][/app_store_petit].

What I've to change? Thanks! :)

1

1 Answers

0
votes
function pi_app_store_petit($atts, $content = null)
{
    $atts = shortcode_atts(array('url' => 'url=""'), $atts,'app_store_petit');
    return "<a href='{$atts["url"]}' target='itunes_store'>".do_shortcode($content)."</a>"; 
}
add_shortcode('app_store_petit', 'pi_app_store_petit');

Now, you can use [app_store_petit url=" "][/app_store_petit]

Reference : https://codex.wordpress.org/Function_Reference/add_shortcode