Which action fire in front-end single post only

You can use the_content filter if you need to modify the content: add_filter( ‘the_content’, ‘cyb_content_filter_callback’ ); function cyb_content_filter_callback( $content ) { // Only for singular post views and for posts of main loop if( is_singular( ‘post’ ) && in_the_loop() ) { // modify $content here } return $content; } If you need an action that … Read more

save_post vs post_updated

OK, so let’s start with Codex: save_post is an action triggered whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email. The data for the post is stored in $_POST, $_GET or the global $post_data, depending on how the post was edited. … Read more

Scheduled event won’t fire

The cron arg usage looks weird. The insert id will return garbage by the time your function is called. By the same token, I believe better schedule it always, with the id argument, on insert, if this if for logging. Else you’ll be throttling your logs, basically. Lastly, are you sure that wp_mail() is working?

add_action(‘wp_ajax_[action name]’, myfunction) problem

There are only three explanations for why this isn’t working: First, something could be unregistering your action. That doesn’t seem very likely, though. Second, your code never runs in the ajax initialization. Third, the wp_ajax_my_function_call hook never runs. I wouldn’t worry about the possibility of the first. As far as the second, just make sure … Read more

How to get post ID in post_updated action hook?

You should be able to get the ID of the post through the $_POST variable. EDIT: Maybe you should try doing this on the save_post action, like so, but save_post sometimes runs on other instances (ie. Autosave Drafts), so you’ll want to do some more verifying. save_post will also return the ID as one of … Read more

Appending meta value onto post content in WordPress during save_post

The initial solution I’ve found is to tie a filter onto an action like wp_insert_post_data and extract other post information from the global $post object. // Tack our filter onto the wp_insert_post_data action add_filter( ‘wp_insert_post_data’, ‘my_appender’ ); function my_appender( $content ) { // Bring global $post into scope global $post; // Get meta value of … Read more