You can use the_content
filter to modify content before it’s output.
function my_the_content_filter( $content ) {
// maybe limit to archive or single cpt display?
if( is_post_type_archive( 'your-cpt' )
|| is_singular( 'your-cpt' ) ){
global $post;
$meta = get_post_meta( $post->ID, 'some-key', true );
if( false === $meta ){
return $content . 'some extra content';
}
}
return $content;
}
add_filter( 'the_content', 'my_the_content_filter' );
Related Posts:
- How to filter content post only on save
- Is there a hook similar to “save_post” which only fires AFTER the post is completely published?
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- How can I edit post data before it is saved?
- How can I see all the actions attached to an “add_action” hook?
- How to only hook on Single.php after content?
- When can you get current page ID and initialize hooks right after?
- How Do I Use The WordPress Plugin Posts 2 Posts by Scribu?
- How can I log a user out of WordPress before the page loads?
- What is the ‘admin_action_’ . $_REQUEST[‘action’] hook used for?
- flush_rewrite_rules on save_post Does Not Work on First Post Save
- WordPress admin notice in plugin function
- Using the ‘draft_to_publish’ hook (post status transition)
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- Disallow a user to post in certain categories
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- Twillio How To Send SMS for Custom Post Type
- Use external link in the add sub menu
- Enable comments for post with comments meta box removed
- do_action and hook methods
- Custom Post Type causes Page Not Found
- How to register custom post types in a plugin?
- Is it possible to add an action to the currently running action?
- Is there an action that is called when a post is restored from the trash?
- Filter or action hook to insert content on admin pages before tag
- Is it possible to remove this action? (as it’s added just before it’s called)
- Action on post publish
- WordPress Plugin Boilerplate – add_action hook in static “activate” function
- How to prevent action in ajax request, when in admin side?
- template_redirect not being called when using ajax
- Can I use a method from an existing plugin as an action hook?
- Plugin custom Action Hook not working
- What are the benefit in adding hook in the init() hook?
- add action for displaying posts using a shortcode
- ‘wp_login’ action hook not working with wp-login.php file
- Where to hook my plugin’s action
- Is there a way to order posts and custom post types as one group?
- Accessing post’s meta data based on user’s click of a post
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- WordPress filter that hook after each action/filter hook
- Any hook for pre-plugin-update -either bulk or single plugin update
- Insert new user with form submit ‘init’ hook
- get_post_type on post.php
- How to get all of the activate_plugin action parameters?
- Matching Chapters to a Custom posts [closed]
- Calling plugin function inside custom plugin for onclick event
- Get Time Taken By Each Action Hook in WordPress
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- How to get post ID with hooks publish_post, new_to_publish, etc
- Redirect to another page using contact form 7? [closed]
- edit_user_profile and show_user_profile are not firing inside a class
- How to delete all trashed item in one-go
- Custom setup of wordpress comments that are displayed
- the_post hook is not firing for me
- Why do plugins often ask to add in to templates?
- Create a post builder skin in a plugin
- remove_action not removing add_action from constructor
- Plugin Development – Functions or Hooks?
- How to get menu location in wp_update_nav_menu hook
- How do I add some javascript validation to the admin interface form’s onsubmit?
- Hook for page Request?
- Are there action hooks for comments?
- How to use template_include hook with form submission?
- posts from multiple post types in one slider
- WooCommerce: after install hook
- How to remove a class function from a plugin by using remove_action()?
- Advanced WordPress plugin activation detection
- how to execute some code after a post is published in WordPress [duplicate]
- Add action to custom Function
- Show related posts based of current ACF field name in a single page post (a loop within loop)
- How to hook into action/filter call
- Is it possible to pin a post in second position from top
- Hook from plugin doesn’t fire up from external PHP script
- update_option_{$option} not working (do function after options are saved)
- Adding custom post category to categories widget
- How to display the custom post related blog by category?
- Callback hooked to post_updated firing on new posts as well
- save_post hook partly firing in update post
- WordPress hide post from custom post-type on a single page
- Hooking into the HTML header container
- Show post object of any page in frontend
- Is it possible to customize a wordpress post from outside dashboard(Something like site.com/post-type/post/?e=post_id)?
- Use action, filter, or hook to append HTML to WordPress plugin function
- Passing function into add_action always returns the first argument
- {status}_{post_type} does not run correctly?
- Identify if the_post hook is being called from the admin post list
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- wp_login_form() ignoring login_form action hook
- Passing a parameter to filter and action functions
- Run only on plug-in activation instead of wp_head
- Plugin Hook: Get posts
- WordPress list child pages of custom post type
- change output location of plugin function using a custom hook
- Insert data in custom table during new post creation
- OOP Plugin: Where should I place the action hooks in the class?
- add query string to all pages after user logged in
- How wordpress plugin hooks works? [duplicate]
- Hook automatic_updates_complete to autoupdate plugin
- How to export post tags from wordpress