Why don’t you try using the WP API?
You could then pull posts from a URL like this …
http://subdomain.example.com/wp-json/posts
You can also set custom post types to use the WP API and then access them also in a similar manner, you would need to add the following to your CPT args:
$args = array(
//...
'show_in_rest' => true,
'rest_base' => 'books-api',
'rest_controller_class' => 'WP_REST_Posts_Controller',
)
);
Take a look at: http://v2.wp-api.org/extending/custom-content-types/
You can even use WP_Query parameters like this:
http://subdomain.example.com/wp-json/posts?filter[posts_per_page]=2&filter[order]=ASC
You could use jQuery.getJSON() to get the data cross domain:
$.getJSON('http://subdomain.example.com/wp-json/posts', function (data) {
console.log(data);
});
Related Posts:
- How do I query for posts by partial meta key?
- WP_Query orderby date not working
- Display products from specific category in shop page
- meta_query where value is equal to given value
- Query by meta_key and order by meta_value_num return orderby date
- Sort posts by custom taxonomy name
- WP Query post meta value
- Understanding the use of wp_reset_query();
- How to exclude products by tag from woocommerce shop page?
- Filtering posts by custom field value not working
- wpdb get results doesn’t work with variable
- Query Ignoring ‘exclude’ Parameter?
- WordPress WP_Query orderby being overwritten
- Multiple meta queries but arrange by specific meta value order
- Custom pagination with WP_Query generating 404 error
- Query post with meta_query where date is not in future
- Apply CSS class to every second database record [closed]
- pre_get_posts order by not working
- merge two query arguments into one WP_Query call
- Adding a parameter to the default query
- Using WP_Query in “parse_query” or “pre_get_post” in Posts2Posts
- How do I change the order (ASC and DESC) in the following retrieval method using WP_Query?
- While creating Block Themes in WordPress, how can I query custom posts for an Archive view?
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- How to get all child pages in their parent page?
- How to display summary content from a Page (Not a Post) on another page
- Custom Search Not Consistent with Results
- how do we display all posts from a particular category in homepage?
- Display both standard posts in a specific category along with a custom post type in a single loop?
- Orderby is working with one query but not with other
- meta_query in WP_Query value is not accepting array
- Add capabilities via plugin for another plugin
- Two loops on archive page
- How to order posts by title after they have already been sorted by category
- How to query custom post types with mixed AND & OR statements for custom fields
- Custom post type archive pagination query issue
- WP Group posts by year(desc) > month(desc) > date(asc)
- Adding a tax_query to a WP_Query Object
- Check the Specific Meta Key IF its Meta Value is Empty then… (WP Post Meta Query)
- wp_query search not taking keywords with together for multiple words
- Adding a html class based on post count
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- How to Display Shortcode in the correct location, currently displaying before content after Page Title?
- Filtering posts by archive showing all years
- Apply filters to main query instead of creating new one?
- WP_Query returns different results from get_posts() [closed]
- How to pass query string vars between admin pages?
- WP_Query posts_per_page strange caching
- wp_query show all values
- Why having more than 10 clauses in WP_Query results in some outputs being dropped?
- mysql query order by
- Why do I have to use pre_get_posts with custom WP_Query to reset posts_per_page?
- WordPress dynamic AJAX query
- Custom Taxonomy Breaks Pages
- Using rewind_posts for displaying multiple categories
- Query to get last posts from authors of blog
- WP_QUERY tax_query not working
- How to get latest post excerpt from a specific category?
- Get all content on a “single page” site depending on language
- Get list of all Grandchild Pages
- get latest added term from taxonomy and insert into php variable
- Featured images loop for Orbit Slider
- WP_Query not returning correct result with meta_query parameter
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Custom query to retrieve oldest post and retrieve others with date interval
- Custom order revolution sliders post base slides as inserted in Specific Posts List field
- How to display Woocommerce products list by tag
- Display the search results like the original pages
- Pagination on archive.php not working?
- How to use jQuery validation to set the search bar to accept only a specific input?
- Unable to reset post data in wordpress custom query
- Check the product in the cart from which category is and show message
- How to filter on placeholder image
- Slow wp_posts and wp_postmeta query using Advance Custom Fields
- WP query for two post types how to order newest to oldest with two different meta fields?
- Get posts with any value in attribute
- WP_Query & shortcode : Return 3 articles from a category WordPress
- Order & Orderby clause not working with custom query
- WP_Query doesn’t works inside loop
- Pagination in WP_Query?
- Extending WP Query: Custom geolocation meta values work, but tax_query breaks
- WordPress: Cron locking and Queue
- Correct Way To Run Multiple Queries Sharing Some Base Data
- how to query for meta_value have array
- How to make the default WordPress search return borader results
- WP_Query shows all posts on single post pages
- Display Count of posts
- Show sticky post before other WP_Query
- List ALL posts within last week from current category on category page
- WP_Query on “property” in the options table
- Post OrderBy slow performance
- Dynamically name array in WordPress loop – add/get values
- Creating Custom Query
- WP_Query issues with argument posts_per_page
- Search (Custom Form, Custom Search Result)
- Hook to get the query result after listing posts
- Elementor custom query
- Query All Posts: Either Display Most Recent or One with Particular ACF Value Chosen
- Can I use WP_Query to find a post with a particular menu_order?
- Display only posts with thumbnails