hijiriworld / intuitive-custom-post-order

WordPress Plugin: Intuitive Custom Post Order
68 stars 34 forks source link

Issue #13 - Integrate with WP API #14

Closed pinkasey closed 7 years ago

pinkasey commented 8 years ago

It is now possible to query posts using wp-api, and have them ordered by menu_order, which is the order this plugin imposes

pinkasey commented 8 years ago

Is there a reason not to integrate this change?

pinkasey commented 8 years ago

Bump

pinkasey commented 8 years ago

Bump

JonathanPort commented 7 years ago

Bump .. This would really be beneficial to a lot of people using angular and wp rest api!

pinkasey commented 7 years ago

@jpwebdevelopment You are welcomed to download and use this plugin from my branch, I think this repository hasn't changed since I've branched.

For some reason, @hijiriworld doesn't seem to intend to merge this branch. I don't know why.

JonathanPort commented 7 years ago

@pinkasey

Since making that comment, I did discover that when making a custom post type, if you enable 'page attributes' for the post type, menu_order will then be available. Not sure if this can be done for the default post type but it probably can be hooked in. Perhaps that's why he's not committing it.

Edit:

From https://www.ddshosting.com/wordpress-enabling-page-attributes-posts-sort_order/

Add the following code snippet to your functions file:

add_action( 'admin_init', 'posts_order' );

function posts_order() 
{
    add_post_type_support( 'post', 'page-attributes' );
}

This will now enable you to use the “menu_order” option in your post query, like so :

array(
  'orderby' => 'menu_order',
  'order' => 'ASC'
);

WP REST API picks this up by default.

pinkasey commented 7 years ago

@jpwebdevelopment Thanks for commenting. I can't honestly say that I understand the difference, I'm very new to WordPress.

If you say your solution works better, and you've tested it - why don't you create a new pull request? If @hijiriworld would accept it, that would be great (please let me know if he does).

Also if you manage to get some other repository accept that fix - please let me know. It appears @hijiriworld is not very eager on accepting pull-requests...

JonathanPort commented 7 years ago

@pinkasey No need to make A pull request, the functionality is already built into Wordpress, no need for this plugin to alter anything.

dianjuar commented 6 years ago

@JonathanPort This is an issue with the underlying WordPress REST API.

Your snippet should work but didn't work for me

pinkasey commented 6 years ago

I wrote this pull request before WP REST API was published, so yes - i guess now it's redundant. (haven't checked yet myself)

dianjuar commented 6 years ago

@pinkasey you opened the issue #13 and the comment of @axelson works like a charm.

I invite to everyone that have this problem to use it.