Does anybody knows how to get the OR开发者_Go百科DER number inserted in page attributes? I need just the number and if is not set, to give me an specific number (1, or whatever I want) for all pages who don't have order page number set.
Thank you!
I'm not sure of what you want...
If you want to retrieve the menu_order from a post/page you can use something like
<?php
$id=1;
$default = 42;
get_post($id); //you can use any kind of query or use it in the loop
global $post;
if(empty($post->menu_order)) //if not set give the value you want
$post->menu_order = $default; //note that it won't update the value in the database
echo $post->menu_order;
wp_reset_query();
?>
Better use this way:
$my_menu_order = get_post_field( 'menu_order', $id, true );
where $id is the id of the post
精彩评论