Add Sponsored Post Prefix to Post Title
-
Hi Guys,
I copied the below snippet on how to “add sponsored post prefix to post tile” from: https://www.wpbeginner.com/wp-tutorials/how-to-add-sponsored-post-prefix-to-post-title-in-wordpress/
add_filter( 'the_title', 'wpb_sponsored' ); function wpb_sponsored( $title ) { global $post; $sponsored_text = '<span class="sponsored_text"> Sponsored Post</span> '; $sponsored = get_post_meta($post->ID, 'sponsored', true); if( $sponsored == 'true' && in_the_loop() ){ return $sponsored_text.$title; } return $title; }
This is working, but the problem is that the “Sponsored” text which is in red is also visible in the breadcrumb. Can anyone assist with a solution not to show the “Sponsored” text in the breadcrumb but only on the “Title” itself?
Thanks
- This topic was modified 4 years, 9 months ago by .
- This topic was modified 4 years, 9 months ago by .
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Add Sponsored Post Prefix to Post Title’ is closed to new replies.