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
- PHP code in page template vs functions
- Apply class to every paragraph that holds image?
- username_exists() function can’t be access without logging in
- Inserting Gravity Form checkbox values into Advanced Custom Fields [closed]
- How do I create a drop down menu in a widget?
- Delete post revisions on post publish
- How to Append to the_excerpt() Function
- Why do filters/actions require an argument count?
- How do I list the_tags() into HTML data-attribute
- WordPress if (is_page) translation on certain page
- Check if term object is in array
- Highlight Current Tag in wp_tag_cloud
- Getting rid of role=”navigation” in the Home Page Pagination
- syntax issue on php 7.4
- How to remove the excerpt in the Dzonia Lite theme
- Get first URL from post content
- Setting custom canonical urls
- Trigger popup in a php if/else statement
- Setting a cookie upon specific URL visit
- get post based on category chosen in drop down – The ajax method
- How to output a PHP file values by shortcode?
- Extending the WP_Widget_Text class
- Set the background to a default image if there isn’t a specified “featured image”
- Logged in user ID as post ID
- WordPress Access allowed to fewer pages till user logs in
- different id for same element visual composer [closed]
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- Filtering a function’ output for a new continued function
- Shortcode to find and replace URL
- Deleting Certain terms from appearing on the front end as links
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- Shortcode to embed Edit Account form not working
- How to make jquery count down timer function manually editable
- Hierarchical taxonomy list with modificated term links
- Add value to new attribute inside WordPress menu items
- Please show me how to use an if/else statement in combination with wp_enqueue
- entire JS folder not loading in a WP theme
- Else/If Statement to Display Photo Descriptions
- Count foreach and display in menu php
- Correct code to use php in text widget
- Strip from or something better?
- Display additional page templates and a sidebar on plugin activation
- Stuck with sidebar registering
- Add a Metabox checkbox to the Page Edit screen of wp-admin , which only certain roles can see and Makes only certain roles able to Edit said page
- how to replace h1 entry title with h2 in category pages only
- How to unset a function from a action inside a class, that is called in another class
- Create a new account on site B with data from the purchase of site A
- Why is the current page loaded in the pop-up window and not the specified one?
- if get_post_meta is empty echo a placeholder or shortcode
- PHP multiple forms, same page, isset($_POST[]) not working?
- Woocommerce – if selected attribute term equals
- split 1 cart item into instock and back ordered
- post_exists stops working in a scheduled event
- Where do I implement this display of User Meta Data, and how to put it in a table?
- Add ID to output only for first option
- Display posts using post ID’s in an array
- Issue encountered while trying to keep website private
- Display text of price (minus 20%) on every product page in a sentence.
- Using get_theme_mod with checkbox to display content
- PHP: Why does my code work in index.php but not a widget?
- use system script advertising in wordpress multisite
- Styling admin page rows in order of importance (checkboxes)
- Insert wordpress tags below posts via functions.php
- Help with my first Metabox helper class
- Using existing widget code! [closed]
- Pagenav Not appearing on custom Template
- ISOTOPE – Missing/Invalid Arguement Get Terms
- My title is showing after the shortcode
- Load a Header in wordpress
- Trouble figuring out how to get my button to submit comment
- Adding multiple conditional tags in a function?
- Understanding responsive imagery
- How to get meta box labels?
- How do I stylize selected comments?
- “acf/load_field” Critical error upon saving/updating WooCommerce products [closed]
- How do I make a shortcode to display Dokan seller badge list?
- Function extension
- Developing a “fallback” for empty wp_query results based on post dates
- How can I process a form submission from an HTTP POST request?