WordPress.org

Forums

JSON API
Get taxonomy index (6 posts)

  1. caio1511
    Member
    Posted 1 year ago #

    Hi. I'm trying to build a method that returns an array containing the taxonomies I created. I tried modifying the "get_categories_index" method, figuring that it would be similar, since categories and taxonomies are quite similar. But no matter what I do, I can't get it working. Does anyone have any idea how to do that?

    Thanks. =)

    https://wordpress.org/plugins/json-api/

  2. newmesis
    Member
    Posted 11 months ago #

    could you fix it? I have the same problem

  3. caio1511
    Member
    Posted 11 months ago #

    Yes! I added this method:

    public function get_city_index() {
        $cities = get_terms('cities', array( 'hide_empty' => 0 ));
    	$cities_array[count($cities)];
    	$i = 0;
    	foreach($cities as $city){
    		$cities_array[$i] = $city->slug;
    		$i++;
    	}
    	return array(
          'count' => count($cities),
          'cities' => $cities_array
        );
      }

    to the core controller, where "cities" is my taxonomy. I know the code can be optimised and all, but that did it for me. I could have returned tons of stuff in that return array, but I needed only the count and the names, so it worked OK.

  4. newmesis
    Member
    Posted 11 months ago #

    my page is so,taxonomy would be my listing?

    http://miweb.cl/listing/local

  5. caio1511
    Member
    Posted 11 months ago #

    Yes, or whatever name you registered you taxonomy as.

  6. newmesis
    Member
    Posted 11 months ago #

    I can not get the category list, try this but I just devulve null
    http://wordpress.stackexchange.com/questions/28349/wordpress-json-api-taxonomy-index-method

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • JSON API
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic