339 reputation
419
bio website dmaggio.carbonmade.com
location
age
visits member for 3 years, 11 months
seen Aug 24 at 16:38

Aug
11
comment Automatically set page order on create page
Mind if update your answer with the fixes?
Aug
9
comment Automatically set page order on create page
Oh, and by the way, I think you should use the commented query instead, which uses ORDER BY menu_order, since I am looking for the highest value (with the addition of the post_status, of course). That query should be the correct one.
Aug
9
accepted Automatically set page order on create page
Aug
9
comment Automatically set page order on create page
Okay, your code with the above fixes seems to work. However, the process runs on every update of the page, thus moving any updated page to the last order. So I added a condition within the function to set the page order ONLY if it is not already set: if ( $post->menu_order === 0 ) {}
Aug
9
comment Automatically set page order on create page
I think I found the solution to the blank page issue: infinite loop. In your case, anyway, the publish_page action should be removed and then re-added. With this fix, along with @bonger's **query**, the overall code is working in the right direction... Still testing, though.
Aug
9
comment Automatically set page order on create page
This works really well. One addition, though, I think the $result should be offset by one so it would be a new unique number and in the last page order. Eg. $ret['menu_order'] = ++$result;
Aug
9
comment Automatically set page order on create page
I think menu_order is shared between the different types of posts, including nav menu items even. @bonger's query seems to be better targeted. Also, with your code, publishing the page seems to take ages and then leads to a blank page.
Aug
3
comment Check if current page is the Blog Page
One use case to use if ( !is_front_page() && is_home() ), at least in my opinion, is if you are distributing a theme that has different layout style for the default homepage and the blog page.
Aug
3
revised Check if current page is the Blog Page
Improve solution
Aug
3
revised Check if current page is the Blog Page
fixed grammar
Aug
3
comment I put my blog on a subpage, how do I get page title?
I don't think it's hackish as I'm sure that's what it was meant for.
Aug
3
suggested suggested edit on Check if current page is the Blog Page
Aug
3
answered Check if current page is the Blog Page
Jul
27
asked Automatically set page order on create page
Jul
27
answered How can I automatically add child pages to pages in a WP menu?
Jul
26
answered How to get current-menu-item title as variable?
Jul
23
awarded  Citizen Patrol
Jul
23
awarded  Excavator
Jul
23
revised Automatically add simple custom buttons for print, Facebook share, & Tweet in Posts
Reworded to be relevant to Wordpress
Jul
22
suggested suggested edit on Automatically add simple custom buttons for print, Facebook share, & Tweet in Posts