Can you check the argument passed $post_id and see if it is returning the post id else define post globally along with $wpdb like global $wpdb, $post and use $post->ID instead of $post_id.
Related Posts:
- WordPress refuses to send mail, “…your host may have disabled the mail() function”
- How do I override the Message-ID header of wp_mail function?
- Why is my get_post_meta always empty
- Should I use wp_mail or PHP’s mail? [duplicate]
- Mail not sent when I set HTML headers
- Processing a subscription form with POST method?
- Different Webhost and using Google Mail server: Is there a better way than SMTP?
- how to remove metadata from the posts of my blog?
- PHP 8, AJAX mail form to function.php doesn’t work
- How to retrieve the sender email with wp_mail()?
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- Pass return-path additional parameter in wp_mail
- How to add post meta in while loop?
- Wp_mail doesnt work
- Word press – JSPDF – Sending PDF as attachment from wp_mail – Special characters
- How to modify default tags in wp_head()
- Send emails to individual subscribers when CPT post is deleted (trashed)
- Send email with PHP from html form on submit with the same script
- start_lvl Ignored in Custom walker_nav_menu
- What exactly does “Posts page” do in WordPress?
- Adding a search form inside a div
- Load custom field value into div with AJAX
- Blank on static home page?
- How to use a frontend URL with a Plugin
- How to display blog images using wordpress in existing project
- How to display a value from a radio button in the options menu in wordpress
- Custom image upload
- How to display recent posts on home page with custom HTML
- WordPress automatically adds tags when pasting code, how to stop it?
- how to increase custom post value by one most efficiently?
- How to Display Image Meta underneath EVERY image in EVERY post
- Slide in Panel WordPress Post
- Attaching a pdf to Contact Form 7 e-mail via functions.php [closed]
- Upload Image in a WordPress page using PHP
- Set a condition based on WooCommerce checkout city field while placing order
- My form action url is being prepended with a directory that does not exists
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- custom fields wordpress
- Why the JavaScript code is ignored from wp editor?
- Populate dropdown with Child Pages based on Parent Page chosen
- How to change redirection route to a php page for making it only accessible by logged-in members?
- Why Won’t My Inputs in a form with a Get method work together?
- How to get the value of input hidden html from text editor to custom page template?
- Show latest posts in a plain HTML website custom widget [closed]
- Can I get an email notification when media is uploaded to the media library?
- Hide HTML element (by class or ID) with PHP
- How to remove coupon dropdown feature
- Add html link in functions.php files of the theme
- PHP contact form not redirecting [closed]
- How to Schedule Cronjobs for start of every month and year
- Handling PHP/HTML inside the output of a shortcode function
- Get user custom field value on function.php
- Illegal string offset error in wordpress theme options textarea
- Update post meta – Custom field does not match meta-key
- Need help removing […] after excerpt
- Initial offset of number of posts in home page on the posts page
- Define category ID using get_post_meta
- WordPressUser Submission Form
- Time Delay a URL Redirect for Specific Page
- Cascading dropdown select search based on Parent Page & Child Page
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Order category posts by last word of custom field
- Background image no longer fits to screen now that project is in php files
- Adding HTML Code to Replace Text in PHP
- Shortcode in Shortcode/HTML Graphics and Pictures
- I can’t go to the page archive-{post_type}.php
- Use Search Term in html link and redirect
- Get and Update Most Meta Value as an array in HTML form
- Fix common misspellings/errors based on array of replacements
- HTML Formatting “single_term_title()”?
- How to center all text body in single.php at once?
- Collapsible menu on post sidebar only expands and does not collapse
- Unable to update the meta boxes with multiple fields
- How can I get my pagination loop to display the correct number of total pages?
- AMP version of e-commerce without plugin
- Creating Log-In Page for backend server
- user update profile for custom code
- Vertical Menu for one page only
- Bootstrap Carousel Indicators Won’t Cycle On Custom WordPress Theme
- Show post/page into div using function
- wordpress, Category ID
- Post from front end form to post_meta
- wp nav menu without label
- Pass the updated value of aid from form using ajax
- Show contact 7 form in popup
- If custom field doesn’t exist, or exists and it’s true show title?
- Arrange Category post manually when displayed
- how to manipulate HTML parameters using PHP conditions
- get_post_meta no longer working
- How to check “From Email” via WordPress before an email is sent
- Display wordpress post to static website in the footer
- Php echo into tag
- How to edit homepage in WordPress?
- WP_Query not returning results
- How do I link the side images?
- wp_mail vs mail functions and header arrays
- How to create a container in php then customise it in CSS
- How to create different templates for woocommerce single-product.php?
- How can I process a form submission from an HTTP POST request?
- Allow HTML in custom taxonomy description, and show it on front end