get_all_page_ids() - WordPress 函数参考中文文档

返回介绍

get_all_page_ids()

发布于 2017-09-10 字数1650 浏览 928 评论 0

get_all_page_ids()

Get a list of page IDs.


描述


返回值

(array) List of page IDs.


源代码

File: wp-includes/post.php

function get_all_page_ids() {
	global $wpdb;

	$page_ids = wp_cache_get('all_page_ids', 'posts');
	if ( ! is_array( $page_ids ) ) {
		$page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'");
		wp_cache_add('all_page_ids', $page_ids, 'posts');
	}

	return $page_ids;
}

更新日志

Version 描述
2.0.0 Introduced.

相关函数

Uses

  • wp-includes/cache.php:
    wp_cache_get()
  • wp-includes/cache.php:
    wp_cache_add()
  • wp-includes/wp-db.php:
    wpdb::get_col()

User Contributed Notes

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

    Contributed by Codex

    Basic Example

    
    <?php
    $page_ids=get_all_page_ids();
    echo '<h3>My Page List :</h3>';
    foreach($page_ids as $page)
    {
    	echo '<br />'.get_the_title($page);
    }
    
    ?>
    

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!