Hey Dan,
and thanks for your question.
Well… you could use the do_shortcode_tag
filter for that. Are you familiar with PHP?
Greetings
Flo
Thanks Flo. I only have a beginner understanding of PHP but I’ll do some research to see if I can piece this filter together.
I’m a little in over my head here. I’ve got this far:
function append_class_to_gaoo( $output, $tag ) {
if ( 'google_analytics_optout' !== $tag ) {
return $output;
}
return $output . ' class="button-class"';
}
add_filter('do_shortcode_tag', 'append_class_to_gaoo', 10, 2);
But it simply prints ‘class=”button-class”‘ after the <a>
tag. I don’t suppose you could help me place it within the <a>
tag?
You’re welcome! š
And you’re almost there. I would suggest to use str_replace. Depending on the code that you use inside the shortcode, this would be one way to do it:
return str_replace( '<a', '<a class="button-class"', $output );