You can do that, as long as you’re doing it inside the shortcodes function.
You’d need to do something like this:
function tag_count_shortcode ($atts, $content = '') {
extract (shortcode_atts (array (
"slug" => ""
), $atts);
echo "<p>Slug is '" . $slug . "'</p>";
}
not to god on php, sry, I need the exact code ore codes.
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Then have you contacted your theme’s or plugin’s author?
Is it possible to replace “test” text from this shortcode with this php code?
not directly, but you can include the ‘do_shortcode’ code into the foreach loop;
example:
<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo do_shortcode('[tag_count slug="' . $tag->slug .'"];
}
}
?>
thank you, your code works, with one small mistake, you forgot ‘) to close.
<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo do_shortcode('[tag_count slug="' . $tag->slug .'"]');
}
}
?>