Hi folks maybe someone can help me. It does not work and I've already tried everything
This should be the shortcode:
[permalink url="http://www.domain.com/" linktext="My Link Text"]
And that the associated function:
function external_permalink( $atts ) {
$atts = shortcode_atts( array(
'linktext' => '',
), $atts, 'permalink' );
$url = get_permalink( array(
'url' => '',
'target' => 'self'
), $url, 'url' );
return '<a href="' . $url['url'] . '">' . $atts['linktext'] . '</a>'; }
add_shortcode('permalink', 'external_permalink');
I have no idea why you even have get_permalink
because it shouldn't be there. This should work
function external_permalink($atts)
{
$atts = shortcode_atts(array(
'linktext' => '',
'url' => ''
), $atts);
return '<a href="' . $atts['linktext'] . '" rel="nofollow">' . $atts['linktext'] . '</a>';
}
add_shortcode('permalink', 'external_permalink');