We help IT Professionals succeed at work.
Get Started

Calling wp_delete_post() from a PHP script

steva
steva asked
on
177 Views
Last Modified: 2016-06-03
I have a simple, bare-bones PHP script, shown below, that deletes a WordPress post:
delete.jpg
Line 15 calls the WordPress wp_delete_post() routine to remove the page from WordPress. The code below that removes any images that were uploaded for the page.

The script is called by a $.post call that passes the page id to delete.

The problem I'm having is that PHP complains that wp_delete_post() is undefined. What do I need to declare at the top of my PHP script to expose it?

Thanks.
Comment
Watch Question
Don't talk to me.
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 2 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE