Is there a better way to accomplish this using the affiliate tags on
my posts?
Definitely I would go for an easier option, not relying on plugins like Jetpack.
Why don’t you try the has_tag function? Something like this:
function tt_filter_the_content( $content ) {
if (has_tag('affiliate'))
$custom_content="YOUR MESSAGE";
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'tt_filter_the_content' );
This will filter your content and add your “YOUR MESSAGE” on all posts with the “affiliate” tag name.
Reference https://developer.wordpress.org/reference/functions/has_tag/
Related Posts:
- How to get the registered sidebar’s name by its id?
- display most popular tags in two columns
- WordPress menu deletes when trying to add a hook
- Get widget settings function?
- javaScript in section of WP API
- Add before_content and after_content to register_sidebar
- PHP Deprecated: WP_RSSjb has a deprecated constructor
- How to put a variable in a instance in the widget
- Adding a widget function into the php theme file
- Widget back end radio button issue
- My website is not showing Footer section
- How to get post category list as select in front-end?
- Show different website layout if no sidebar added
- Add a select-option to the default widgets
- How a HTML form can trigger a PHP function?
- is_user_logged_in() not working in homepage
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- WordPress – registering sidebar and adding a button directly after .textwidget
- List sibling pages widget, exclude current page
- WP Debug enabled Undefined index error in a widget
- Allowed memory size of 268435456 bytes exhausted (tried to allocate 7146491840906359738 bytes)
- Customize default settings on new sites on multisite
- How do I get the author’s page url from their ID?
- Remove class that has been added by parent theme
- How to check from which page the user is coming to the current page?
- Setting up the child theme so as to enable right-to-left WordPress?
- Design view breaking on Pages
- Hooking new functions to actions + passing parameters
- Execute only on a certain page
- Replace comment avatars and links at the same time
- Check if Product is in a Specific Category in Functions.php
- Adding ads code between comments
- Create Logout Link WordPress Admin Menu
- How to Display Image Meta underneath EVERY image in EVERY post
- Calculations in functions.php [closed]
- Limiting woocommerce line_total decimal length
- Shortcode content filter?
- only show container with next/prev links if they exist?
- JS file work only in index page
- Error in custom php function doesn’t exist
- Custom shortcode outputs plain text instead of HTML at top of post
- how can i use $_COOKIE[] + PostID to execute the below code?
- register_taxonomy() take much queries
- Can anyone offer any help with this function?
- Shortcode with PHP issue “Undefined index”
- height should be set to auto to avoid pixelation in the post thumbnail function
- Can i put my shortcode inside a variable in php files?
- Override a function defined in wp-includes/comment-template.php
- Show meta box only for default page template
- Can’t access site after making changes to the functions.php [closed]
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- Countdown to date function?
- calling a custom field value inside functions.php
- Custom meta box values are not getting saved for my custom post type
- Simple AJAX notification when the new post is added to the database
- Upload multiple files in randomly generated folder using wp_upload_bits
- Personalize checkout text
- WordPress check if current taxonomy has child
- get post id from wp_insert_post for get_template_part
- This function is deprecated; use mysql_real_escape_string() instead
- get_theme_mod outputs number when using WP_Customize_Cropped_Image_Control
- Adding an interior ‘hero’ area with some added php title customization
- Call to undefined function error in plugin
- Custom Taxonomy Select Menu: Setting default option value?
- How to add author’s posts link (HTML + PHP) inside a function to output it
- Creating customized php files in theme folder
- Conditional On custom field plugin metabox
- Post Views Code Hacks
- Closing WP_LINK_PAGES DIV ID w/After Argmuent
- Exclude function from running on a certain page
- How to set value selected using select2 jquery plugin
- Workaround for og:image unsupported webp image type, Yoast SEO?
- Disclaimer that will show every refresh of the page
- Using ACF Relationship field to set post type to draft or published status
- Providin exception to WordPress wp_nav_menu Custom CSS Classes
- Woocommerce My acount page
- How to use wp_get_attachment_image or wp_get_attachment_image_src instead of $instance[‘single_feature_image_uri’]
- How can i avoid duplicate same post in wp?
- Child theme overirde template-tags in a theme built on underscores in inc/template-tags
- Custom meta box is not displaying value showing tag as empty
- Menu not updating for logged in users after redirect
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- Priority call methods – PHPMailer->addAddress(NULL)
- All categories options or All categories not Populating
- WordPress load javascript file if something… (after the page is loaded)
- Add class for the_post_thumbnail_caption()
- Getting page / post URL on publish and / or update
- Wrapping shortcode content in a span or link
- Allow BBPress participant role to trash topics
- Display Year and Month from custom field + Age Calculator
- Get author meta of all writers
- Hide the content before the more tag in the “single page”
- Replace TinyMCE with Custom Built Editor
- Particular meta tag – viewport – insertion when dealing with plugin
- how to loop through blog posts in php
- WP Fatal error: Call to undefined function get_template_directory_uri()
- Remove default Image Sizes
- Custom Admin Menu Report for Specific User ID
- how to create twitter card without plugin in wordpress website?