Hook into save_post
, count the words, and update the post meta field.
Sample code, not tested:
add_action( 'save_post', 'wpse_73563_save_word_count', 10, 2 );
function wpse_73563_save_word_count( $post_ID, $post )
{
if ( ! current_user_can( 'edit_' . $_POST['post_type'], $post_ID ) )
{
return FALSE;
}
$count = t5_word_count( $post->post_content );
update_post_meta( $post_ID, '_word_count', ( 200 > $count ? 2 : 1 ) );
}
Related Posts:
- Update all posts automatically when using post_meta
- Better post meta efficiency?
- Change post format using custom field
- Sanitizing `wp_editor();` Values for Database, Edit, and Display
- What Is meta_id In wp_postmeta?
- How can I sort posts by the date and a custom meta field?
- Cannot retrieve a custom RSS field from posts
- Customize rel=canonical tag for single blog post
- How to I retrieve the ID from the Posts page?
- if in category but only with post meta
- Saving Post Data in Another Database
- Add multiple meta keys to a post at once
- saving/reading custom field value does not work – no value gets POSTed
- Post meta not working
- How do you update post date (year only) in a separate custom field?
- WP_Query sort by meta_value_num or date
- Creating Ordered Query using Meta_key
- How enter custom post meta or custom field on box post list archive page?
- How to check if post meta key exists or not in wordpress database
- How set featured posts using checkbox in post edit screen?
- Convert custom fields to post categories
- How to batch update post content with custom post meta value
- Setting post meta data to random value during post status transition / on publish
- Add custom field to all posts in specific category
- meta_box or custom_field as a second tinymce post-instance?
- Edit meta data does’t work with custom sql
- Create A Metabox For A Custom Field
- Paragraphs removed when using get_post_custom()?
- Does WP get all post_meta on POST page?
- Populating a page with content from post custom fields
- How to add a custom field after wp post
- Custom fields on a virtual page
- Get a custom field of all posts on current blog page
- Only display posts after current date
- How to permanently delete a post meta entry?
- How can I get a post field value using javascript?
- Automatic value for custom fields for posts
- Modify WP_Post before processing
- I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Get Meta Key Value While Saving Post
- How to display Common posts from specific Tag & Category with Shortcode
- Force the “Choose from the most used tags” meta box section to always be expanded
- Automatically add custom fields value to wordpress post
- Meta value does not save for scheduled posts
- MySql query to get posts with all meta and terms
- How to compare two posts including their meta fields on a scalable base?
- Add a custom meta box in the post options that loads some html code in the header
- Is it possible to paste a link without tags and make it directly a link in a post?
- Query Posts With Over 1000 Views
- Hooking into the post editing screen for an existing page only
- How to automate featured posts number? [duplicate]
- How to rate a post from Admin Side / Manually?
- How to save meta checkbox WordPress
- How to calculate the average of a post meta value(Numeric) of a specific author
- wpColorPicker – problem with implementation to post meta
- Update post meta within save_post action
- Add two custom fields as a default to the “new post” page.
- Custom permalink for each post
- Is there a way getting post fields using `transition_post_status`
- The loop starting at a certain ID
- Simple Custom Metabox Not Saving
- Why my meta boxes won’t show in front post page?
- Will multiple category descriptions effect my search engine optimization?
- Automate post update for all posts?
- What snippet do I need to type to show my ACF field show up on my theme?
- Is there a way to make [Table Of Content] plugin while not using revision data?
- Only the most recent post is showing on my category page (working on localhost, not live site)
- Post picker custom field on page
- Featured Images most often doesnt appear
- How to bulk Update URLs to new values?
- SQL DELETE multiple post_meta on single and multi-sites
- How to retrieve all meta data directly from the $post object? Such as $post->related_topics?
- How to get value of a selected option from select tag and use it in WP_query to filter posts?
- When working with a post, almost all wp_postmeta are deleted
- Check if user has avatar
- Auto populate custom fields by post date
- Best Way to detect unique posts in wp rest api
- ACF Relationship – Get Parent’s Post Object
- post_name is not stored until post is published… where should I store my slug until it goes live then?
- Add a meta to a post submited from a frontend form
- How can I set and update the the_date according to a custom field of the post
- How to retrieve a post by inputing the url in a custom field and displaying it on an options page
- Custom fields in normal posts
- Show posts between two Custom Fields date
- WP Query between posts custom fields [duplicate]
- How to get only current images of a post
- Ordering posts alphabetically by meta keys and title
- Run function after post is updated
- Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working
- Using Post ID and Page ID in same function
- Apply comment to different post (not the current post) [duplicate]
- Adding custom fields to the Quick Edit screen – puzzled about the column concept
- get_post_meta property of non object
- How do I insert a custom field in a user submitted post?
- How to make a local “scroll to ID” on post?
- If meta_key exists then don’t select this post?
- How to detect if an ACF custom-field is really in use?
- NewsPaper WP Theme – Additional Related Posts Filter by Time (divTag composer)
- Site ‘Categories’: save an admin global setting with post metadata [closed]