Wordpress 获取页面id和信息 wordpress get current page id

If you're using pretty permalinks, get_query_var('page_id') won't work.

Instead, get the queried object ID from the global $wp_query:

 

// Since 3.1 - recommended!
$page_object = get_queried_object();
$page_id     = get_queried_object_id();


// "Dirty" pre 3.1
global $wp_query;

$page_object = $wp_query->get_queried_object();
$page_id     = $wp_query->get_queried_object_id();

 

来源:http://stackoverflow.com/questions/3127385/wordpress-get-the-page-id-outside-the-loop

 

 

 

你可能感兴趣的:(WP,/,Joomla!,/,Magento,/,Shopify,/,Drupal,/,Moodle,/,Zimbra)