B
B
BushaevDenis2017-12-09 14:23:35
C++ / C#
BushaevDenis, 2017-12-09 14:23:35

How to get a post from another wordpress script?

I implement an ajax cart that connects to the database and gets the id of the goods in the current user's cart, so you need to get the title, thumbnail and other post data by Id.
As I understand it, you need to include files that form a request and define the concept of $post.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BushaevDenis, 2017-12-09
@BushaevDenis

// indicate that we need a minimum from WP
define('SHORTINIT', true);
// load the WordPress environment
// WP does some checks and only loads the essentials to connect to the database
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
global $wpdb;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question