Closed pinkasey closed 7 years ago
Is there a reason not to integrate this change?
Bump
Bump
Bump .. This would really be beneficial to a lot of people using angular and wp rest api!
@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.
@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.
@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...
@pinkasey No need to make A pull request, the functionality is already built into Wordpress, no need for this plugin to alter anything.
@JonathanPort This is an issue with the underlying WordPress REST API.
Your snippet should work but didn't work for me
I wrote this pull request before WP REST API was published, so yes - i guess now it's redundant. (haven't checked yet myself)
It is now possible to query posts using wp-api, and have them ordered by menu_order, which is the order this plugin imposes