From 9f7f1dde6ea9d1272c4531bf255fe8f407d6ee6e Mon Sep 17 00:00:00 2001 From: Eric Stout Date: Thu, 26 Oct 2017 11:16:22 -0700 Subject: [PATCH] Fix file name, fix post object returning one post on tax endpoints --- better-wp-endpoints.php | 4 ++-- includes/{get_post_tax.php => get_posts_tax.php} | 11 ++++++++--- package-lock.json | 2 +- package.json | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) rename includes/{get_post_tax.php => get_posts_tax.php} (91%) diff --git a/better-wp-endpoints.php b/better-wp-endpoints.php index 625e29f..0608e8b 100644 --- a/better-wp-endpoints.php +++ b/better-wp-endpoints.php @@ -3,7 +3,7 @@ Plugin Name: Better WordPress Endpoints Plugin URI: https://github.com/factor1/better-wp-endpoints/ Description: Serves up slimmer WordPress Rest API endpoints, with some great enhancements. -Version: 0.1.8 +Version: 0.1.9 Author: Eric Stout, Factor1 Studios Author URI: https://factor1studios.com/ License: GPL3 @@ -105,7 +105,7 @@ private function includes() { include_once self::$plugin_dir . 'includes/get_tax.php'; // get custom taxonomies post endpoints - include_once self::$plugin_dir . 'includes/get_post_tax.php'; + include_once self::$plugin_dir . 'includes/get_posts_tax.php'; } } diff --git a/includes/get_post_tax.php b/includes/get_posts_tax.php similarity index 91% rename from includes/get_post_tax.php rename to includes/get_posts_tax.php index 8f1dc82..9dc5736 100644 --- a/includes/get_post_tax.php +++ b/includes/get_posts_tax.php @@ -3,7 +3,7 @@ * Get Posts by Taxonomy * * @param none - * @return object|null ACF object,
 * or null if none. + * @return endpoint returns a WordPress Rest API Endpoint * @since 0.1.8 */ @@ -56,11 +56,12 @@ function bwe_build_custom_tax_endpoint() { if( $query->have_posts() ){ // setup post object - $bwe_tax_post = new stdClass(); + $bwe_tax_posts = array(); while( $query->have_posts() ) { $query->the_post(); + $bwe_tax_post = new stdClass(); // get post data $bwe_tax_post->id = get_the_ID(); @@ -115,9 +116,13 @@ function bwe_build_custom_tax_endpoint() { $bwe_tax_post->media = false; } + // push the post to the main array + array_push($bwe_tax_posts, $bwe_tax_post); + } + // return the post array + return $bwe_tax_posts; - return $bwe_tax_post; } else { // if no post is found return array(); diff --git a/package-lock.json b/package-lock.json index c6db524..54e3711 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "better-wp-endpoints", - "version": "0.1.7", + "version": "0.1.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b5f6c47..d59c485 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "better-wp-endpoints", - "version": "0.1.8", + "version": "0.1.9", "description": "Serves up slimmer WordPress Rest API endpoints.", "main": "index.js", "scripts": {