We can do this by storing the value into postmeta when post is published first time.
function save_ispublished( $post_id ) {
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return;
$published_once = get_post_meta( $post_id, 'is_published', true );
// Check if 'is_published' meta value is empty.
if ( ! empty( $published_once ) ) {
$published_once="yes";
}
// store is_published value when first time published.
update_post_meta( $post_id, 'is_published', $published_once );
}
add_action( 'save_post', 'save_ispublished' );
you can check it by get the meta value.
$is_published = get_post_meta( $post_id, 'is_published', true );
if( $is_published == 'yes' ) {
/*
* Actions if post is already published atleast once.
*/
}
Hope this help !
Related Posts:
- How can I retrieve multiple get_post_meta values efficiently?
- How to batch update post content with custom post meta value
- What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
- Using radio button meta data from a custom meta box
- How to rename “Publish” metabox title in post screen
- Meta value does not save for scheduled posts
- Calling Different Custom Post Timestamps in a table
- How to I retrieve the ID from the Posts page?
- How to save meta checkbox WordPress
- Updating post meta for checkbox
- Adding a meta box to determine the sidebar [closed]
- Simple Custom Metabox Not Saving
- Bulk Post update_post_meta
- How to check if post meta key exists or not in wordpress database
- add action only on post publish – not update
- How to add category to: ‘wp-admin/post-new.php’?
- How to prevent posts from being published too close to each other?
- Code to make a post sticky
- Is it possible to Schedule Attachments in WordPress?
- How to allow hidden custom fields to be added from wp-admin/post.php?
- Elegant way to include only published posts with get_objects_in_term()?
- Can I force a metabox to be in one column?
- How to add a new tab to page editor
- Listen to Post action
- Export WordPress Posts and Meta Information in CSV format
- Delete duplicated wp_postmeta record
- WordPress plugin to publish to multiple remote WordPress blogs
- Post publish only hook?
- Publish pending article from front end with a button?
- How to add metabox for post of specific category
- How to add a “publish” link to the quick actions
- How to limit user to publish post per day and per role?
- Will a large postmeta table slow a site down?
- Update all posts automatically when using post_meta
- upload image in a meta box
- When a user creates a post (pending), send a confirmation link that allows them to publish
- Change slug with custom field
- In what sequence are the hooks fired when a post is “published”?
- Restrict the Number of Posts an Author can Publish (over time)?
- Add javascript when post is published
- Better post meta efficiency?
- featuring old articles without messing up with the archive
- Setting post meta data to random value during post status transition / on publish
- meta_box or custom_field as a second tinymce post-instance?
- Edit meta data does’t work with custom sql
- 1 column admin screen options – move submitdiv to bottom
- Publish posts only after the condition is met
- multicheck box for post metabox
- Hiding by default specific post status on backend list?
- Create A Metabox For A Custom Field
- Human Time Diff, change mins to minutes
- Change post format using custom field
- Have save_post write to database image meta [closed]
- Detect Post Type when publish_post is ran
- Does WP get all post_meta on POST page?
- How can I display a specific user’s first published post?
- Does WordPress remove draft status automatically?
- Sanitizing `wp_editor();` Values for Database, Edit, and Display
- Prevent post from being published if no category selected
- Exporting Data from WordPress into a flat table
- Send email to user that his post has been rejected
- Adding Multiple Values to a Post Meta Key
- Limit number of posts a user can make per minute?
- Save list from a custom meta box?
- Using Custom Posts with Metaboxes and Drop-downs
- Every possible way to get data (posts) from WordPress
- publish_post conflicts with save_post
- PHP Notice error (when on 404 page)
- What Is meta_id In wp_postmeta?
- Notification to Admin or Author upon new post [duplicate]
- What differences are there between a Privately Published post and a Draft post?
- Checking if a post with certain meta value exists
- How to run a function when post is edited or updated using publish post action?
- How can I create custom button in post.php
- How to permanently delete a post meta entry?
- Add custom field automatically (add_post_meta) with value based on number of words of article
- Automatic value for custom fields for posts
- How to generate numbers indistinguishable for the IDs of the posts
- Modify WP_Post before processing
- Understanding and using metaboxes in posts
- Save re-arranged draggable post items to wordpress database
- I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
- Change post_date to post_modified date on post template?
- count the total number of comments the user has received for his published posts
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Automatically Updating Publish Date Bug
- Dashboard :10 Last draft page and 10 last pending review page (metabox)
- How can I schedule a PAGE to go live at a future date/time?
- How to give capability (publish contributors posts) to author role?
- How can I sort posts by the date and a custom meta field?
- is there a way to show the the post title after the image?
- Get Meta Key Value While Saving Post
- Print a message if excerpt is empty after posts have been publish/update!
- Adding custom fields to bbpress reply form
- Check if checkbox is marked on publish/update post
- Force the “Choose from the most used tags” meta box section to always be expanded
- Decide user that can publish a post
- How to switch wordpress post status between publish and schedule in MySQL?
- Custom Posts Query and meta_query Sort Order
- Prevent scheduled post being published if date/time is past current date/time