Categories
CMS Mastering Development Wordpress

Uploading a media item with the wp-json API to a specific path

I’m using the WP-JSON API to import all my posts from my live site to my development site. It’s working fine for posts, categories and authors, but when I upload my images, the API treats the files as having been uploaded that day (so for example, as we’re in June 2020, the files all go […]

Categories
CMS Mastering Development Wordpress

Extend Plugin that creates an endpoint for GET request to also accepts POST requests

I use a plugin called GiveWP for creating donation forms. The endpoint to see all the forms and data is /give-api/v1/forms/ The plugin has only built an endpoint to GET the data of created forms created from the dashboard, but I also need to be able to create new forms from the API via a […]

Categories
CMS Mastering Development Wordpress

How to get post with associated categories and tags names instead of ids with rest api?

When i retrieve a post from rest api i have the following response : { “id”: 2598, “date”: “2018-10-15T06:20:10”, “modified”: “2019-05-16T23:35:50”, “slug”: “lorem-ipsum-dolor-sit-amet-consectetur-adipisicing-elit”, “status”: “publish”, “type”: “post”, “link”: “http://www.mywebsite.org/2018/10/15/lorem-ipsum-dolor-sit-amet-consectetur-adipisicing-elit/”, “title”: { “rendered”: “Lorem ipsum dolor sit amet, consectetur adipisicing elit” }, “content”: { “rendered”: “<p>Eaque ipsa quae ab illo inventore veritatis et quasi. Eaque ipsa […]

Categories
CMS Mastering Development Wordpress

Gutenberg get core data – search

I am trying to query data in gutenberg like search in REST API. Following this documentation: https://developer.wordpress.org/block-editor/data/data-core/ I came up with this select: wp.data.select(“core”).getEntityRecords(“postType”, “page”, { status: [“publish”, “draft”], per_page: 10, search: “”, }); It suffers just one problem. It allows me query always only single post type but I need query both types – […]

Categories
CMS Mastering Development Wordpress

Why wc_get_products() returns empty array? [closed]

I want to retrieve WooCommerce products from inside of the front-page.php with the following code: $args = array(); $products = wc_get_products($args); So that I could could reiterate through them and output with a custom markup. However it returns an empty array, even though products do exist. When I use echo do_shortcode(”) inside the front-page.php, it […]

Categories
CMS Mastering Development Wordpress

How to trace/fix false $term->count, rogue term relationships?

On a page listing terms from my ‘source’ taxonomy, I loop through foreach term… foreach ($all_source_terms as $source_term) { // some stuff echo $source_term->count; } When I echo $source_term->count;, it outputs a count of posts for that term. In one term’s case, the output value is 2. But, on my taxonomy-source.php page (where I do […]

Categories
CMS Development Wordpress

Adding Amchart Interface to WordPress API

I’m using the amchart wordpress plugin and want to add support for it via the wp rest API. Here’s what I’ve done so far: in ../includes/setup.php (To $args array I’ve added: This will create the /wp/v2/charts route) ‘show_in_rest’ => true, ‘rest_base’ => ‘charts’ There are 4 fields in the plugin, and they are all stored […]

Categories
CMS Development Wordpress

get Woocommerce product format json for WP_Query

I’m building custom endpoint REST API and I need the same format wooCommerce gave for its post type ( product ), using the WP_Query() class. I tried the wc_Product_Query and for some reason not working with my tax_query, So instead, I start using the WordPress query WP_Query and works very well but the wooCommerce has […]

Categories
API CMS Development Wordpress

WP Rest API search a Custom Post Type by name

I am trying to add a simple search for a custom post type. My custom post type is “team”, I have already added “‘show_in_rest’ => true” when creating it and if I search for “/wp-json/wp/v2/team” I get the results. I would like to add a search like you can with regular posts, supposedly “/wp-json/wp/v2/team?search=john” should […]

Categories
Development JSON Swift

Decoding Nested JSON Elements (SwiftUI)

I am trying to parse the JSON data below into the structs that are shown. I am having a helluva time trying to figure out how to get at the “nested” elements, such as elements “title:”, “content:”, and “excerpt:”. Whenever the code runs, it barfs while parsing the nested elements. I’ve looked at the Apple […]