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
- Removing default image size list in Media Box
- How to restrict actions and filters “properly” by conditions
- Check if the user has explicitly set an excerpt
- How to display random users with avatars
- How to override function in functions.php of parent theme?
- Creating a table from shortcode avoiding wpautop for each row
- Shortcode with custom content attribute?
- Shortcode to insert menu in page body?
- Passing HTML in WordPress Shortcode arguments
- Allow latex in wordpress excerpt
- Exclude Empty Child Categories in Menu
- add_filter priority problem
- Clean-up script tags
- Custom Shortcode, functions PHP WP_Query loop
- Display gallery on top before content
- Using “Read More” link with custom excerpt
- Adding multiple taxonomy filters to functions.php
- How to extract the variables out from “add_shortcode” function?
- How to get specified parent page title in my function
- Last updated date function
- Possible to display shortcode based on the category?
- How to set default archive image without overriding first attached image? [closed]
- Only let plugin add actions to wp_head & wp_footer on single posts
- Display post shortcode content in the sidebar?
- How to make custom column Admin>Users sortable?
- How to get the index number of the posts?
- Get Current Post ID in functions php, meta query filter
- Using shortcode content with nested shortcode
- Output and filter data from a XML url
- What did I do wrong in my functions code, that will not change the “Get New Password” text to “Send It”?
- Limit length of first excerpt in the loop
- Display gallery on bottom after content
- WordPress Shortcode function display outside of widget
- check if the user is owner of current page
- Add Element as a Filter to the_content
- Use html inside shortcode function
- How would I go about replacing this function in my child theme located in inc/template-tags.php
- Retrieve a value from Yoast SEO to use to set a default twitter card image honoring overrides
- Can’t properly set the_title add_filter to show short_URL
- the_excerpt filter doesn’t work as expected
- Filter an WordPress Function in (general-template.php)
- 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
- Function shortcode – Set Parameter
- Filter nav menu items HTML tags and wrap inner text with span
- Modify gform_other_choice_value for specific form and specific field in Gravity Forms
- Set “woocommerce_is_purchasable” to false for specific “$product->is_stock_status”
- How to add custom li item to wordpress menu
- How to create shortcode with html and php content?
- Can I include a custom PHP function in a WordPress function?
- remove_action not working, even after changing priority [duplicate]
- remove/hide wp-editor
- Limit number of characters in different excerpts
- Problem with shortcode inside a shortcode
- Need help making a short code work
- How to display an image before title text in menu items
- Save_post – Warning: Cannot modify header information
- custom error message for empty username and password using authenticate filter not working
- Last updated posts shortcode in functions.php
- Add #primary at the end of navlink permalinks on single posts
- Reload page with a different shortcode when a user selects from a dropdown
- How can I automatically delete comments that contain a URL?
- How to add class dynamically from templates
- Display list of pages that contain a certain string within the slug
- $content is empty while using DOMDocument
- HowTo: Add wrapper to columns shortcode?
- Auto-generated excerpt with shortcode and read more button/text link
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- Custom shortcode with do_shortcode and substr
- Regex works in regexr, but not if I filter content [closed]
- Retrieve a custom form field modified by a filter
- Can I use a function to return HTML and the result of another function?
- Expanding a function to call a plugin or show a link
- Excerpt length: get 2 paragraphs
- Trying to the deduce shortcode from a function
- Run function from parent on child site
- Force resize for all video content
- Way of getting queried loop before the query with a filter hook?
- Shortcode Variations?
- Excerpt – First Sentence & Read More
- Custom shortcode not being included in content paragraph [duplicate]
- Trying to get this function to show below the content
- Creating mixture of shortcodes to use in the visual/text editor