There is a WordPress hook comment_post to retrieve recently added comment and to pass comment id to get_comment you will get the post id.
add_action( 'comment_post', 'show_message_function', 10, 2 ); function show_message_function( $comment_ID, $comment_approved ) { $comment_array = get_comment($comment_ID ); $comment_post_id = $comment_array->comment_post_ID; }
Related Posts:
- What is the correct way to use WordPress functions outside WordPress files?
- How to add product in woocommerce with php code [closed]
- What’s the best way to use the Featured Image for responsive web design?
- Hide php Notices in Dashboard
- How to correctly submit a search form and display the result in an independent page
- Show the most popular post per week
- Shortcode to insert
- What is the most efficient way to search users by their display name?
- Calling a method from functions.php on a click of a button
- How to change featured content to a different tag in WordPress Twenty Fourteen?
- Using Echo in ShortCode – Stuck
- Get used terms by an author as array of strings
- Two posts in same div – WP loop
- Compare two meta key values against each other inside the get_posts array?
- Multiple do_shortcode($content) within one shortcode
- WordPress menu deletes when trying to add a hook
- Making Quote Plugin more efficient
- Different database query in function.php using mysqli
- How to show only a certain part of the entry title?
- Create shortcodes within foreach loop (using array)
- Programmatically add and remove woocommerce product category
- allow subscribers to see private posts without plug in
- Get image’s size name from it’s dimension
- How to securely provide a $_POST var in WP_Query with PHP 7?
- If Query In Sidebar
- Unreadable pagination
- Is there any risk setting WordPress file permissions and FS method to ‘direct’ on localhost?
- wp_enqueue_scripts leads to error
- How can I get the values of my WordPress $wpdb query in Jquery?
- My page.php shows the index.php
- How create a Shortcode with hover and complex options
- WordPress SQL injection
- Plugin Generate Unexpected output during activation
- Function returns text instead of html [closed]
- How can I display a div ONLY if it is not a certain term page
- Next post link on a bootstrap button
- Echo title attribute php
- How to override url params with rewrite rules vars?
- how to serialize() mysql update data
- How to render a block from php template
- Output: “Array”
- How to add data to a custom field at the wp_users table?
- Calculate days between two custom field value dates
- Using rules in Posts
- How to make a cookie be on the whole site instead of being on a specific page/
- php – Plugin/theme relative PATH/URI
- Save the value of a wp_dropdown_pages
- Search only working on front page (index) , not working on other pages
- Live search from database table
- call a string/function from database
- Grabing default from cuztomizer php file instead of other php script
- Unset all main menu items except those with $menu_object->title == ‘x’
- Deleting records with AJAX, deleting records as I search
- Create ACF Checkbox to get all ACF Values from Parent Page
- How a HTML form can trigger a PHP function?
- Custom Login page, redirection and restrictions
- Display custom field value in woocommerce variable product via jQurey
- get orders of today’s date
- foreach not returning expected results
- Passing Current User ID into SQL statement
- Load WordPress core but with specific plugins
- Change user metadata on registration (show_admin_bar_front = false)
- Warning in WordPress for Declaration of SplitMenuWalker::walk($elements, $max_depth) [duplicate]
- How to output values from a loop into a javascript array
- Display child-page links in sidebar on both Parent Pages AND Child Pages
- Cron not sending wp-mail()
- custom post type column countdown
- Adding body class to html tag that already has language attrubutes?
- Creating wordpress user registration form
- Add missing alt tag to featured images for “storefront” theme
- what’s the syntax for if the image exists get the image?
- Clone the “proceed to cart” button and place it above checkout on the cart page, but only appear display size is 320px
- Load admin bar without wp_head or wp_footer [duplicate]
- Latest Post Thumbnail Alt Text Missing
- Getting most popular posts based on Facebook comments count
- WordPress get_post_meta issue
- Woocommerce Price Text
- Best way to define a database with product codes and back-end support?
- Display pages from specific page template
- If Elseif Query
- Querying multiple meta_keys in WordPress SQL query
- 3 domains, 1 wordpress install, redirecting and changing domains on live site
- How can I print out a single stylesheet or javascript link?
- Cannot Upload Custom Header Image into WordPress Dashboard
- wordpress featured image
- Generating a number based on post ID
- Add comma between variables [closed]
- Ajax Load More or View More functionality for woocommerce category layout by template overriding
- echo vs output variable [closed]
- Disable Typed Parameters for JavaScript in PhpStorm? [closed]
- Properly process a custom WP REST API request (Authenticate, Authorize + Validate)?
- Losing Session ID and sessionStorage when navigating to other domains on Multisite
- Contact form with dynamic dropdown and filter
- REST API custom endpoints for metaboxes
- Add default block css when the block has been added with php?
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- How to sort search result by post_title, then by post_content
- Custom Admin Menu Report for Specific User ID
- how can i link threejs in my functions.php file in understrap theme
- WordPress / PHP: Check if column has value and then check if value in array