something like this will work:
function record_hit_if_post(){
global $wp_query;
if($wp_query->is_single==1)
// single post's ID:
// $wp_query->post->ID;
}
add_filter('template_redirect', 'record_hit_if_post');
Related Posts:
- How can I make it so the Add New Post page has Visibility set to Private by default?
- Show Similar Post Titles ( Similar to Stack Exchange )
- How to add option box in “Edit Post” plugin API?
- How do I unlock a post programmatically?
- How To Ignore a Filter On Applying Filter the Content In a Function
- How to get posts by content?
- Publish Post After Click On A Link
- Action on post publish
- How use %like% in sql statement wordpress
- Adding Attachment Display Settings in custom media frame
- Execute a plugin only on post pages
- Display post lists in 2nd paragraph
- Redirect to another page using contact form 7? [closed]
- How to get all posts belongs to a user between a certain date
- Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
- Post status doesn’t update to ‘future’ every time?
- Delete data from custom table when deleting a post
- Plugin is creating posts twice
- How to get Recent Post From Each Category with Thumbnail?
- help intercepting save_post through plugin
- Is it possible to pin a post in second position from top
- Help to Create a Simple Plugin to make a post
- How to display the custom post related blog by category?
- WP Forms not displaying,becomming an fatal error
- How can I see $post object in frontend from functions.php?
- Allow members to create groups on my site
- add tags to wordpress post using REST API
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- WordPress Product Detail and catalog
- Is it possible to create duplicate post on other site (either push, on publish, or pull, periodically)?
- How can I get the Post ID and Post Type within a Must Use Plugin?
- Get content and send to 3rd party
- Displaying friend’s posts only
- Get page type to display content
- Capturing POST data
- Custom feed parameters / Template overriding
- Plugin to display text before a post
- warning wp session
- is_plugin_active function doesn’t exist
- How to call a plugin function from index.php
- Where can I find a schema of wordpress plugin core architecture?
- How Does WordPress Uninclude/Deactivate A Plugin?
- Disallow a user to post in certain categories
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- How can I add a custom meta value on file upload?
- Admin-ajax.php is dying “0” without processing function
- How do I register a stylesheet inside a WordPress widget?
- Add a Custom Permalink option in the Permalink Admin Screen?
- How to remove an Ajax action
- Has anyone used require.js for handling plugin scripts?
- publish_post plugin hook doesn’t always pass $post->post_content
- Multiple files in a plugin
- Let user subscribe to specific categories
- adding a new value to a serialized array in WP_option table
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- What is the best way to mimic a search query within a plugin
- Remove rewrite rules generated by plugin during deactivation
- Programatically download a plugin
- Do action only on certain front end pages?
- Call to a member function have_posts() on a non-object on normal loop
- Archive – same title for the first two posts
- Creating plugin using simple_html_dom parser?
- WordPress Gutenberg react make import of __experimentalUseInnerBlocksProps which is no more experimetal
- How to stop activating a plugin and show admin notice when dependent plugins minimum version is not met
- How can I make my metabox appear?
- Create shortcode to echo javascript
- Separate database for a wordpress plugin
- remove all submenus from plugin
- How to prevent plugins from sniffing/stealing other plugins’ options?
- Hook for page Request?
- How to render a template file using shortcode inside a plugin
- Does WordPress check for updates of a plugin via plugins root folder name?
- How do i ‘deactivate’ a plugin only on a certain page template?
- How to write a new file when new post has been published in WordPress
- Need to add/remove group of options and display them as rows
- How to deactivate my plugin upon deactivation of NextGen
- Paypal Framework
- WP Insert Post If user refreshes override new post
- Summary and Comments on Main landing Page
- Order by post_date does not work in Previous and Next post pagination
- Fatal error “Call to undefined function is_plugin_active” each time the plugin is activated
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- How to get the checkout form data from checkout page when place-order button is clicked
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- How to make WooCommerce multiple filter with custom meta fields
- Modify Plugin PHP Class in Child Theme – Correct Method
- Call function when save setting/option in custom admin page
- Plugin to Delete All Posts Monthly
- mailjet plugin – extend functionnalities and reuse api
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- Creating fields in the database
- How to block external download link access if visitor not referred from WP?
- Notifications Bar on home page only
- Distribute post content through several divs [closed]
- Does anyone have the Custom Post Permalinks plugin from John P. Bloch? [closed]
- contact form 7 captcha support anyother captcha plugin? [closed]
- How to create a “Most Popular” & “Latest” TAB in WordPress
- is_user_logged_in() undefined at shutdown in plugin context
- What are Seeds? [closed]
- Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode