0

I have a WordPress site running on an external server, I also have a local machine running a Python script.

I am looking for a way to trigger the python script from the WordPress install.

I know I can use the publish_post hook in WordPress to activate whenever a new post is published but I am unsure of the best way to link that to my local machine.

Anyone have an example of something similar being done? Would the WordPress Rest API be of any use here?

2 Answers 2

1

The only safe way I can think of is to "poll" the website from the local machine. It is impractical and insecure to access the local machine from the website.

You need to find a condition that changes and can be examined using the local script and use that to determine whether to take the necessary action or not. This could be another PHP script on the WordPress site giving you state information, or just a web call locally.

Sign up to request clarification or add additional context in comments.

Comments

1

WordPress wouldn't have access to your python script. But you python script has access to WordPress. It should periodically fetch the data from the WordPress installation URL / Blog page. And this will have to be scheduled periodically like every 4 hours if that's how frequently the posts are published.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.