Wordpress - 获取页面/发布订单号(如果已设置)

Adr*_*scu 3 wordpress

有人知道如何在页面属性中插入ORDER编号吗?我只需要数字,如果没有设置,给我一个特定的数字(1,或任何我想要的)所有没有设置订单页码的页面.

谢谢!

jac*_*ier 6

我不确定你想要什么......

如果你想从帖子/页面中检索menu_order,你可以使用类似的东西

<?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();
?>
Run Code Online (Sandbox Code Playgroud)