1

I have installed Wordpress JSON APi plugin, the idea what I want to do is to retrieve all posts from a websites except a specific category for example with ID: 434.

I need all posts except from this category.

The query is like this example: www.example.com/?json=1&count=300

I have changed something in code but it removes the details of categories, not posts.

if ($category->id == 434 && $category->slug == 'archive') {
// Skip the 'archive' category
continue;
        }

How it is possible, please help me!!!

0
1

I found a solution. You have to go to the folder controllers/core.php and there you have to change the function get_recent_posts(). You have to add this code to remove categories that you don't want:

public function get_recent_posts() {
global $json_api;

// get all the categories from the database
        $cats = get_categories(); 

            // loop through the categries
            foreach ($cats as $cat) {
                // setup the cateogory ID
                $cat_id = $cat->term_id;

                // create a custom wordpress query
                query_posts("cat=-434,-22837,-13571,-1,-18,-17385");
                // start the wordpress loop!

                while (have_posts()) {
                $posts = $json_api->introspector->get_posts();  
                return $this->posts_result($posts);
                }
           } 

  }
1
  • Thanks for sharing the solution, please mark this as the accepted answer. Nov 3 '16 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.