Try using the $post parameter:
add_action( 'pending_to_publish', 'sa_ads_count' );
function sa_ads_count( $post )
{
// use the $post variable here, not the missing global.
}
Related Posts:
- Visual Studio SignTool.exe Not Found
- How can I set a draft page as parent without publishing?
- Display a post’s publish date from 2112
- Does blocking xmlrpc.php affect pinging update services like pingomatic
- I can’t preview post’s change once they are published
- How to access the post meta of a post that has just been published?
- How to programmatically create a connection with [Plugin: Posts 2 Posts] on cpt publish?
- Publish post when edit post form submitted with enter/return pressed on keyboard
- Access post meta just after publishing
- How to make scheduled post preview visible to anyone?
- Scheduled Posts and wp-cron – Why don’t scheduled posts publish if too old?
- Why does publish_{custom-post-type} fire on update?
- Show recent published posts
- Is there a way to know if a post has been published through XML-RPC?
- How to unpublish a page and still keep a draft?
- get_terms on save_post hook
- Save and Publish button not working after installing SSL
- Disable “preview changes” button
- Can we have private drafts?
- Can’t schedule post for another time
- publish_post called too early
- Custom save button shows ‘Are you sure you want to…’ dialog
- Calling Different Custom Post Timestamps in a table
- Get publish post link?
- Bulk update all posts from plugin settings screen
- Controlled publishing in WordPress
- Change the text of the publish button to Save
- Can’t publish custom post type – “You are not allowed to edit this post.”
- problem with publish date not always appearing [duplicate]
- Get only used meta_values
- What is happening to make my Update/Publish button disabled?
- What is the reason for the new_to_publish hook not working?
- After I publish a post where does it go
- Should you manually ping new WordPress posts?
- How can I tell if a post has been published at least once?
- Authors should not publish
- How to add custom status to quick edit
- I need to modify drafts using custom data from database and then publish it
- How to show or hide a post based on meta_value selection?
- i am making text changes on my page show in preview not on live site, why? [closed]
- Is WordPress “publish” atomic?
- How to move post process to background
- Meta field bulk editing no longer working in WP 6.0 [closed]
- How does redirect work when publish date changes and date in url changes?
- Gutenberg publish date datepicker
- How Google Indexer should only index published pages
- Bulk Post update_post_meta
- Publish and go to page [duplicate]
- Publish Post Action Not Working
- Is it normal for a scheduled post to say “Missed Schedule”
- Manage multiple wordpress installs (Best Practice)
- Access post meta just after publishing
- Publish post and create additional posts with same content
- Disable Facebook Comments Automatically On CPT
- update_post_meta() not working in bulk option
- Showing the next post’s title, even if it’s an unpublished post
- Force Publish Future (Scheduled) Posts Immediately [duplicate]
- Can’t publish posts, Jetpack won’t connect, empty notification emails to my inbox [closed]
- Duplicate post on publish
- How is it possible to use a very reduced version of WordPress?
- Problems in updating a self-developed plugin
- Order by optional meta key?
- Documentation for post meta
- update_post_meta() not working in save_post
- how to fire join query with post_meta
- Get a post_id where meta_value equals something in a serialized meta_value field
- WP_POSTMETA changes site crash
- meta_post_meta return value 1
- How can I sort homepage by a meta value?
- Meta Key Value in current-user-only loop
- Make metabox of custom post type fully autosave- and bulk-/quick-edit compatible
- Run a check for multiple meta key values
- running function during post save and adding variable to post meta
- Shortcode to show current post category with link
- Doubts about the use of metadata and how this can affect performance on WordPress
- Published site reverts without changes to theme
- update_post_meta not working in a loop
- Get draggable widgets on Edit Post page
- Default Custom Field Value Automatically Update
- Generate images to be associated for tag and category?
- Why does get_transient() always return string even if integer set?
- Author_meta ONLY if it exists
- Customize rel=canonical tag for single blog post
- run script on publish
- $post->post_meta not pulling any post in wordpress/php
- Update meta_value in wp_postmeta using API
- update_post_meta not working?
- Drag and Drop Metadata Menu Order
- Custom Query: query by post custom meta data
- update_post_meta not working well
- Post Thumbnail missing when using webp format while sharing
- Bulk Update Post Meta Values from Different Post via Rest Api
- Using Self Hosted Video URL With Custom Fields
- alt of attached image in post / pages
- Query postmeta values, and return multiple post_titles for common meta value
- Best way to check if a post with specific meta exists
- Storing values in Post Meta vs new tables
- Retrieving custom field as shortcode
- get_post_meta() doesn’t allow email
- Search for meta_query does not return any result if combined with title