WordPressを読む 27-1 /blog/wp-includes/query.php 1
2014/12/11
目次
- 1 /blog/wp-includes/query.php 1
- 2 関数 is_front_page()
- 3 関数 is_home()
- 4 関数 is_month()
- 5 関数 is_page()
- 6 関数 is_paged()
- 7 関数 is_preview()
- 8 関数 is_robots()
- 9 関数 is_search()
- 10 関数 is_single()
- 11 関数 is_singular()
- 12 関数 is_time()
- 13 関数 is_trackback()
- 14 関数 is_year()
- 15 関数 is_404()
- 16 関数 is_main_query()
- 17 関数 have_posts()
- 18 関数 in_the_loop()
- 19 関数 rewind_posts()
- 20 関数 the_post()
- 21 関数 have_comments()
- 22 関数 the_comment()
/blog/wp-includes/query.php 1
関数 is_front_page()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /** * Is the query for the front page of the site? * * This is for what is displayed at your site's main URL. * * Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_on_front'. * * If you set a static page for the front page of your site, this function will return * true when viewing that page. * * Otherwise the same as @see is_home() * * @see WP_Query::is_front_page() * @since 2.5.0 * @uses is_home() * @uses get_option() * * @return bool True, if front of site. */ function is_front_page() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_front_page(); } |
関数 is_home()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /** * Is the query for the blog homepage? * * This is the page which shows the time based blog content of your site. * * Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_for_posts'. * * If you set a static page for the front page of your site, this function will return * true only on the page you set as the "Posts page". * * @see is_front_page() * * @see WP_Query::is_home() * @since 1.5.0 * @uses $wp_query * * @return bool True if blog view homepage. */ function is_home() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_home(); } |
関数 is_month()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * Is the query for an existing month archive? * * @see WP_Query::is_month() * @since 1.5.0 * @uses $wp_query * * @return bool */ function is_month() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_month(); } |
関数 is_page()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /** * Is the query for an existing single page? * * If the $page parameter is specified, this function will additionally * check if the query is for one of the pages specified. * * @see is_single() * @see is_singular() * * @see WP_Query::is_page() * @since 1.5.0 * @uses $wp_query * * @param mixed $page Page ID, title, slug, or array of such. * @return bool */ function is_page( $page = '' ) { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_page( $page ); } |
関数 is_paged()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * Is the query for paged result and not for the first page? * * @see WP_Query::is_paged() * @since 1.5.0 * @uses $wp_query * * @return bool */ function is_paged() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_paged(); } |
関数 is_preview()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * Is the query for a post or page preview? * * @see WP_Query::is_preview() * @since 2.0.0 * @uses $wp_query * * @return bool */ function is_preview() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_preview(); } |
関数 is_robots()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * Is the query for the robots file? * * @see WP_Query::is_robots() * @since 2.1.0 * @uses $wp_query * * @return bool */ function is_robots() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_robots(); } |
関数 is_search()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * Is the query for a search? * * @see WP_Query::is_search() * @since 1.5.0 * @uses $wp_query * * @return bool */ function is_search() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_search(); } |
関数 is_single()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /** * Is the query for an existing single post? * * Works for any post type, except attachments and pages * * If the $post parameter is specified, this function will additionally * check if the query is for one of the Posts specified. * * @see is_page() * @see is_singular() * * @see WP_Query::is_single() * @since 1.5.0 * @uses $wp_query * * @param mixed $post Post ID, title, slug, or array of such. * @return bool */ function is_single( $post = '' ) { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_single( $post ); } |
関数 is_singular()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /** * Is the query for an existing single post of any post type (post, attachment, page, ... )? * * If the $post_types parameter is specified, this function will additionally * check if the query is for one of the Posts Types specified. * * @see is_page() * @see is_single() * * @see WP_Query::is_singular() * @since 1.5.0 * @uses $wp_query * * @param mixed $post_types Optional. Post Type or array of Post Types * @return bool */ function is_singular( $post_types = '' ) { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_singular( $post_types ); } |
関数 is_time()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * Is the query for a specific time? * * @see WP_Query::is_time() * @since 1.5.0 * @uses $wp_query * * @return bool */ function is_time() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_time(); } |
関数 is_trackback()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * Is the query for a trackback endpoint call? * * @see WP_Query::is_trackback() * @since 1.5.0 * @uses $wp_query * * @return bool */ function is_trackback() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_trackback(); } |
関数 is_year()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * Is the query for an existing year archive? * * @see WP_Query::is_year() * @since 1.5.0 * @uses $wp_query * * @return bool */ function is_year() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_year(); } |
関数 is_404()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * Is the query a 404 (returns no results)? * * @see WP_Query::is_404() * @since 1.5.0 * @uses $wp_query * * @return bool */ function is_404() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' ); return false; } return $wp_query->is_404(); } |
関数 is_main_query()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /** * Is the query the main query? * * @since 3.3.0 * * @return bool */ function is_main_query() { if ( 'pre_get_posts' === current_filter() ) { $message = sprintf( __( 'In <code>%1$s</code>, use the <code>%2$s</code> method, not the <code>%3$s</code> function. See %4$s.' ), 'pre_get_posts', 'WP_Query::is_main_query()', 'is_main_query()', __( 'http://codex.wordpress.org/Function_Reference/is_main_query' ) ); _doing_it_wrong( __FUNCTION__, $message, '3.7' ); } global $wp_query; return $wp_query->is_main_query(); } |
関数 have_posts()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /* * The Loop. Post loop control. */ /** * Whether current WordPress query has results to loop over. * * @see WP_Query::have_posts() * @since 1.5.0 * @uses $wp_query * * @return bool */ function have_posts() { global $wp_query; return $wp_query->have_posts(); } |
関数 in_the_loop()
1 2 3 4 5 6 7 8 9 10 11 12 13 | /** * Whether the caller is in the Loop. * * @since 2.0.0 * @uses $wp_query * * @return bool True if caller is within loop, false if loop hasn't started or ended. */ function in_the_loop() { global $wp_query; return $wp_query->in_the_loop; } |
関数 rewind_posts()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /** * Rewind the loop posts. * * @see WP_Query::rewind_posts() * @since 1.5.0 * @uses $wp_query * * @return null */ function rewind_posts() { global $wp_query; return $wp_query->rewind_posts(); } |
関数 the_post()
1 2 3 4 5 6 7 8 9 10 11 12 | /** * Iterate the post index in the loop. * * @see WP_Query::the_post() * @since 1.5.0 * @uses $wp_query */ function the_post() { global $wp_query; $wp_query->the_post(); } |
関数 have_comments()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * Comments loop. */ /** * Whether there are comments to loop over. * * @see WP_Query::have_comments() * @since 2.2.0 * @uses $wp_query * * @return bool */ function have_comments() { global $wp_query; return $wp_query->have_comments(); } |
関数 the_comment()
1 2 3 4 5 6 7 8 9 10 11 12 13 | /** * Iterate comment index in the comment loop. * * @see WP_Query::the_comment() * @since 2.2.0 * @uses $wp_query * * @return object */ function the_comment() { global $wp_query; return $wp_query->the_comment(); } |