- This topic has 19 replies, 4 voices, and was last updated 5 years, 11 months ago by
Jonathan.
-
AuthorPosts
-
March 6, 2019 at 11:53 am #830907
freeform1999
Hi, how can I BEST add ‘Menu Order’ to Posts?
I’m using Elementor Pro and it and other add-ons can order ‘post grids’, ‘post-carousels’ and ‘sliders’ in a defined category by ‘date’ or ‘menu order’… Dates are a pain to change (unless I’m missing the secret?) so I want to try ‘menu order’… but basic posts don’t have that field.
(Another option I’m going to look into is creating a custom field that sometimes can be used for post order too.
– I’ve also seen some mention of using Tom’s ‘WP Show Posts’ plugin: https://en-ca.wordpress.org/plugins/wp-show-posts/, though I briefly looked there it seems to do more than I need? And didn’t find info in my brief look about post ‘menu order’. )THX for any help!
RandMarch 6, 2019 at 12:16 pm #830924Leo
StaffCustomer SupportHi there,
What is menu order?
Can you provide an example?
March 6, 2019 at 12:29 pm #830933freeform1999
Hi Leo,
Pages have a ‘menu_order’ field seen in the editor but posts don’t (maybe some custom post types might?).Here is 1 explanation on how to enable it for Posts,
though I wanted to know what the GP aces would recommend for GP: https://wordpress.stackexchange.com/questions/91866/how-to-use-menu-order-field-for-postsI don’t understand them exactly yet but here are some other descriptions:
https://www.google.com/search?q=Add+Menu+Order+to+Posts&oq=Add+Menu+Order+to+PostsTHX for the help!!
March 6, 2019 at 4:37 pm #831107Tom
Lead DeveloperLead DeveloperHi there,
So you’re wanting to order your regular blog/archive posts by
menu_order?Not sure if this will work, but..
add_action( 'admin_init', function() { add_post_type_support( 'post', 'page-attributes' ); } ); add_action( 'pre_get_posts', function( $query ) { if ( ! is_admin() && $query->is_main_query() && ( $query->is_home() || $query->is_archive() ) ) { $query->set( 'orderby', 'menu_order' ); $query->set( 'order', 'ASC' ); } } );March 6, 2019 at 5:01 pm #831127freeform1999
Thx Tom…
Yes, I wanted to TRY using menu_order on posts..
because many widgets in Elementor have it as an order option (along with by date) on sliders and post grids etc.I just tried adding your php code above using Code Snippet but it’s getting an error on line 6 (the ‘if.. ‘ line). BUT oddly the error message says,
”
The code snippet you are trying to save produced a fatal error on line 7:
syntax error, unexpected ‘;’
“March 6, 2019 at 5:04 pm #831133Tom
Lead DeveloperLead DeveloperSorry about that. Can you try now?
March 6, 2019 at 5:12 pm #831142freeform1999
YAY!
March 6, 2019 at 5:15 pm #831143freeform1999
🙂 that worked.
THX TOM!!!!!!!
I’ll report back here IF this works with Elementor widgets as hoped…Now I just need to find a way to sort the post list by the order column I added via Admin Columns plug. :/
March 6, 2019 at 5:23 pm #831147Tom
Lead DeveloperLead DeveloperGlad I could help 🙂
March 7, 2019 at 11:03 am #832035freeform1999
I am SO happy!
This Posts ‘menu_order’ makes it such a breeze for my client or I to set the order of Post-grids, post-carousels, portfolios, galleries, sliders, etc! At least in Elementor.Not to be too greedy for more support (esp. since this is not firmly GP related) …but does anyone know a clean way for the ‘order’ column in the ‘Posts list’ to be clickable to sort the list by Order? (I made the column visible using the free Admin Columns plugin, the pro version can make it clickable but a bit pricey for just this 1 need.)
If the above is not possible another decent & simple option would be to set the initial sort order of the ‘Posts list’ to ‘menu_order’.
(EDIT!! Doh, it already is defaulting to ‘menu_order’!!)
THX!!March 7, 2019 at 3:52 pm #832268Tom
Lead DeveloperLead DeveloperIt would likely be pretty difficult to make that field editable from the list itself. You might be able to hire a developer to do it, but I’m not sure if that would be worth it if there’s a plugin that does it.
March 7, 2019 at 4:33 pm #832301freeform1999
Thx as usual Tom…
Yea, I’m fine just using ‘Quick Edit’ to change the order #.
Cheers!July 16, 2020 at 3:10 am #1365315Antar
Hello, All –
This is just what I was looking for too – but it doesn’t seem to work. The code Tom has provided does add a “Order” field to the post attributes – but every time I try to change it, the number resets to zero after updating.
Note, I am using Gutenberg – which may or may not be a factor.
This is a great shame as a simple way to order posts manually is completely missing from the WP toolkit.
Antar
July 16, 2020 at 4:35 am #1365407David
StaffCustomer SupportJuly 16, 2020 at 1:57 pm #1366086Jonathan
I really need a way to sort WooCommerce products by Menu Order. Is this possible? I don’t see the option in the Customizer.
-
AuthorPosts
- The topic ‘Add 'Menu Order' to Posts’ is closed to new replies.