Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to create a Windows Store App using IdeaPress (https://github.com/ideanotion/ideapress/issues), which relies on the JSON API Plugin (http://wordpress.org/extend/plugins/json-api/other_notes/). Unfortunately requesting recent_posts returns just content up to the

<!--more--> 

tag. I'd like to display the whole post, though. Any ideas on how to do this? This is my json code: http://wp7app.de/api/get_recent_posts/?dev=1

share|improve this question
    
is this still unsolved? –  birgire Jun 10 '13 at 9:34
add comment

1 Answer

up vote 1 down vote accepted

You can try this to show the full post content only in the JSON API:

function remove_more_wpse_96740($content) {
    if(get_query_var('json')){
        global $post;
        $content = preg_replace('/<!--more(.*?)?-->/','',$post->post_content);
    }
    return $content;
}
add_filter('the_content', 'remove_more_wpse_96740',1);

by targeting the json query variable and remove the <!--more--> part of the post.

If you have a custom string like <!--more But wait, there's more! -->, it will also be removed.

This part of the plugin in /json-api/models/post.php:

  function set_content_value() {
    global $json_api;
    if ($json_api->include_value('content')) {
      $content = get_the_content($json_api->query->read_more);
      $content = apply_filters('the_content', $content);
      $content = str_replace(']]>', ']]&gt;', $content);
      $this->content = $content;
    } else {
      unset($this->content);
    }
  }

is fetching the content and the check for <!--more(.*?)?--> in the content takes place in the WordPress function get_the_content().

PS: Using the method above will disable <!--noteaser--> in the JSON API, but that should be alright since you want the full post content there.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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