I want to copy/move all tags of a post into posts content, as text form not in a link form.
For example:
A post has:
- a title in title field,
- some content in content field (like: a boy has good nature),
- three tags (like: x1,x2,x3).
Can we copy all tags of that post in their content field, like:
A post has:
- a title in title field,
- some content in content field (like: a boy has good nature x1 x2 x3),
- three tags (like: x1,x2,x3).
as in text, not in link form.
I want to copy/move all tags of a post into posts content, as text form not in a link form.
For example:
A post has:
- a title in title field,
- some content in content field (like: a boy has good nature),
- three tags (like: x1,x2,x3).
Can we copy all tags of that post in their content field, like:
A post has:
- a title in title field,
- some content in content field (like: a boy has good nature x1 x2 x3),
- three tags (like: x1,x2,x3).
as in text, not in link form.
Share Improve this question edited May 10, 2019 at 9:40 Neeraj Bill asked May 9, 2019 at 10:19 Neeraj BillNeeraj Bill 12 bronze badges1 Answer
Reset to default 0You can simply preprocess the content by adding a filter to the_content
like that:
function wpse_337486( $content ) {
if ( is_single() ) {
// Get the current post.
global $post;
// Get all post tags. Get only their names.
$tags = wp_get_post_tags($post->ID, ['fields' => 'names']);
// Append post tags to content.
$content = $content . ' ' . implode(' ', $tags);
}
return $content;
}
add_filter( 'the_content', 'wpse_337486' );