**strong text**/****post-tag****/
function asr_tags() {
$asrtags = get_the_tags( get_the_ID());
foreach($asrtags as $tag){$string .= '<span class="post-tag"><a class="p-tag" href="'. get_tag_link($tag->term_id) .'">'. $tag->name . '</a></span>' . "\n";
}
return $string;
}
add_shortcode('asrtags' , 'asr_tags' );
/*****post-tag*****/
**strong text**/****post-tag****/
function asr_tags() {
$asrtags = get_the_tags( get_the_ID());
foreach($asrtags as $tag){$string .= '<span class="post-tag"><a class="p-tag" href="'. get_tag_link($tag->term_id) .'">'. $tag->name . '</a></span>' . "\n";
}
return $string;
}
add_shortcode('asrtags' , 'asr_tags' );
/*****post-tag*****/
Share
Improve this question
edited Aug 7, 2019 at 8:39
abdullahsk
asked Aug 6, 2019 at 18:47
abdullahskabdullahsk
12 bronze badges
1 Answer
Reset to default 1get_the_tags()
returns an array or false
on failure. (It appears it may also return a WP_Error
object under certain circumstances.)
It also requires a parameter: the post ID. You're not passing that, so you're not going to get the array your code expects.
Edit
You can't just call get_the_tags()
-- that'll just get you a value of false
. You need to provide a post ID.
This might work: replace
$asrtags = get_the_tags();
with
$asrtags = get_the_tags( get_the_ID() );
...but note that this will only work if you're in The Loop.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744860923a4597696.html
评论列表(0条)