Edit File by line
/home/barbar84/www/wp-inclu...
File: query.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WordPress Query API
[2] Fix | Delete
*
[3] Fix | Delete
* The query API attempts to get which part of WordPress the user is on. It
[4] Fix | Delete
* also provides functionality for getting URL query information.
[5] Fix | Delete
*
[6] Fix | Delete
* @link https://developer.wordpress.org/themes/basics/the-loop/ More information on The Loop.
[7] Fix | Delete
*
[8] Fix | Delete
* @package WordPress
[9] Fix | Delete
* @subpackage Query
[10] Fix | Delete
*/
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* Retrieves the value of a query variable in the WP_Query class.
[14] Fix | Delete
*
[15] Fix | Delete
* @since 1.5.0
[16] Fix | Delete
* @since 3.9.0 The `$default` argument was introduced.
[17] Fix | Delete
*
[18] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[19] Fix | Delete
*
[20] Fix | Delete
* @param string $var The variable key to retrieve.
[21] Fix | Delete
* @param mixed $default Optional. Value to return if the query variable is not set. Default empty.
[22] Fix | Delete
* @return mixed Contents of the query variable.
[23] Fix | Delete
*/
[24] Fix | Delete
function get_query_var( $var, $default = '' ) {
[25] Fix | Delete
global $wp_query;
[26] Fix | Delete
return $wp_query->get( $var, $default );
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Retrieves the currently queried object.
[31] Fix | Delete
*
[32] Fix | Delete
* Wrapper for WP_Query::get_queried_object().
[33] Fix | Delete
*
[34] Fix | Delete
* @since 3.1.0
[35] Fix | Delete
*
[36] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[37] Fix | Delete
*
[38] Fix | Delete
* @return WP_Term|WP_Post_Type|WP_Post|WP_User|null The queried object.
[39] Fix | Delete
*/
[40] Fix | Delete
function get_queried_object() {
[41] Fix | Delete
global $wp_query;
[42] Fix | Delete
return $wp_query->get_queried_object();
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Retrieves the ID of the currently queried object.
[47] Fix | Delete
*
[48] Fix | Delete
* Wrapper for WP_Query::get_queried_object_id().
[49] Fix | Delete
*
[50] Fix | Delete
* @since 3.1.0
[51] Fix | Delete
*
[52] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[53] Fix | Delete
*
[54] Fix | Delete
* @return int ID of the queried object.
[55] Fix | Delete
*/
[56] Fix | Delete
function get_queried_object_id() {
[57] Fix | Delete
global $wp_query;
[58] Fix | Delete
return $wp_query->get_queried_object_id();
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Sets the value of a query variable in the WP_Query class.
[63] Fix | Delete
*
[64] Fix | Delete
* @since 2.2.0
[65] Fix | Delete
*
[66] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[67] Fix | Delete
*
[68] Fix | Delete
* @param string $var Query variable key.
[69] Fix | Delete
* @param mixed $value Query variable value.
[70] Fix | Delete
*/
[71] Fix | Delete
function set_query_var( $var, $value ) {
[72] Fix | Delete
global $wp_query;
[73] Fix | Delete
$wp_query->set( $var, $value );
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Sets up The Loop with query parameters.
[78] Fix | Delete
*
[79] Fix | Delete
* Note: This function will completely override the main query and isn't intended for use
[80] Fix | Delete
* by plugins or themes. Its overly-simplistic approach to modifying the main query can be
[81] Fix | Delete
* problematic and should be avoided wherever possible. In most cases, there are better,
[82] Fix | Delete
* more performant options for modifying the main query such as via the {@see 'pre_get_posts'}
[83] Fix | Delete
* action within WP_Query.
[84] Fix | Delete
*
[85] Fix | Delete
* This must not be used within the WordPress Loop.
[86] Fix | Delete
*
[87] Fix | Delete
* @since 1.5.0
[88] Fix | Delete
*
[89] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[90] Fix | Delete
*
[91] Fix | Delete
* @param array|string $query Array or string of WP_Query arguments.
[92] Fix | Delete
* @return WP_Post[]|int[] Array of post objects or post IDs.
[93] Fix | Delete
*/
[94] Fix | Delete
function query_posts( $query ) {
[95] Fix | Delete
$GLOBALS['wp_query'] = new WP_Query();
[96] Fix | Delete
return $GLOBALS['wp_query']->query( $query );
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Destroys the previous query and sets up a new query.
[101] Fix | Delete
*
[102] Fix | Delete
* This should be used after query_posts() and before another query_posts().
[103] Fix | Delete
* This will remove obscure bugs that occur when the previous WP_Query object
[104] Fix | Delete
* is not destroyed properly before another is set up.
[105] Fix | Delete
*
[106] Fix | Delete
* @since 2.3.0
[107] Fix | Delete
*
[108] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[109] Fix | Delete
* @global WP_Query $wp_the_query Copy of the global WP_Query instance created during wp_reset_query().
[110] Fix | Delete
*/
[111] Fix | Delete
function wp_reset_query() {
[112] Fix | Delete
$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
[113] Fix | Delete
wp_reset_postdata();
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* After looping through a separate query, this function restores
[118] Fix | Delete
* the $post global to the current post in the main query.
[119] Fix | Delete
*
[120] Fix | Delete
* @since 3.0.0
[121] Fix | Delete
*
[122] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[123] Fix | Delete
*/
[124] Fix | Delete
function wp_reset_postdata() {
[125] Fix | Delete
global $wp_query;
[126] Fix | Delete
[127] Fix | Delete
if ( isset( $wp_query ) ) {
[128] Fix | Delete
$wp_query->reset_postdata();
[129] Fix | Delete
}
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
/*
[133] Fix | Delete
* Query type checks.
[134] Fix | Delete
*/
[135] Fix | Delete
[136] Fix | Delete
/**
[137] Fix | Delete
* Determines whether the query is for an existing archive page.
[138] Fix | Delete
*
[139] Fix | Delete
* Archive pages include category, tag, author, date, custom post type,
[140] Fix | Delete
* and custom taxonomy based archives.
[141] Fix | Delete
*
[142] Fix | Delete
* For more information on this and similar theme functions, check out
[143] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[144] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[145] Fix | Delete
*
[146] Fix | Delete
* @since 1.5.0
[147] Fix | Delete
*
[148] Fix | Delete
* @see is_category()
[149] Fix | Delete
* @see is_tag()
[150] Fix | Delete
* @see is_author()
[151] Fix | Delete
* @see is_date()
[152] Fix | Delete
* @see is_post_type_archive()
[153] Fix | Delete
* @see is_tax()
[154] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[155] Fix | Delete
*
[156] Fix | Delete
* @return bool Whether the query is for an existing archive page.
[157] Fix | Delete
*/
[158] Fix | Delete
function is_archive() {
[159] Fix | Delete
global $wp_query;
[160] Fix | Delete
[161] Fix | Delete
if ( ! isset( $wp_query ) ) {
[162] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
[163] Fix | Delete
return false;
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
return $wp_query->is_archive();
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
/**
[170] Fix | Delete
* Determines whether the query is for an existing post type archive page.
[171] Fix | Delete
*
[172] Fix | Delete
* For more information on this and similar theme functions, check out
[173] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[174] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[175] Fix | Delete
*
[176] Fix | Delete
* @since 3.1.0
[177] Fix | Delete
*
[178] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[179] Fix | Delete
*
[180] Fix | Delete
* @param string|string[] $post_types Optional. Post type or array of posts types
[181] Fix | Delete
* to check against. Default empty.
[182] Fix | Delete
* @return bool Whether the query is for an existing post type archive page.
[183] Fix | Delete
*/
[184] Fix | Delete
function is_post_type_archive( $post_types = '' ) {
[185] Fix | Delete
global $wp_query;
[186] Fix | Delete
[187] Fix | Delete
if ( ! isset( $wp_query ) ) {
[188] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
[189] Fix | Delete
return false;
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
return $wp_query->is_post_type_archive( $post_types );
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
/**
[196] Fix | Delete
* Determines whether the query is for an existing attachment page.
[197] Fix | Delete
*
[198] Fix | Delete
* For more information on this and similar theme functions, check out
[199] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[200] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[201] Fix | Delete
*
[202] Fix | Delete
* @since 2.0.0
[203] Fix | Delete
*
[204] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[205] Fix | Delete
*
[206] Fix | Delete
* @param int|string|int[]|string[] $attachment Optional. Attachment ID, title, slug, or array of such
[207] Fix | Delete
* to check against. Default empty.
[208] Fix | Delete
* @return bool Whether the query is for an existing attachment page.
[209] Fix | Delete
*/
[210] Fix | Delete
function is_attachment( $attachment = '' ) {
[211] Fix | Delete
global $wp_query;
[212] Fix | Delete
[213] Fix | Delete
if ( ! isset( $wp_query ) ) {
[214] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
[215] Fix | Delete
return false;
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
return $wp_query->is_attachment( $attachment );
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
/**
[222] Fix | Delete
* Determines whether the query is for an existing author archive page.
[223] Fix | Delete
*
[224] Fix | Delete
* If the $author parameter is specified, this function will additionally
[225] Fix | Delete
* check if the query is for one of the authors specified.
[226] Fix | Delete
*
[227] Fix | Delete
* For more information on this and similar theme functions, check out
[228] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[229] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[230] Fix | Delete
*
[231] Fix | Delete
* @since 1.5.0
[232] Fix | Delete
*
[233] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[234] Fix | Delete
*
[235] Fix | Delete
* @param int|string|int[]|string[] $author Optional. User ID, nickname, nicename, or array of such
[236] Fix | Delete
* to check against. Default empty.
[237] Fix | Delete
* @return bool Whether the query is for an existing author archive page.
[238] Fix | Delete
*/
[239] Fix | Delete
function is_author( $author = '' ) {
[240] Fix | Delete
global $wp_query;
[241] Fix | Delete
[242] Fix | Delete
if ( ! isset( $wp_query ) ) {
[243] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
[244] Fix | Delete
return false;
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
return $wp_query->is_author( $author );
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
/**
[251] Fix | Delete
* Determines whether the query is for an existing category archive page.
[252] Fix | Delete
*
[253] Fix | Delete
* If the $category parameter is specified, this function will additionally
[254] Fix | Delete
* check if the query is for one of the categories specified.
[255] Fix | Delete
*
[256] Fix | Delete
* For more information on this and similar theme functions, check out
[257] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[258] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[259] Fix | Delete
*
[260] Fix | Delete
* @since 1.5.0
[261] Fix | Delete
*
[262] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[263] Fix | Delete
*
[264] Fix | Delete
* @param int|string|int[]|string[] $category Optional. Category ID, name, slug, or array of such
[265] Fix | Delete
* to check against. Default empty.
[266] Fix | Delete
* @return bool Whether the query is for an existing category archive page.
[267] Fix | Delete
*/
[268] Fix | Delete
function is_category( $category = '' ) {
[269] Fix | Delete
global $wp_query;
[270] Fix | Delete
[271] Fix | Delete
if ( ! isset( $wp_query ) ) {
[272] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
[273] Fix | Delete
return false;
[274] Fix | Delete
}
[275] Fix | Delete
[276] Fix | Delete
return $wp_query->is_category( $category );
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
/**
[280] Fix | Delete
* Determines whether the query is for an existing tag archive page.
[281] Fix | Delete
*
[282] Fix | Delete
* If the $tag parameter is specified, this function will additionally
[283] Fix | Delete
* check if the query is for one of the tags specified.
[284] Fix | Delete
*
[285] Fix | Delete
* For more information on this and similar theme functions, check out
[286] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[287] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[288] Fix | Delete
*
[289] Fix | Delete
* @since 2.3.0
[290] Fix | Delete
*
[291] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[292] Fix | Delete
*
[293] Fix | Delete
* @param int|string|int[]|string[] $tag Optional. Tag ID, name, slug, or array of such
[294] Fix | Delete
* to check against. Default empty.
[295] Fix | Delete
* @return bool Whether the query is for an existing tag archive page.
[296] Fix | Delete
*/
[297] Fix | Delete
function is_tag( $tag = '' ) {
[298] Fix | Delete
global $wp_query;
[299] Fix | Delete
[300] Fix | Delete
if ( ! isset( $wp_query ) ) {
[301] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
[302] Fix | Delete
return false;
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
return $wp_query->is_tag( $tag );
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
/**
[309] Fix | Delete
* Determines whether the query is for an existing custom taxonomy archive page.
[310] Fix | Delete
*
[311] Fix | Delete
* If the $taxonomy parameter is specified, this function will additionally
[312] Fix | Delete
* check if the query is for that specific $taxonomy.
[313] Fix | Delete
*
[314] Fix | Delete
* If the $term parameter is specified in addition to the $taxonomy parameter,
[315] Fix | Delete
* this function will additionally check if the query is for one of the terms
[316] Fix | Delete
* specified.
[317] Fix | Delete
*
[318] Fix | Delete
* For more information on this and similar theme functions, check out
[319] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[320] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[321] Fix | Delete
*
[322] Fix | Delete
* @since 2.5.0
[323] Fix | Delete
*
[324] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[325] Fix | Delete
*
[326] Fix | Delete
* @param string|string[] $taxonomy Optional. Taxonomy slug or slugs to check against.
[327] Fix | Delete
* Default empty.
[328] Fix | Delete
* @param int|string|int[]|string[] $term Optional. Term ID, name, slug, or array of such
[329] Fix | Delete
* to check against. Default empty.
[330] Fix | Delete
* @return bool Whether the query is for an existing custom taxonomy archive page.
[331] Fix | Delete
* True for custom taxonomy archive pages, false for built-in taxonomies
[332] Fix | Delete
* (category and tag archives).
[333] Fix | Delete
*/
[334] Fix | Delete
function is_tax( $taxonomy = '', $term = '' ) {
[335] Fix | Delete
global $wp_query;
[336] Fix | Delete
[337] Fix | Delete
if ( ! isset( $wp_query ) ) {
[338] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
[339] Fix | Delete
return false;
[340] Fix | Delete
}
[341] Fix | Delete
[342] Fix | Delete
return $wp_query->is_tax( $taxonomy, $term );
[343] Fix | Delete
}
[344] Fix | Delete
[345] Fix | Delete
/**
[346] Fix | Delete
* Determines whether the query is for an existing date archive.
[347] Fix | Delete
*
[348] Fix | Delete
* For more information on this and similar theme functions, check out
[349] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[350] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[351] Fix | Delete
*
[352] Fix | Delete
* @since 1.5.0
[353] Fix | Delete
*
[354] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[355] Fix | Delete
*
[356] Fix | Delete
* @return bool Whether the query is for an existing date archive.
[357] Fix | Delete
*/
[358] Fix | Delete
function is_date() {
[359] Fix | Delete
global $wp_query;
[360] Fix | Delete
[361] Fix | Delete
if ( ! isset( $wp_query ) ) {
[362] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
[363] Fix | Delete
return false;
[364] Fix | Delete
}
[365] Fix | Delete
[366] Fix | Delete
return $wp_query->is_date();
[367] Fix | Delete
}
[368] Fix | Delete
[369] Fix | Delete
/**
[370] Fix | Delete
* Determines whether the query is for an existing day archive.
[371] Fix | Delete
*
[372] Fix | Delete
* A conditional check to test whether the page is a date-based archive page displaying posts for the current day.
[373] Fix | Delete
*
[374] Fix | Delete
* For more information on this and similar theme functions, check out
[375] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[376] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[377] Fix | Delete
*
[378] Fix | Delete
* @since 1.5.0
[379] Fix | Delete
*
[380] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[381] Fix | Delete
*
[382] Fix | Delete
* @return bool Whether the query is for an existing day archive.
[383] Fix | Delete
*/
[384] Fix | Delete
function is_day() {
[385] Fix | Delete
global $wp_query;
[386] Fix | Delete
[387] Fix | Delete
if ( ! isset( $wp_query ) ) {
[388] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
[389] Fix | Delete
return false;
[390] Fix | Delete
}
[391] Fix | Delete
[392] Fix | Delete
return $wp_query->is_day();
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
/**
[396] Fix | Delete
* Determines whether the query is for a feed.
[397] Fix | Delete
*
[398] Fix | Delete
* For more information on this and similar theme functions, check out
[399] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[400] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[401] Fix | Delete
*
[402] Fix | Delete
* @since 1.5.0
[403] Fix | Delete
*
[404] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[405] Fix | Delete
*
[406] Fix | Delete
* @param string|string[] $feeds Optional. Feed type or array of feed types
[407] Fix | Delete
* to check against. Default empty.
[408] Fix | Delete
* @return bool Whether the query is for a feed.
[409] Fix | Delete
*/
[410] Fix | Delete
function is_feed( $feeds = '' ) {
[411] Fix | Delete
global $wp_query;
[412] Fix | Delete
[413] Fix | Delete
if ( ! isset( $wp_query ) ) {
[414] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
[415] Fix | Delete
return false;
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
return $wp_query->is_feed( $feeds );
[419] Fix | Delete
}
[420] Fix | Delete
[421] Fix | Delete
/**
[422] Fix | Delete
* Is the query for a comments feed?
[423] Fix | Delete
*
[424] Fix | Delete
* @since 3.0.0
[425] Fix | Delete
*
[426] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[427] Fix | Delete
*
[428] Fix | Delete
* @return bool Whether the query is for a comments feed.
[429] Fix | Delete
*/
[430] Fix | Delete
function is_comment_feed() {
[431] Fix | Delete
global $wp_query;
[432] Fix | Delete
[433] Fix | Delete
if ( ! isset( $wp_query ) ) {
[434] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
[435] Fix | Delete
return false;
[436] Fix | Delete
}
[437] Fix | Delete
[438] Fix | Delete
return $wp_query->is_comment_feed();
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
/**
[442] Fix | Delete
* Determines whether the query is for the front page of the site.
[443] Fix | Delete
*
[444] Fix | Delete
* This is for what is displayed at your site's main URL.
[445] Fix | Delete
*
[446] Fix | Delete
* Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_on_front'.
[447] Fix | Delete
*
[448] Fix | Delete
* If you set a static page for the front page of your site, this function will return
[449] Fix | Delete
* true when viewing that page.
[450] Fix | Delete
*
[451] Fix | Delete
* Otherwise the same as @see is_home()
[452] Fix | Delete
*
[453] Fix | Delete
* For more information on this and similar theme functions, check out
[454] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[455] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[456] Fix | Delete
*
[457] Fix | Delete
* @since 2.5.0
[458] Fix | Delete
*
[459] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[460] Fix | Delete
*
[461] Fix | Delete
* @return bool Whether the query is for the front page of the site.
[462] Fix | Delete
*/
[463] Fix | Delete
function is_front_page() {
[464] Fix | Delete
global $wp_query;
[465] Fix | Delete
[466] Fix | Delete
if ( ! isset( $wp_query ) ) {
[467] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
[468] Fix | Delete
return false;
[469] Fix | Delete
}
[470] Fix | Delete
[471] Fix | Delete
return $wp_query->is_front_page();
[472] Fix | Delete
}
[473] Fix | Delete
[474] Fix | Delete
/**
[475] Fix | Delete
* Determines whether the query is for the blog homepage.
[476] Fix | Delete
*
[477] Fix | Delete
* The blog homepage is the page that shows the time-based blog content of the site.
[478] Fix | Delete
*
[479] Fix | Delete
* is_home() is dependent on the site's "Front page displays" Reading Settings 'show_on_front'
[480] Fix | Delete
* and 'page_for_posts'.
[481] Fix | Delete
*
[482] Fix | Delete
* If a static page is set for the front page of the site, this function will return true only
[483] Fix | Delete
* on the page you set as the "Posts page".
[484] Fix | Delete
*
[485] Fix | Delete
* For more information on this and similar theme functions, check out
[486] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[487] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[488] Fix | Delete
*
[489] Fix | Delete
* @since 1.5.0
[490] Fix | Delete
*
[491] Fix | Delete
* @see is_front_page()
[492] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[493] Fix | Delete
*
[494] Fix | Delete
* @return bool Whether the query is for the blog homepage.
[495] Fix | Delete
*/
[496] Fix | Delete
function is_home() {
[497] Fix | Delete
global $wp_query;
[498] Fix | Delete
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function