Search code examples
wordpressmobile-application

Wordpress api plugin V2 + post order


I'm trying to build a mobile app using wordpress as a backend (see "wordpress hybrid client"), and i use wp api v2 to query for posts by category. It is crucial for me to control the order of the posts, so i've installed several wp  plugins that allow you to controll the order of the posts in the site (eg 'simple poßt order'). While these posts work wondefully when browsing the site, I dont see a way to integrate them with wp api v2 pluging - so i cant controll the order of posts in my application. Does anyone know how to do it? I'm considering writing a small plugin to bridge these two. But that might take me a long time since It's not my field.

Any suggestion or code snippet, no matther how obvious, is welcomed. I'm a noob to wordpress.


Solution

  • I've ended up solving this issue myself - I've found a 'post-order' pluging, intuitive-custom-post-order, modified it to support wp-api, and created a pull-request. For some unknown reason, the author does not reply to my-pull request.

    The fix was a very small modification, that can be done on any 'post-order' plugin, I believer:

    add_action( 'init', array( $this, 'register_page_attributes' ) );
    
    ...
    
    function register_page_attributes()
    {
        add_post_type_support( "post", "page-attributes" );
    }