You could do something like this:
/* Add disclaimer to top of POSTS that contain affiliate tag */
function tt_filter_the_content( $content ) {
if (has_tag('affiliate') && is_single())
$custom_content="<hr><p><em>Disclosure: This post contains affiliate links and we may receive a referral fee (at no extra cost to you) if you sign up or purchase products or services mentioned.</em></p><hr>";
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'tt_filter_the_content' );
Now you are checking if the tag exists and if it’s a single post. If this still shows up in the feed, then you can change the if statement to something like:
if ((has_tag('affiliate') && is_single()) && !is_feed())
Related Posts:
- Stripping shortcode from custom excerpt function
- Remove images from get_the_excerpt
- Adding body class when post contains a specific shortcode
- Super simple shortcode not working
- How to filter out shortcode when displaying the_excerpt() in the loop?
- How to filter $content in shortcode function
- Excerpts are not displayed by a shortcode on category pages
- Setting a default text for excerpts of a particular category
- Native gallery custom html output
- Customizing the wp_video_shortcode output with add_filter
- Appending „read more” to the excerpt conditionally
- How to make an If Else on Excerpt Filter
- Shortcode to eliminate and replace with
- Problem in outputting shortcode
- Can’t change excerpt length and more tag
- function to show youtube videos within excerpt – if condition and apply_filters
- Can’t properly set the_title add_filter to show short_URL
- Add_filter when value is no variable?
- the_excerpt filter doesn’t work as expected
- How to add_filter html template to middle of content
- Shotcode argument issues
- Shortcode parse error – wrong syntax
- (Woocommerce) Order by price when entering specific category
- Filter an WordPress Function in (general-template.php)
- Exclude category from shortcode
- wp_nonce_field is breaking form for reasons unknown
- Shortcodes in RSS excerpts
- Remove links from the_content when using filters wp_trim_excerpt
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- Excerpt for pages not showing
- get_pages() Returns Only One Item
- run shortcode in excerpt of single custom post type
- Redefine function arguments before rendering
- Function shortcode – Set Parameter
- How to edit classes in body tag?
- Adding an option to a shortcode
- How to use author meta in shortcode?
- Using multiple line variable inside a function?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Use a shortcode to display custom meta box contents
- Echoing function into WordPress NextGen gallery
- How do I pull excerpts from pages?
- Output loop to function return?
- How to echo the value of an array element using a function via a shortcode
- Filter nav menu items HTML tags and wrap inner text with span
- Wp-query Order By problem
- Possible to hook into Media Library preview File column and use a custom image?
- WordPress Excerpt – How to remove the first link using functions.php
- How can I add a class to a nav li depending on URL?
- Access category within rss2_head hook?
- Modify gform_other_choice_value for specific form and specific field in Gravity Forms
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- Combine embed_oembed_html and oembed_result
- login_headertitle is deprecated since version 5.2.0
- Set “woocommerce_is_purchasable” to false for specific “$product->is_stock_status”
- Woocommerce checkout field
- How to display the_archive_title() and the_archive_description() – “weird” interaction
- Filter to wp_list_authors
- Strip div From Excerpt
- How to add custom li item to wordpress menu
- How to include any template using Shortcode fuction?
- How can I pass a shortcode value to the head in wordpress functions.php
- How to change value of variable in theme file with functions.php WordPress?
- Need to convert image url to a Base_64 data url with wordpress function..
- The_content and Preg_replace in loaded Iframe [closed]
- dynamic site link for future migration in echo do_shortcode()
- How to create shortcode with html and php content?
- first paragraph of the_content as meta description
- Tracking the number of shortcodes for a list?
- Need a method to prevent WP from adding in between my shortcodes
- How to edit/replace Parent functions.php function in Child Theme to add “Walker” class
- Load scripts for do_shortcode( ‘ [ my_shortcode ] ‘ )
- Shortcode question
- Functions Filter Question [closed]
- Can I include a custom PHP function in a WordPress function?
- How to create a shortcode out of a php function
- Is it possible to use add_filter in an included file in the child theme’s functions.php?
- Insert Content Before div#main from the functions.php File
- Add Adsense code between job listings – wp job manager plugin
- Problem with images URL after filter applying
- remove_action not working, even after changing priority [duplicate]
- remove/hide wp-editor
- Shortcode to get featured image of specific id post
- Modify shortcode to work with custom post types
- How do I place a function in a standalone page?
- shorthand syntax for custom fields
- Replace header image on all other pages but home – URL issue
- Add a class to post if it has been recently updated
- Adding Read More to Custom excerpts
- search form leads to 404
- Limit number of characters in different excerpts
- how to add_filter to non hook function
- Shortcode of a function
- show all the posts thumbnails
- Changing the text of Upload/Insert on Posts and Pages Screen
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- Any adverse effects of adding apply_filters to a function?
- Conditional custom menu?