Adding custom text at end of posts in certain categories.
-
Hi, I am doing a series on my blog and want to add custom text at the end of each post that is tagged in this category.
I found this coding:
_______________________________________________________________________
add_filter(‘the_content’, ‘custom_category_text’);function custom_category_text($content){
global $post;
$custom_category_text = ‘<p>This post is a part of the #tenminutes challenge, a global challenge to write/craft/reflect for ten minutes everyday, no matter what. This is a personal invitation to join the challenge to help you become more dedicated to your passion and polish your craft. To learn more about the movement, visit: https://www.chorusofblue.com/ten-minutes. Join the movement!</p>’;
if(in_category(‘ten-minutes’)){ // change category ID ten-minutes
$content = $content . $custom_category_text;
}
return $content;
}_______________________________________________________________________
and added it as instructed to the function.php file (I just added at the end, not sure if thats where it should be placed), but Im having two issues with it:
1. I want it to appear at the END of the TEXT in the post, before the sharing and social media links, rather than after all of that.
2. I want the web address to show as a LINK with the the text just saying “Ten Minutes Project” rather than the full web address.
Can anyone help? Ive been adding the text manually to each post and its very frustrating. Thanks in advance.
Here’s an example of the code in action… youll see I have my manual text where I want the automatic text to appear (havent removed it yet) right after the posts text, and the automatic text appears AFTER the social media links and other related posts links… and it also shows the full web address, rather than an actual link.
https://chorusofblue.com/free-write-storm/
Please help!
- The topic ‘Adding custom text at end of posts in certain categories.’ is closed to new replies.