Skip to content

Instantly share code, notes, and snippets.

@brasofilo
Created August 25, 2014 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brasofilo/22a17c0625a0bea6cf18 to your computer and use it in GitHub Desktop.
Save brasofilo/22a17c0625a0bea6cf18 to your computer and use it in GitHub Desktop.
Codex function reference to Apple Dictionary
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="utf-8"?>
<d:dictionary xmlns="http://www.w3.org/1999/xhtml" xmlns:d="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
<d:entry id="get_usernumposts" d:title="get usernumposts">
<d:index d:value="get usernumposts"/>
<h1>get usernumposts</h1>
<p>{{Deprecated}}
== Description ==
Returns the post count for the user whose ID is passed to it. Properties map directly to the wp_posts table in the database (see [[Database Description#Table:_wp_posts|Database Description]]).
== Replace With ==
[[Function_Reference/count_user_posts|count_user_posts()]]
== Usage ==
&lt;?php get_usernumposts(userid); ?&gt;
== Parameters ==
{{Parameter|$userid|integer|The ID of the user whose post count should be retrieved.}}
== Example ==
=== Default Usage ===
The call to &lt;tt&gt;get_usernumposts&lt;/tt&gt; returns the number of posts made by the user.
&lt;?php echo 'Posts made: ' . get_usernumposts(1); ?&gt;
&lt;div style=&quot;border:1px solid blue; width:50%; padding:10px&quot;&gt;Posts made: 143&lt;/div&gt;
== Change Log ==
* Since: 0.71
* Deprecated: 3.0.0
==Source File==
&lt;tt&gt;get usernumposts()&lt;/tt&gt; is located in {{Trac|wp-includes/deprecated.php}}. Formerly, {{Trac|wp-includes/user.php}}.
== Related ==
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="do_action" d:title="do action">
<d:index d:value="do action"/>
<h1>do action</h1>
<p>{{Languages|
{{en|Function_Reference/do_action}}
{{fax|Function_Reference/do_action}}
{{ru|Справочник по функциям/do_action}}
{{ja|関数リファレンス/do_action}}
}}
== Description ==
Execute functions hooked on a specific action hook.
This function invokes all functions attached to action hook &lt;tt&gt;$tag&lt;/tt&gt;. It is possible to create new action hooks by simply calling this function, specifying the name of the new hook using the &lt;tt&gt;$tag&lt;/tt&gt; parameter. You can pass extra arguments to the hooks, much like you can with &lt;tt&gt;[[Function_Reference/apply_filters | apply_filters()]]&lt;/tt&gt;. This function works similar to &lt;tt&gt;apply_filters()&lt;/tt&gt; with the exception that nothing is returned and only the functions or methods are called.
You can hook a function to an action hook using &lt;tt&gt;[[Function Reference/add_action|add_action()]]&lt;/tt&gt;.
== Usage ==
%%% &lt;?php do_action( $tag, $arg ); ?&gt; %%%
Multiple Arguments:
%%% &lt;?php do_action( $tag, $arg_a, $arg_b, $etc ); ?&gt; %%%
== Parameters ==
{{Parameter|$tag|string|The name of the hook you wish to execute.}}
{{Parameter|$arg|mixed|The list of arguments to send to this hook.|optional|Empty string}}
== Return Values ==
This function does not return a value.
== Example ==
&lt;pre&gt;
&lt;?php
# ======= Somewhere in a (mu-)plugin, theme or the core ======= #
/**
* You can have as many arguments as you want,
* but your callback function and the add_action call need to agree in number of arguments.
* Note: `add_action` above has 2 and 'i_am_hook' accepts 2.
* You will find action hooks like these in a lot of themes &amp; plugins and in many place @core
* @see: http://codex.wordpress.org/Plugin_API/Action_Reference
*/
# ======= e.g., inside your functions.php file ======= #
/**
* Define callback function
* Inside this function you can do whatever you can imagine
* with the variables that are loaded in the do_action() call above.
*/
function who_is_hook( $a, $b )
{
echo '&lt;code&gt;';
print_r( $a ); // `print_r` the array data inside the 1st argument
echo '&lt;/code&gt;';
echo '&lt;br /&gt;'.$b; // echo linebreak and value of 2nd argument
}
// then add it to the action hook, matching the defined number (2) of arguments in do_action
// see [http://codex.wordpress.org/Function_Reference/add_action] in the Codex
// add_action( $tag, $function_to_add, $priority, $accepted_args );
add_action( 'i_am_hook', 'who_is_hook', 10, 2 );
// Define the arguments for the action hook
$a = array(
'eye patch' =&gt; 'yes'
,'parrot' =&gt; true
,'wooden leg' =&gt; (int) 1
);
$b = 'And Hook said: &quot;I ate ice cream with Peter Pan.&quot;';
// Executes the action hook named 'i_am_hook'
do_action( 'i_am_hook', $a, $b );
# ======= output that you see in the browser ======= #
Array (
['eye patch'] =&gt; 'yes'
['parrot'] =&gt; true
['wooden leg'] =&gt; 1
)
And hook said: &quot;I ate ice cream with Peter Pan.&quot;
&lt;/pre&gt;
== Notes ==
* Uses: [[Global_Variables | global]] &lt;tt&gt;$wp_filter&lt;/tt&gt; - Stores all of the filters and actions.
* Uses: [[Global_Variables | global]] &lt;tt&gt;$wp_actions&lt;/tt&gt; - Increments the amount of times the action was triggered.
== Change Log ==
Since: [[Version_1.2|1.2.0]]
== Source File ==
&lt;tt&gt;do_action()&lt;/tt&gt; is located in {{Trac|wp-includes/plugin.php}}.
== Related ==
{{Action Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="timer_stop" d:title="timer stop">
<d:index d:value="timer stop"/>
<h1>timer stop</h1>
<p>== Description ==
This function returns the amount of time (in seconds) to generate the page.
== Usage ==
%%% &lt;?php timer_stop( $display = 0, $precision = 3 ); ?&gt; %%%
== Example ==
=== Usage ===
Determine length of time to render page with a precision of 3, 5 and 10 digits.
&lt;pre&gt;
&lt;?php echo('Seconds: '.timer_stop( 0 ).'&lt;br /&gt;'); ?&gt;
&lt;?php echo('Seconds: '.timer_stop( 0, 5 ).'&lt;br /&gt;'); ?&gt;
&lt;?php echo('Seconds: '.timer_stop( 0, 10 ).'&lt;br /&gt;'; ?&gt;
&lt;/pre&gt;
&lt;div style=&quot;border:1px solid blue; width:50%; padding:10px&quot;&gt;
Seconds: 0.815&lt;br /&gt;
Seconds: 0.81551&lt;br /&gt;
Seconds: 0.8155429363
&lt;/div&gt;
== Parameters ==
; display : (''integer'') Possible values: 0 or 1. Defaults to 0.
; precision : (''integer'') Possible values: 0 or 1. Defaults to 3.
[[Category:Functions]]
== Related Functions ==
[[timer_start]]
== Further Reading ==
For a comprehensive list of functions, take a look at the [http://codex.wordpress.org/Category:Functions category Functions]
Also, see [[Function_Reference]]</p>
</d:entry>
<d:entry id="get_approved_comments" d:title="get approved comments">
<d:index d:value="get approved comments"/>
<h1>get approved comments</h1>
<p>{{Languages|
{{en|Function Reference/get_approved_comments}}
{{it|Riferimento funzioni/get_approved_comments}}
}}
==Description==
Takes post ID and returns an array of objects that represent comments that have been submitted ''and'' approved.
== Usage ==
%%%&lt;?php
$comment_array = get_approved_comments($post_id);
?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|The ID of the post|required}}
== Return Values ==
{{Return|$comments|array|The approved comments}}
==Example==
In this example we will output a simple list of comment IDs and corresponding post IDs.
&lt;pre&gt;
&lt;?php
$postID = 1;
$comment_array = get_approved_comments($postID);
foreach($comment_array as $comment){
echo $comment-&gt;comment_ID.&quot; =&gt; &quot;.$comment-&gt;comment_post_ID.&quot;\n&quot;;
}
?&gt;
&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: [[Version 2.0|2.0.0]]
== Source File ==
current_user_can_for_blog() is located in {{Trac|wp-includes/capabilities.php}}
== Related ==
&amp;nbsp;
{{Tag Footer}}
{{Copyedit}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="add_option" d:title="add option">
<d:index d:value="add option"/>
<h1>add option</h1>
<p>{{Languages|
{{en|Function_Reference/add_option}}
{{ru|Справочник_по_функциям/add_option}}
}}
== Description ==
A safe way of adding a named option/value pair to the options database table. It does nothing if the option already exists. After the option is saved, it can be accessed with [[Function_Reference/get_option|get_option()]], changed with [[Function_Reference/update_option|update_option()]], and deleted with [[Function_Reference/delete_option|delete_option()]].
You do not need to serialize values. If the value needs to be serialized, then it will be serialized before it is inserted into the database. You can create options without values and then add values later.
Calling &lt;tt&gt;add_option&lt;/tt&gt; first checks whether the option has already been added, and returns false if an option with the same name exists. Next, it checks to make sure the option name is not one of the protected names ''alloptions'' or ''notoptions'', and dies with an error message if attempting to overwrite a protected option. If the option name is not protected, and does not already exist, the option will be created.
'''''Note:''''' ''&lt;tt&gt;add_option&lt;/tt&gt; uses &lt;tt&gt;get_option&lt;/tt&gt; to determine whether the option already exists, and since &lt;tt&gt;get_option&lt;/tt&gt; returns '''false''' as the default value, if you set an option to '''false''' in the database (e.g. via &lt;tt&gt;update_option($option_name, false)&lt;/tt&gt;), then a subsequent call to &lt;tt&gt;add_option&lt;/tt&gt; will change the value, because it will seem to &lt;tt&gt;add_option&lt;/tt&gt; that the option does '''not''' exist.''
=== vs. update_option() ===
If you are trying to ensure that a given option is created, use [[Function_Reference/update_option|update_option()]] instead, which bypasses the option name check and updates the option with the desired value whether or not it exists.
NB: you cannot specify autoload='no' if you use update_option(). If you need to specify autoload='no', and you are not sure whether the option already exists, then call delete_option() first before calling add_option().
== Usage ==
%%%&lt;?php add_option( $option, $value, $deprecated, $autoload ); ?&gt;%%%
== Parameters ==
{{Parameter|$option|string|Name of the option to be added. Must not exceed 64 characters. Use underscores to separate words, and do not use uppercase&mdash;this is going to be placed into the database.}}
{{Parameter|$value|mixed|Value for this option name. Limited to 2^32 bytes of data|optional|''Empty string''}}
{{Parameter|$deprecated|string|Deprecated in WordPress [[Version 2.3]].|optional|''Empty string''}}
{{Parameter|$autoload|string|Should this option be automatically loaded by the function [[Function Reference/wp_load_alloptions|wp_load_alloptions()]] (puts options into object cache on each page load)? Valid values: '''yes''' or '''no'''.|optional|yes}}
== Return Value ==
{{Return||boolean|False if option was not added and true if option was added}}
== Example ==
&lt;pre&gt;
&lt;?php add_option( 'myhack_extraction_length', '255', '', 'yes' ); ?&gt;
&lt;/pre&gt;
== Change Log ==
Since: [[Version 1.0|1.0.0]]
== Source File ==
&lt;tt&gt;add_option()&lt;/tt&gt; is located in {{Trac|wp-includes/option.php}}.
== Related ==
{{Option Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="delete_option" d:title="delete option">
<d:index d:value="delete option"/>
<h1>delete option</h1>
<p>{{Languages|
{{en|Function_Reference/delete_option}}
{{ru|Справочник_по_функциям/delete_option}}
}}
== Description ==
A safe way of removing a named option/value pair from the options database table.
== Usage ==
%%%&lt;?php delete_option( $option ); ?&gt;%%%
== Parameters ==
{{Parameter|$option|string|Name of the option to be deleted. A list of valid default options can be found at the [[Option Reference]].}}
== Return Value ==
{{Return||boolean|True, if option is successfully deleted. False on failure, or option does not exist.}}
== Example ==
=== Delete a single option ===
This will delete 'my_option' from the options table within your MySQL database.
&lt;pre&gt;
&lt;?php delete_option( 'my_option' ); ?&gt;
&lt;/pre&gt;
== Change Log ==
Since: [[Version 1.2|1.2.0]]
== Source File ==
&lt;code&gt;delete_option()&lt;/code&gt; is located in {{Trac|wp-includes/option.php}}.
== Related ==
{{Option Tags}}
{{Tag Footer}}
[[Category:Functions]]
{{Copyedit}}</p>
</d:entry>
<d:entry id="get_rss" d:title="get rss">
<d:index d:value="get rss"/>
<h1>get rss</h1>
<p>{{Deprecated}}
==Description==
Retrieves an RSS feed and parses it, then displays it as a list of links. The get_rss() function only outputs the list items, not the surrounding list tags itself.
Uses the [http://magpierss.sourceforge.net/ MagpieRSS and RSSCache] functions for parsing and automatic caching and the [http://sourceforge.net/projects/snoopy/ Snoopy HTTP client] for the actual retrieval.
Deprecated note: Switch to using [[Function_Reference/fetch_feed|fetch_feed]] instead.
==Usage==
%%%&lt;?php
require_once(ABSPATH . WPINC . '/rss-functions.php');
get_rss($uri, $num = 5);
?&gt;%%%
==Parameters==
{{Parameter|$uri|URI|The URI of the RSS feed you want to retrieve. The resulting parsed feed is returned, with the more interesting and useful bits in the items array.}}
{{Parameter|$num|integer|The number of items to display.|optional|5}}
[[Category:Functions]]
==Example==
The get_rss() function only outputs the list items, not the surrounding list tags itself. So, to get and display an ordered list of 5 links from an existing RSS feed:
%%%&lt;?php
require_once(ABSPATH . WPINC . '/rss-functions.php');
echo '&lt;ol&gt;';
get_rss('http://example.com/rss/feed/goes/here');
echo '&lt;/ol&gt;';
?&gt;%%%
==Output==
The output from the above example will look like the following:
%%%&lt;ol&gt;
&lt;li&gt;&lt;a href='LINK FROM FEED' title='DESCRIPTION FROM FEED'&gt;TITLE FROM FEED&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;
(repeat for number of links specified)
&lt;/ol&gt;%%%
==Related==
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="User:JHodgdon/Function_Reference_2.1" d:title="User:JHodgdon/Function Reference 2.1">
<d:index d:value="User:JHodgdon/Function Reference 2.1"/>
<h1>User:JHodgdon/Function Reference 2.1</h1>
<p>__NOTOC__
NOTE: This has now been moved to [[Function Reference]]... but I could not do it as a move....
The files of WordPress define many useful PHP functions. Some of the functions, known as [[Template Tags]], are defined especially for use in WordPress themes. There are also some functions related to actions and filters (the [[Plugin API]]), which are therefore used primarily for developing plugins. The rest are used to create the core WordPress functionality.
Many of the core WordPress functions may also be useful to plugin developers, and to a lesser extent, possibly theme developers as well. So, this article lists most of the core functions, by category; some of the function names are also links to more detailed documentation in separate pages. Each category also lists the files where its functions can be found (the files are in the &lt;tt&gt;wp-includes&lt;/tt&gt; directory of WordPress).
'''Note''': This reference applies to Version 2.1 of WordPress, and does not include functions that have been deprecated as of that version of WordPress. An incomplete page for the 2.0.x versions of WordPress can be found at [[Function Reference 2.0.x]].
'''Note''': Functions specifically for templates, which are listed in the [[Template Tags]] article, and contained in files &lt;tt&gt;wp-includes/*_template.php&lt;/tt&gt;, are not listed here.
&lt;div style=&quot;border:blue 1px solid;padding:10px; background: #E6CCFF&quot;&gt;
'''You can help make this page more complete!'''
Here are some things you can do to help:
* Add documentation to un-documented functions, by creating sub-pages or at least by adding short comments in the lists below. If you create a subpage for a function, please include information and examples of usage of that function, if possible, per the examples found in [[Template Tags]].
* List more functions here, following the category structure.
* Remove functions from the list, if you think they could not possibly be useful to plugin developers, or if they have been deprecated.
* Correct errors by moving functions to better categories where appropriate, and of course fixing typos. Note that it is OK for a function to appear in more than one category.
Read [[Contributing to WordPress]] to find out more about how you can contribute to the effort!
&lt;/div&gt;
&lt;!-- remove the DIV above after there's enough example content --&gt;
==Functions by category==
{| cellspacing=&quot;10&quot; width=&quot;100%&quot;
|- valign=&quot;top&quot;
|bgcolor=&quot;#fbfbef&quot; style=&quot;border:1px solid #ffc9c9;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Post, Page, and Attachment Functions ==
These functions are contained in &lt;tt&gt;formatting.php&lt;/tt&gt;, &lt;tt&gt;post.php&lt;/tt&gt;. See also [[Template Functions]].
* &lt;tt&gt;wp_trim_excerpt&lt;/tt&gt;
* &lt;tt&gt;get_attached_file&lt;/tt&gt;
* &lt;tt&gt;update_attached_file&lt;/tt&gt;
* &lt;tt&gt;get_children&lt;/tt&gt;
* &lt;tt&gt;get_extended&lt;/tt&gt;
* [[Function Reference/get_post|get_post]] - get information on a specific post
* [[Function Reference/get_post_mime_type|get_post_mime_type($ID = &quot;&quot;)]] - takes a post ID, returns its MIME type
* &lt;tt&gt;get_post_status&lt;/tt&gt;
* &lt;tt&gt;get_post_type&lt;/tt&gt;
* &lt;tt&gt;get_posts&lt;/tt&gt;
* &lt;tt&gt;add_post_meta&lt;/tt&gt;
* &lt;tt&gt;delete_post_meta&lt;/tt&gt;
* &lt;tt&gt;get_post_meta&lt;/tt&gt;
* &lt;tt&gt;update_post_meta&lt;/tt&gt;
* &lt;tt&gt;get_post_custom&lt;/tt&gt;
* &lt;tt&gt;get_post_custom_keys&lt;/tt&gt;
* &lt;tt&gt;get_post_custom_values&lt;/tt&gt;
* [[Function Reference/wp_delete_post|wp_delete_post($postid)]] - A generic function to delete a post in the post table
* &lt;tt&gt;get_post_categories&lt;/tt&gt;
* &lt;tt&gt;get_recent_posts&lt;/tt&gt;
* &lt;tt&gt;get_single_post&lt;/tt&gt;
* [[Function Reference/wp_insert_post|wp_insert_post($postarr=array())]] - A generic function for inserting data into the post table
* [[Function Reference/wp_update_post|wp_update_post($postarr=array())]] - A generic function to update data in the post table
* [[Function Reference/wp_publish_post|wp_publish_post($post_id)]] - Set a post's post_status to published. Calls &lt;tt&gt;wp_update_post&lt;/tt&gt;.
* &lt;tt&gt;wp_set_post_categories&lt;/tt&gt;
* &lt;tt&gt;get_all_page_ids&lt;/tt&gt;
* &lt;tt&gt;get_page&lt;/tt&gt;
* &lt;tt&gt;get_page_by_path&lt;/tt&gt;
* &lt;tt&gt;get_page_by_title&lt;/tt&gt;
* &lt;tt&gt;get_page_children&lt;/tt&gt;
* &lt;tt&gt;get_page_hierarchy&lt;/tt&gt;
* &lt;tt&gt;get_page_uri&lt;/tt&gt;
* &lt;tt&gt;get_pages&lt;/tt&gt;
* &lt;tt&gt;generate_page_uri_index&lt;/tt&gt;
* &lt;tt&gt;is_local_attachment&lt;/tt&gt;
* &lt;tt&gt;wp_insert_attachment&lt;/tt&gt;
* &lt;tt&gt;wp_delete_attachment&lt;/tt&gt;
* &lt;tt&gt;wp_get_attachment_metadata&lt;/tt&gt;
* &lt;tt&gt;wp_update_attachment_metadata&lt;/tt&gt;
* &lt;tt&gt;wp_get_attachment_url&lt;/tt&gt;
* &lt;tt&gt;wp_get_attachment_thumb_file&lt;/tt&gt;
* &lt;tt&gt;wp_get_attachment_thumb_url&lt;/tt&gt;
* &lt;tt&gt;wp_attachment_is_image&lt;/tt&gt;
* &lt;tt&gt;wp_mime_type_icon&lt;/tt&gt;
* &lt;tt&gt;wp_check_for_changed_slugs&lt;/tt&gt;
|valign=&quot;top&quot; bgcolor=&quot;#f0f0ff&quot; style=&quot;border:1px solid #c6c9ff;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Category Functions ==
These functions are contained in &lt;tt&gt;category.php&lt;/tt&gt;. See also [[Template Functions]].
* &lt;tt&gt;get_all_category_ids&lt;/tt&gt;
* &lt;tt&gt;get_categories&lt;/tt&gt;
* &lt;tt&gt;get_category&lt;/tt&gt;
* &lt;tt&gt;get_category_by_path&lt;/tt&gt;
* [[Function Reference/get_cat_ID|get_cat_ID($cat_name='General')]] - get category ID for given category name
* [[Function Reference/get_cat_name|get_cat_name($cat_id)]] - get category name for given ID
* &lt;tt&gt;cat_is_ancestor_of&lt;/tt&gt;
|- valign=&quot;top&quot;
|bgcolor=&quot;#fbfbef&quot; style=&quot;border:1px solid #ffc9c9;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
==User and Author Functions==
These functions are in &lt;tt&gt;user.php, pluggable.php, registration.php&lt;/tt&gt;. See also [[Template Functions]].
* &lt;tt&gt;get_profile&lt;/tt&gt;
* [[Function_Reference/get_usernumposts|get_usernumposts]] &amp;mdash; get post count for a specific user
* &lt;tt&gt;delete_usermeta&lt;/tt&gt;
* [[Function_Reference/get_usermeta|get_usermeta]] &amp;mdash; get meta data for a specific user
* &lt;tt&gt;update_usermeta&lt;/tt&gt;
* &lt;tt&gt;set_current_user&lt;/tt&gt;
* &lt;tt&gt;wp_set_current_user&lt;/tt&gt;
* &lt;tt&gt;wp_get_current_user&lt;/tt&gt;
* [[Function Reference/get_currentuserinfo|get_currentuserinfo]] &amp;mdash; get information on the current user
* [[Function Reference/get_userdata|get_userdata]] &amp;mdash; get information on any user
* &lt;tt&gt;get_userdatabylogin&lt;/tt&gt;
* &lt;tt&gt;wp_login&lt;/tt&gt;
* &lt;tt&gt;is_user_logged_in&lt;/tt&gt;
* &lt;tt&gt;auth_redirect&lt;/tt&gt;
* &lt;tt&gt;username_exists&lt;/tt&gt;
* &lt;tt&gt;email_exists&lt;/tt&gt;
* &lt;tt&gt;validate_username&lt;/tt&gt;
* &lt;tt&gt;wp_insert_user&lt;/tt&gt;
* &lt;tt&gt;wp_update_user&lt;/tt&gt;
* [[Function_Reference/wp_create_user|wp_create_user]] &amp;mdash; Create a user and add it to the user database.
|valign=&quot;top&quot; bgcolor=&quot;#f0f0ff&quot; style=&quot;border:1px solid #c6c9ff;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Feed Functions ==
These functions are in &lt;tt&gt;functions.php&lt;/tt&gt;, &lt;tt&gt;feed.php&lt;/tt&gt;, &lt;tt&gt;rss.php&lt;/tt&gt;
* [[Function_Reference/fetch_rss|fetch_rss]] -- retrieve an RSS feed from a URL with automatic caching (included in rss_functions.php)
* [[Function_Reference/wp_rss|wp_rss]] -- retrieve and display an RSS feed as an unordered list (included in rss_functions.php)
* [[Function_Reference/get_rss|get_rss]] -- retrieve and display an RSS feed as a list (ordering optional) (included in rss_functions.php)
* &lt;tt&gt;do_feed&lt;/tt&gt;
* &lt;tt&gt;do_feed_rdf&lt;/tt&gt;
* &lt;tt&gt;do_feed_rss&lt;/tt&gt;
* &lt;tt&gt;do_feed_rss2&lt;/tt&gt;
* &lt;tt&gt;do_feed_atom&lt;/tt&gt;
* &lt;tt&gt;get_bloginfo_rss&lt;/tt&gt;
* &lt;tt&gt;bloginfo_rss&lt;/tt&gt;
* &lt;tt&gt;get_the_title_rss&lt;/tt&gt;
* &lt;tt&gt;the_title_rss&lt;/tt&gt;
* &lt;tt&gt;the_content_rss&lt;/tt&gt;
* &lt;tt&gt;the_excerpt_rss&lt;/tt&gt;
* &lt;tt&gt;permalink_single_rss&lt;/tt&gt;
* &lt;tt&gt;comment_link&lt;/tt&gt;
* &lt;tt&gt;get_comment_author_rss&lt;/tt&gt;
* &lt;tt&gt;comment_author_rss&lt;/tt&gt;
* &lt;tt&gt;comment_text_rss&lt;/tt&gt;
* &lt;tt&gt;comments_rss_link&lt;/tt&gt;
* &lt;tt&gt;comments_rss&lt;/tt&gt;
* &lt;tt&gt;get_author_rss_link&lt;/tt&gt;
* &lt;tt&gt;get_category_rss_link&lt;/tt&gt;
* &lt;tt&gt;get_the_category_rss&lt;/tt&gt;
* &lt;tt&gt;the_category_rss&lt;/tt&gt;
* &lt;tt&gt;rss_enclosure&lt;/tt&gt;
|- valign=&quot;top&quot;
|bgcolor=&quot;#fbfbef&quot; style=&quot;border:1px solid #ffc9c9;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Comment, Ping, and Trackback Functions ==
These functions are found in &lt;tt&gt;comment.php&lt;/tt&gt;, &lt;tt&gt;functions.php&lt;/tt&gt;, &lt;tt&gt;post.php&lt;/tt&gt;. See also [[Template Functions]].
* &lt;tt&gt;check_comment&lt;/tt&gt;
* [[Function Reference/get_approved_comments|get_approved_comments]]
* &lt;tt&gt;get_comment&lt;/tt&gt;
* &lt;tt&gt;get_lastcommentmodified&lt;/tt&gt;
* &lt;tt&gt;sanitize_comment_cookies&lt;/tt&gt;
* &lt;tt&gt;wp_allow_comment&lt;/tt&gt;
* &lt;tt&gt;wp_delete_comment&lt;/tt&gt;
* &lt;tt&gt;wp_get_comment_status&lt;/tt&gt;
* &lt;tt&gt;wp_get_current_commenter&lt;/tt&gt;
* &lt;tt&gt;wp_insert_comment&lt;/tt&gt;
* &lt;tt&gt;wp_filter_comment&lt;/tt&gt;
* &lt;tt&gt;wp_throttle_comment_flood&lt;/tt&gt;
* &lt;tt&gt;wp_new_comment&lt;/tt&gt;
* &lt;tt&gt;wp_set_comment_status&lt;/tt&gt;
* &lt;tt&gt;wp_update_comment&lt;/tt&gt;
* &lt;tt&gt;wp_update_comment_count&lt;/tt&gt;
* &lt;tt&gt;discover_pingback_server_uri&lt;/tt&gt;
* &lt;tt&gt;do_all_pings&lt;/tt&gt;
* &lt;tt&gt;do_trackbacks&lt;/tt&gt;
* &lt;tt&gt;generic_ping&lt;/tt&gt;
* &lt;tt&gt;pingback&lt;/tt&gt;
* &lt;tt&gt;privacy_ping_filter&lt;/tt&gt;
* &lt;tt&gt;trackback&lt;/tt&gt;
* &lt;tt&gt;weblog_ping&lt;/tt&gt;
* &lt;tt&gt;do_enclose&lt;/tt&gt;
* &lt;tt&gt;add_ping&lt;/tt&gt;
* &lt;tt&gt;get_enclosed&lt;/tt&gt;
* &lt;tt&gt;get_pung&lt;/tt&gt;
* &lt;tt&gt;get_to_ping&lt;/tt&gt;
* &lt;tt&gt;trackback_url_list&lt;/tt&gt;
|valign=&quot;top&quot; bgcolor=&quot;#f0f0ff&quot; style=&quot;border:1px solid #c6c9ff;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Action, Filter, and Plugin Functions ==
These functions are contained in &lt;tt&gt;plugin.php&lt;/tt&gt;. See also [[Plugin API]].
* &lt;tt&gt;add_filter&lt;/tt&gt;
* &lt;tt&gt;apply_filters&lt;/tt&gt;
* &lt;tt&gt;merge_filters&lt;/tt&gt;
* &lt;tt&gt;remove_filter&lt;/tt&gt;
* [[Function Reference/add_action|add_action]]
* [[Function Reference/do_action|do_action]]
* &lt;tt&gt;did_action&lt;/tt&gt;
* &lt;tt&gt;do_action_ref_array&lt;/tt&gt;
* &lt;tt&gt;remove_action&lt;/tt&gt;
* &lt;tt&gt;plugin_basename&lt;/tt&gt;
* &lt;tt&gt;register_activation_hook&lt;/tt&gt;
* &lt;tt&gt;register_deactivation_hook&lt;/tt&gt;
|- valign=&quot;top&quot;
|bgcolor=&quot;#fbfbef&quot; style=&quot;border:1px solid #ffc9c9;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Theme-Related Functions ==
These functions are found in &lt;tt&gt;theme.php&lt;/tt&gt;.
* &lt;tt&gt;get_stylesheet&lt;/tt&gt;
* &lt;tt&gt;get_stylesheet_directory&lt;/tt&gt;
* &lt;tt&gt;get_stylesheet_directory_uri&lt;/tt&gt;
* &lt;tt&gt;get_stylesheet_uri&lt;/tt&gt;
* &lt;tt&gt;get_locale_stylesheet_uri&lt;/tt&gt;
* &lt;tt&gt;get_template&lt;/tt&gt;
* &lt;tt&gt;get_template_directory&lt;/tt&gt;
* &lt;tt&gt;get_template_directory_uri&lt;/tt&gt;
* [[Function Reference/get_theme_data|get_theme_data]]
* &lt;tt&gt;get_themes&lt;/tt&gt;
* &lt;tt&gt;get_theme&lt;/tt&gt;
* &lt;tt&gt;get_current_theme&lt;/tt&gt;
* &lt;tt&gt;get_theme_root&lt;/tt&gt;
* &lt;tt&gt;get_theme_root_uri&lt;/tt&gt;
* &lt;tt&gt;get_query_template&lt;/tt&gt;
* &lt;tt&gt;get_404_template&lt;/tt&gt;
* &lt;tt&gt;get_archive_template&lt;/tt&gt;
* &lt;tt&gt;get_author_template&lt;/tt&gt;
* &lt;tt&gt;get_category_template&lt;/tt&gt;
* &lt;tt&gt;get_date_template&lt;/tt&gt;
* &lt;tt&gt;get_home_template&lt;/tt&gt;
* &lt;tt&gt;get_page_template&lt;/tt&gt;
* &lt;tt&gt;get_paged_template&lt;/tt&gt;
* &lt;tt&gt;get_search_template&lt;/tt&gt;
* &lt;tt&gt;get_single_template&lt;/tt&gt;
* &lt;tt&gt;get_attachment_template&lt;/tt&gt;
* &lt;tt&gt;get_comments_popup_template&lt;/tt&gt;
* &lt;tt&gt;load_template&lt;/tt&gt;
* &lt;tt&gt;locale_stylesheet&lt;/tt&gt;
* &lt;tt&gt;validate_current_theme&lt;/tt&gt;
* &lt;tt&gt;get_theme_mod&lt;/tt&gt;
* &lt;tt&gt;set_theme_mod&lt;/tt&gt;
* &lt;tt&gt;get_header_textcolor&lt;/tt&gt;
* &lt;tt&gt;get_header_image&lt;/tt&gt;
* &lt;tt&gt;header_image&lt;/tt&gt;
* &lt;tt&gt;add_custom_image_header&lt;/tt&gt;
|valign=&quot;top&quot; bgcolor=&quot;#f0f0ff&quot; style=&quot;border:1px solid #c6c9ff;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Formatting Functions ==
These functions are contained in &lt;tt&gt;formatting.php&lt;/tt&gt;, &lt;tt&gt;functions.php&lt;/tt&gt;, &lt;tt&gt;kses.php&lt;/tt&gt;.
* [[Function_Reference/wptexturize|wptexturize( $text )]]
* [[Function_Reference/clean_pre|clean_pre( $text )]] - Returns the text without BR tags, and with P tags turned into line-breaks
* [[Function_Reference/wpautop|wpautop( $pee, $br = 1 )]] - Returns the text with HTML formatting for paragraphs
* [[Function_Reference/seems_utf8|seems_utf8($Str)]] - Returns true if given string seems like it is UTF8-encoded
* [[Function_Reference/wp_specialchars|wp_specialchars( $text, $quotes = 0 )]] - Like the PHP function htmlspecialchars except it doesn't double-encode HTML entities
* &lt;tt&gt;utf8_uri_encode&lt;/tt&gt;
* [[Function_Reference/remove_accents|remove_accents($string)]] - Returns a string with accents or umlauts without these
* &lt;tt&gt;sanitize_file_name&lt;/tt&gt;
* [[Function_Reference/sanitize_user|sanitize_user( $username, $strict = false )]] - Makes the username more machine-readable. Strict option for pure ASCII only.
* [[Function_Reference/sanitize_title|sanitize_title($title, $fallback_title = '')]]
* [[Function_Reference/sanitize_title_with_dashes|sanitize_title_with_dashes($title)]]
* [[Function_Reference/convert_chars|convert_chars($content, $flag = 'obsolete')]] - Translation of invalid Unicode references range to valid range
* &lt;tt&gt;funky_javascript_fix&lt;/tt&gt;
* [[Function_Reference/balanceTags|balanceTags($text, $is_comment = 0)]] - Balances Tags of string using a modified stack. Can be disabled by configuration.
* &lt;tt&gt;force_balance_tags&lt;/tt&gt;
* &lt;tt&gt;format_to_edit&lt;/tt&gt;
* &lt;tt&gt;format_to_post&lt;/tt&gt;
* [[Function_Reference/zeroise|zeroise($number,$threshold)]] - Adds leading zeros when necessary
* &lt;tt&gt;backslashit&lt;/tt&gt;
* &lt;tt&gt;trailingslashit&lt;/tt&gt;
* &lt;tt&gt;addslashes_gpc&lt;/tt&gt;
* &lt;tt&gt;stripslashes_deep&lt;/tt&gt;
* &lt;tt&gt;antispambot&lt;/tt&gt; - converts email address to anti-spam version
* &lt;tt&gt;make_clickable&lt;/tt&gt;
* &lt;tt&gt;wp_rel_nofollow&lt;/tt&gt;
* &lt;tt&gt;convert_smilies&lt;/tt&gt;
* &lt;tt&gt;is_email&lt;/tt&gt;
* &lt;tt&gt;wp_iso_descrambler&lt;/tt&gt;
* &lt;tt&gt;popuplinks&lt;/tt&gt; - converts a link into a popup link that will open in a different window
* &lt;tt&gt;sanitize_email&lt;/tt&gt;
* [[Function_Reference/ent2ncr|ent2ncr($text)]] - Returns HTML entity as its number representation.
* &lt;tt&gt;wp_richedit_pre&lt;/tt&gt;
* &lt;tt&gt;clean_url&lt;/tt&gt;
* &lt;tt&gt;htmlentities2&lt;/tt&gt;
* &lt;tt&gt;js_escape&lt;/tt&gt;
* &lt;tt&gt;attribute_escape&lt;/tt&gt;
* &lt;tt&gt;wp_make_link_relative&lt;/tt&gt; - makes an absolute link into a relative link
* &lt;tt&gt;add_magic_quotes&lt;/tt&gt;
* &lt;tt&gt;wp_kses&lt;/tt&gt;
* &lt;tt&gt;wp_kses_hook&lt;/tt&gt;
* &lt;tt&gt;wp_kses_version&lt;/tt&gt;
* &lt;tt&gt;wp_kses_split&lt;/tt&gt;
* &lt;tt&gt;wp_kses_split2&lt;/tt&gt;
* &lt;tt&gt;wp_kses_attr&lt;/tt&gt;
* &lt;tt&gt;wp_kses_hair&lt;/tt&gt;
* &lt;tt&gt;wp_kses_check_attr_val&lt;/tt&gt;
* &lt;tt&gt;wp_kses_bad_protocol&lt;/tt&gt;
* &lt;tt&gt;wp_kses_no_null&lt;/tt&gt;
* &lt;tt&gt;wp_kses_strip_slashes&lt;/tt&gt;
* &lt;tt&gt;wp_kses_array_lc&lt;/tt&gt;
* &lt;tt&gt;wp_kses_js_entities&lt;/tt&gt;
* &lt;tt&gt;wp_kses_html_error&lt;/tt&gt;
* &lt;tt&gt;wp_kses_bad_protocol_once&lt;/tt&gt;
* &lt;tt&gt;wp_kses_bad_protocol_once2&lt;/tt&gt;
* &lt;tt&gt;wp_kses_normalize_entities&lt;/tt&gt;
* &lt;tt&gt;wp_kses_normalize_entities2&lt;/tt&gt;
* &lt;tt&gt;wp_kses_decode_entities&lt;/tt&gt;
* &lt;tt&gt;wp_filter_kses&lt;/tt&gt;
* &lt;tt&gt;wp_filter_post_kses&lt;/tt&gt;
* &lt;tt&gt;wp_filter_nohtml_kses&lt;/tt&gt;
|- valign=&quot;top&quot;
|bgcolor=&quot;#fbfbef&quot; style=&quot;border:1px solid #ffc9c9;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Miscellanous Functions ==
These functions are contained in &lt;tt&gt;formatting.php&lt;/tt&gt;, &lt;tt&gt;functions.php&lt;/tt&gt;, &lt;tt&gt;bookmarks.php&lt;/tt&gt;, &lt;tt&gt;cron.php&lt;/tt&gt;, &lt;tt&gt;l10n.php&lt;/tt&gt;, &lt;tt&gt;user.php&lt;/tt&gt;, &lt;tt&gt;pluggable.php&lt;/tt&gt;
Time/Date Functions
* &lt;tt&gt;get_gmt_from_date&lt;/tt&gt;
* &lt;tt&gt;get_date_from_gmt&lt;/tt&gt;
* &lt;tt&gt;iso8601_timezone_to_offset&lt;/tt&gt;
* &lt;tt&gt;iso8601_to_datetime&lt;/tt&gt;
* &lt;tt&gt;human_time_diff&lt;/tt&gt;
* &lt;tt&gt;mysql2date&lt;/tt&gt;
* [[Function Reference/current time|current_time]]
* &lt;tt&gt;date_i18n&lt;/tt&gt;
* &lt;tt&gt;get_weekendstartend&lt;/tt&gt;
* &lt;tt&gt;get_lastpostdate&lt;/tt&gt;
* &lt;tt&gt;get_lastpostmodified&lt;/tt&gt;
* &lt;tt&gt;is_new_day&lt;/tt&gt;
Serialization
* &lt;tt&gt;maybe_serialize&lt;/tt&gt;
* &lt;tt&gt;maybe_unserialize&lt;/tt&gt;
* &lt;tt&gt;is_serialized&lt;/tt&gt;
* &lt;tt&gt;is_serialized_string&lt;/tt&gt;
Options
* &lt;tt&gt;get_option&lt;/tt&gt;
* &lt;tt&gt;form_option&lt;/tt&gt; -- like &lt;tt&gt;get_option&lt;/tt&gt;, but removes attributes from result&lt;/tt&gt;
* &lt;tt&gt;get_alloptions&lt;/tt&gt;
* &lt;tt&gt;update_option&lt;/tt&gt; -- given option name and new value, it makes a safe update of given option's database row.
* [[Function Reference/add option|add_option]]
* [[Function Reference/delete option|delete_option]] -- removes row of given option name from the options database table.
* &lt;tt&gt;get_user_option&lt;/tt&gt;
* &lt;tt&gt;update_user_option&lt;/tt&gt;
XMLRPC
* &lt;tt&gt;xmlrpc_getposttitle&lt;/tt&gt;
* &lt;tt&gt;xmlrpc_getpostcategory&lt;/tt&gt;
* &lt;tt&gt;xmlrpc_removepostdata&lt;/tt&gt;
* &lt;tt&gt;user_pass_ok&lt;/tt&gt;
Localization
See also [[Translating WordPress]].
* &lt;tt&gt;get_locale&lt;/tt&gt;
* &lt;tt&gt;__&lt;/tt&gt;
* &lt;tt&gt;_e&lt;/tt&gt;
* &lt;tt&gt;_ngettext&lt;/tt&gt;
* &lt;tt&gt;load_textdomain&lt;/tt&gt;
* &lt;tt&gt;load_default_textdomain&lt;/tt&gt;
* &lt;tt&gt;load_plugin_textdomain&lt;/tt&gt;
* &lt;tt&gt;load_theme_textdomain&lt;/tt&gt;
Cron (Scheduling)
* &lt;tt&gt;wp_schedule_single_event&lt;/tt&gt;
* &lt;tt&gt;wp_schedule_event&lt;/tt&gt;
* &lt;tt&gt;wp_reschedule_event&lt;/tt&gt;
* &lt;tt&gt;wp_unschedule_event&lt;/tt&gt;
* &lt;tt&gt;wp_clear_scheduled_hook&lt;/tt&gt;
* &lt;tt&gt;wp_next_scheduled&lt;/tt&gt;
* &lt;tt&gt;spawn_cron&lt;/tt&gt;
* &lt;tt&gt;wp_cron&lt;/tt&gt;
* &lt;tt&gt;wp_get_schedules&lt;/tt&gt;
* &lt;tt&gt;wp_get_schedule&lt;/tt&gt;
Miscellaneous
* &lt;tt&gt;gzip_compression&lt;/tt&gt;
* &lt;tt&gt;make_url_footnote&lt;/tt&gt;
* &lt;tt&gt;wp_get_http_headers&lt;/tt&gt;
* &lt;tt&gt;add_query_arg&lt;/tt&gt;
* &lt;tt&gt;remove_query_arg&lt;/tt&gt;
* &lt;tt&gt;wp_remote_fopen&lt;/tt&gt;
* &lt;tt&gt;wp&lt;/tt&gt;
* &lt;tt&gt;status_header&lt;/tt&gt;
* &lt;tt&gt;nocache_headers&lt;/tt&gt;
* &lt;tt&gt;cache_javascript_headers&lt;/tt&gt;
* &lt;tt&gt;get_num_queries&lt;/tt&gt;
* &lt;tt&gt;bool_from_yn&lt;/tt&gt; - converts a &quot;Y/N&quot; variable into boolean true/false
* &lt;tt&gt;do_robots&lt;/tt&gt;
* &lt;tt&gt;is_blog_installed&lt;/tt&gt;
* &lt;tt&gt;wp_nonce_url&lt;/tt&gt;
* &lt;tt&gt;wp_nonce_field&lt;/tt&gt;
* &lt;tt&gt;wp_referer_field&lt;/tt&gt;
* &lt;tt&gt;wp_original_referer_field&lt;/tt&gt;
* &lt;tt&gt;wp_get_referer&lt;/tt&gt;
* &lt;tt&gt;wp_get_original_referer&lt;/tt&gt;
* &lt;tt&gt;wp_mkdir_p&lt;/tt&gt;
* &lt;tt&gt;wp_upload_dir&lt;/tt&gt;
* &lt;tt&gt;wp_upload_bits&lt;/tt&gt;
* &lt;tt&gt;wp_check_filetype&lt;/tt&gt;
* &lt;tt&gt;wp_explain_nonce&lt;/tt&gt;
* &lt;tt&gt;wp_nonce_ays&lt;/tt&gt;
* &lt;tt&gt;wp_die&lt;/tt&gt;
* &lt;tt&gt;get_bookmark&lt;/tt&gt;
* &lt;tt&gt;get_bookmarks&lt;/tt&gt;
* &lt;tt&gt;wp_mail&lt;/tt&gt;
* &lt;tt&gt;check_admin_referer&lt;/tt&gt;
* &lt;tt&gt;check_ajax_referer&lt;/tt&gt;
* &lt;tt&gt;wp_redirect&lt;/tt&gt;
* &lt;tt&gt;wp_get_cookie_login&lt;/tt&gt;
* &lt;tt&gt;wp_setcookie&lt;/tt&gt;
* &lt;tt&gt;wp_clearcookie&lt;/tt&gt;
* &lt;tt&gt;wp_notify_postauthor&lt;/tt&gt;
* &lt;tt&gt;wp_notify_moderator&lt;/tt&gt;
* &lt;tt&gt;wp_new_user_notification&lt;/tt&gt;
* &lt;tt&gt;wp_verify_nonce&lt;/tt&gt;
* &lt;tt&gt;wp_create_nonce&lt;/tt&gt;
* &lt;tt&gt;wp_salt&lt;/tt&gt;
* &lt;tt&gt;wp_hash&lt;/tt&gt;
|valign=&quot;top&quot; bgcolor=&quot;#f0f0ff&quot; style=&quot;border:1px solid #c6c9ff;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Classes ==
The following classes were created by WordPress developers, and are found in files &lt;tt&gt;capabilities.php&lt;/tt&gt;,
&lt;tt&gt;classes.php&lt;/tt&gt;, &lt;tt&gt;class-snoopy.php&lt;/tt&gt;, &lt;tt&gt;locale.php&lt;/tt&gt;, &lt;tt&gt;query.php&lt;/tt&gt;, &lt;tt&gt;rewrite.php&lt;/tt&gt;, &lt;tt&gt;script-loader.php&lt;/tt&gt;, &lt;tt&gt;wp-db.php&lt;/tt&gt;:
* WP - general request handling
* WP_Ajax_Response - AJAX handling
* [[Function_Reference/WP_Cache|WP_Object_Cache]] (formerly &lt;tt&gt;WP_Cache&lt;/tt&gt;) - Object cache (and functions &lt;tt&gt;wp_cache_add, wp_cache_close, wp_cache_delete, wp_cache_flush, wp_cache_get, wp_cache_init, wp_cache_replace, wp_cache_set&lt;/tt&gt;)
* WP_Error - error handling (and function &lt;tt&gt;is_wp_error&lt;/tt&gt;)
* &lt;tt&gt;WP_Locale&lt;/tt&gt; - handles date and time locales
* [[Function_Reference/WP_Query|WP_Query]] - Request parsing and manipulation, posts fetching (with functions &lt;tt&gt;get_query_var, query_posts, have_posts, in_the_loop, rewind_posts, the_post, wp_old_slug_redirect, setup_postdata&lt;/tt&gt;, as well as the [[Conditional Tags]] &lt;tt&gt;is_*&lt;/tt&gt;)
* [[Function_Reference/WP_Rewrite|WP_Rewrite]] - Rewrite rules (and functions &lt;tt&gt;add_rewrite_rule, add_rewrite_tag, add_feed, add_rewrite_endpoint, url_to_postid&lt;/tt&gt;)
* WP_Roles, WP_Role, WP_User - Users and capabilities (and functions &lt;tt&gt;map_meta_cap, current_user_can, get_role, add_role, remove_role&lt;/tt&gt;)
* WP_Scripts - JavaScript loading (and functions &lt;tt&gt;wp_print_scripts, wp_register_script, wp_deregister_script, wp_enqueue_script&lt;/tt&gt;)
* Walker, Walker_Page, Walker_PageDropdown, Walker_Category, Walker_CategoryDropdown - Display tree-like data
* [[Function_Reference/wpdb Class|wpdb]] - Database interface
The following classes were created by outside developers, and are found in files &lt;tt&gt;class-IXR.php&lt;/tt&gt;, &lt;tt&gt;class-pop3.php&lt;/tt&gt;, &lt;tt&gt;class-snoopy.php&lt;/tt&gt;, &lt;tt&gt;gettext.php&lt;/tt&gt;, &lt;tt&gt;rss.php&lt;/tt&gt;, &lt;tt&gt;streams.php&lt;/tt&gt;:
* [http://scripts.incutio.com/xmlrpc/ IXR] - XML-RPC Classes, including IXR_Value, IXR_Message, IXR_Server, IXR_IntrospectionServer, IXR_Request, IXR_Client, IXR_ClientMulticall, IXR_Error, IXR_Date, IXR_Base64
* [http://sourceforge.net/projects/snoopy/ Snoopy] - HTTP client
* gettext_reader (part of [http://savannah.nongnu.org/projects/php-gettext/ PHP-gettext]) - Localization Class
* [http://magpierss.sourceforge.net/ RSS Classes (MagpieRSS and RSSCache)] (and functions &lt;tt&gt;fetch_rss, is_info, is_success, is_redirect, is_error, is_client_error, is_server_error, parse_w3cdtf, wp_rss, get_rss&lt;/tt&gt;)
* POP3: SquirrelMail wrapper
* &lt;tt&gt;StreamReader, StringReader, FileReader, CachedFileReader&lt;/tt&gt;
|}
[[Category:Advanced Topics]]
[[Category:Functions]]
[[Category:WordPress Development]]</p>
</d:entry>
<d:entry id="get_theme_data" d:title="get theme data">
<d:index d:value="get theme data"/>
<h1>get theme data</h1>
<p>{{Deprecated|new_function=wp_get_theme}}
== Description ==
Returns an array of information about a theme file.
This function has been replaced with [[Function Reference/wp_get_theme|wp_get_theme]] in WordPress 3.4
== Usage ==
%%% &lt;?php get_theme_data( $theme_filename ); ?&gt; %%%
Use [[Function Reference/wp_get_theme|wp_get_theme]] instead.
== Parameters ==
{{Parameter|$theme_filename|string|Path and filename of the theme's &lt;tt&gt;style.css&lt;/tt&gt;.}}
== Return values ==
;(array)
: The function returns an array containing the following keyed information:
; 'Name' : (''string'') The Themes name.
; 'Title' : (''string'') Either the Theme's name or a HTML fragment containg the Theme's name linked to the Theme's URI if the Theme's URI is defined.
; 'URI' : (''string'') The Themes URI.
; 'Description' : (''string'') A HTML fragment containg the Themes description after it has passed through [[Function_Reference/wptexturize|wptexturize]].
; 'AuthorURI' : (''string'') The Theme's Author URI.
; 'Template' : (''string'') The name of the parent Theme if one exists.
; 'Version' : (''string'') The Theme's version number.
; 'Status' : (''string'') the Theme's Status (defaults to 'publish')
; 'Tags' : (''string'') the Theme's Tags
; 'Author' : (''string'') Either the Author's name or a HTML fragment containing the Author's name linked to the Author's URI if the Author's URI is defined.
== Example ==
=== Usage ===
Get the information from the theme's style.css and display the Theme Name and Author.
&lt;pre&gt;
&lt;?php
/*
* Assign theme folder name that you want to get information.
* make sure theme exist in wp-content/themes/ folder.
*/
$theme_name = 'twentyeleven';
/*
* Do not use get_stylesheet_uri() as $theme_filename,
* it will result in PHP fopen error if allow_url_fopen is set to Off in php.ini,
* which is what most shared hosting does. You can use get_stylesheet_directory()
* or get_template_directory() though, because they return local paths.
*/
$theme_data = get_theme_data( get_theme_root() . '/' . $theme_name . '/style.css' );
echo $theme_data['Title'];
echo $theme_data['Author'];
?&gt;
&lt;/pre&gt;
== Source File ==
&lt;tt&gt;get_theme_data()&lt;/tt&gt; is located in {{Trac|wp-includes/deprecated.php}}.
== Related ==
{{Tag Footer}}
[[Category:Functions]]
[[Category:File Header API]]</p>
</d:entry>
<d:entry id="update_option" d:title="update option">
<d:index d:value="update option"/>
<h1>update option</h1>
<p>{{Languages|
{{en|Function_Reference/update_option}}
{{ru|Справочник_по_функциям/update_option}}
}}
== Description ==
Use the function &lt;tt&gt;update_option()&lt;/tt&gt; to update a named option/value pair to the options database table. The &lt;tt&gt;$option&lt;/tt&gt; (option name) value is escaped with &lt;tt&gt;$wpdb-&gt;prepare&lt;/tt&gt; before the INSERT statement but not the option value, this value should always be properly sanitized.
This function may be used in place of [[Function Reference/add option|&lt;tt&gt;add_option&lt;/tt&gt;]], although it is not as flexible. &lt;tt&gt;update_option&lt;/tt&gt; will check to see if the option already exists. If it does not, it will be added with &lt;tt&gt;add_option('option_name', 'option_value')&lt;/tt&gt;. Unless you need to specify the optional arguments of &lt;tt&gt;add_option()&lt;/tt&gt;, &lt;tt&gt;update_option()&lt;/tt&gt; is a useful catch-all for both adding and updating options.
'''Note:''' This function cannot be used to change whether an option is to be loaded (or not loaded) by &lt;tt&gt;[[Function_Reference/wp_load_alloptions | wp_load_alloptions()]]&lt;/tt&gt;. In that case, a [[Function_Reference/delete_option|&lt;tt&gt;delete_option()&lt;/tt&gt;]] should be followed by use of the [[Function_Reference/add_option|&lt;tt&gt;add_option()&lt;/tt&gt;]] function.
== Usage ==
%%%&lt;?php update_option( $option, $new_value ); ?&gt;%%%
== Parameters ==
{{Parameter|$option|string|Name of the option to update. Must not exceed 64 characters. A list of valid default options to update can be found at the [[Option Reference]].}}
{{Parameter|$newvalue|mixed|The NEW value for this option name. This value can be an integer, string, array, or object.}}
== Return Value ==
{{Return||boolean|True if option value has changed, false if not or if update failed.}}
== Example ==
=== Updating Core Options ===
Set the default comment status to 'closed':
update_option( 'default_comment_status', 'closed' );
This option is usually set by from the Settings &gt; Discussion administration panel. See the [[Option Reference]] for a full list of options used by WordPress Core.
=== Updating Custom Options ===
You can also create your own custom options. To update the option &lt;tt&gt;'myhack_extraction_length'&lt;/tt&gt; with the value 255, we would do this:
update_option( 'myhack_extraction_length', 255 );
This will automatically add the option if it does not exist. However, if we don't want this option to be autoloaded, we have to add it with a&lt;tt&gt;dd_option()&lt;/tt&gt;. In this example, we update the option if it already exists, and if it does not exist we use &lt;tt&gt;add_option()&lt;/tt&gt; and set &lt;tt&gt;$autoload&lt;/tt&gt; to &quot;no&quot;.
&lt;pre&gt;
&lt;?php
$option_name = 'myhack_extraction_length' ;
$new_value = '255' ;
if ( get_option( $option_name ) !== false ) {
// The option already exists, so we just update it.
update_option( $option_name, $new_value );
} else {
// The option hasn't been added yet. We'll add it with $autoload set to 'no'.
$deprecated = null;
$autoload = 'no';
add_option( $option_name, $new_value, $deprecated, $autoload );
}
?&gt;
&lt;/pre&gt;
== Change Log ==
Since: [[Version 1.0|1.0.0]]
== Source File ==
&lt;tt&gt;update_option()&lt;/tt&gt; is located in {{Trac|wp-includes/option.php}}.
== Related ==
{{Option Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="Function_Reference_2.0.x" d:title="Function Reference 2.0.x">
<d:index d:value="Function Reference 2.0.x"/>
<h1>Function Reference 2.0.x</h1>
<p>__NOTOC__
'''Note: This page applies to versions of WordPress prior to WordPress 2.1, and is also incomplete. The current WordPress function reference is at [[Function Reference]]'''.
&lt;div style=&quot;border:blue 1px solid;padding:10px; text-align:center; background: #E6CCFF&quot;&gt;
'''EDITORS AND CONTRIBUTORS'''
The layout and structure of this page will follow [[Template Tags]]. Please create pages for these functions as subpages of this page. If you create a subpage for a function, please include information and examples of usage of that function, if possible, per the examples found in [[Template Tags]].
For example: &lt;nowiki&gt;[[Function_Reference/wpdb_Class|wpdb_Class]]&lt;/nowiki&gt;.
&lt;/div&gt;
WordPress defines many useful functions. Rather than reinventing the wheel, you should take advantage of the core functions whenever possible. Of course, if the slick new plugin you are designing needs a better wheel, you are on your own, but at least you can take inspiration from the following functions.
Please check out the [[Mailing Lists#Documentation|wp-docs mailing list]] to find out how you can contribute to this section. And it needs ''your'' help!.
&lt;!-- remove this after there's enough example content --&gt;
==Functions by category==
{| cellspacing=&quot;10&quot; width=&quot;100%&quot;
|- valign=&quot;top&quot;
|bgcolor=&quot;#fbfbef&quot; style=&quot;border:1px solid #ffc9c9;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== General Functions ==
'''[[Function Reference|functions.php:]]'''
* profile
* time/date
** [[Function Reference/current time|current_time]]
* options
** [[Function Reference/add option|add_option]]
** [[Function Reference/delete option|delete_option]] -- removes row of given option name from the options database table.
** form_option -- does a [[Function_Reference/get_settings|get_settings]] on given string and returns info for an option. Before calling get_settings, the indata is passed through htmlspecialchars().
** get_alloptions - no parameters
** [[Function Reference/get settings|get_settings]] (alias: get_option)
** update_option -- given option name and new value, it makes a safe update of given option's database row.
* meta
* trackpack/ping
* xmlrpc
* filters
* actions
* is_single,page,archive,time/data
* themes/templates
* htmlentities2
* cookies
* plugins
* mail (pop) access
'''[[Function Reference|complete list]]'''
|valign=&quot;top&quot; bgcolor=&quot;#f0f0ff&quot; style=&quot;border:1px solid #c6c9ff;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Formatting Functions ==
This list is incomplete, please contribute.
* [[Function_Reference/wptexturize|wptexturize( $text )]]
* [[Function_Reference/clean_pre|clean_pre( $text )]] - Returns the text without BR tags, and with P tags turned into line-breaks
* [[Function_Reference/wpautop|wpautop( $pee, $br = 1 )]] - Returns the text with HTML formatting for paragraphs
* [[Function_Reference/seems_utf8|seems_utf8($Str)]] - Returns true if given string seems like it is UTF8-encoded
* [[Function_Reference/wp_specialchars|wp_specialchars( $text, $quotes = 0 )]] - Like the PHP function htmlspecialchars except it doesn't double-encode HTML entities
* [[Function_Reference/remove_accents|remove_accents($string)]] - Returns a string with accents or umlauts without these
* [[Function_Reference/sanitize_user|sanitize_user( $username, $strict = false )]] - Makes the username more machine-readable. Strict option for pure ASCII only.
* [[Function_Reference/sanitize_title|sanitize_title($title, $fallback_title = '')]]
* [[Function_Reference/sanitize_title_with_dashes|sanitize_title_with_dashes($title)]]
* [[Function_Reference/convert_chars|convert_chars($content, $flag = 'obsolete')]] - Translation of invalid Unicode references range to valid range
* [[Function_Reference/balanceTags|balanceTags($text, $is_comment = 0)]] - Balances Tags of string using a modified stack. Can be disabled by configuration.
* [[Function_Reference/zeroise|zeroise($number,$threshold)]] - Adds leading zeros when necessary
* [[Function_Reference/ent2ncr|ent2ncr($text)]] - Returns HTML entity as its number representation.
|- valign=&quot;top&quot;
|bgcolor=&quot;#fbfbef&quot; style=&quot;border:1px solid #ffc9c9;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Post Functions ==
* [[Function Reference/get_post|get_post]] - get information on a specific post
* [[Function Reference/get_cat_name|get_cat_name($cat_id)]] - get category name for given ID
* [[Function Reference/get_cat_ID|get_cat_ID($cat_name='General')]] - get category ID for given category name
* [[Function Reference/get_author_name|get_author_name( $auth_id )]] - get author's preferred display name
* [[Function Reference/get_post_mime_type|get_post_mime_type($ID = &quot;&quot;)]] - takes a post ID, returns its MIME type
* [[Function Reference/wp_insert_post|wp_insert_post($postarr=array())]] - A generic function for inserting data into the post table
* [[Function Reference/wp_update_post|wp_update_post($postarr=array())]] - A generic function to update data in the post table
* [[Function Reference/wp_publish_post|wp_publish_post($post_id)]] - Set a post's post_status to 'publish'ed. Calls wp_update_post.
* [[Function Reference/wp_delete_post|wp_delete_post($postid)]] - A generic function to delete a post in the post table
|valign=&quot;top&quot; bgcolor=&quot;#f0f0ff&quot; style=&quot;border:1px solid #c6c9ff;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Comment Functions ==
* [[Function Reference/get_approved_comments|get_approved_comments]]
|- valign=&quot;top&quot;
|bgcolor=&quot;#fbfbef&quot; style=&quot;border:1px solid #ffc9c9;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Feed Functions ==
* is_feed -- returns a Boolean, true if the current context is within a feed (wrapper for $WP_Query-&gt;is_feed)
* [[Function_Reference/fetch_rss|fetch_rss]] -- retrieve an RSS feed from a URL with automatic caching (included in rss_functions.php)
* [[Function_Reference/wp_rss|wp_rss]] -- retrieve and display an RSS feed as an unordered list (included in rss_functions.php)
* [[Function_Reference/get_rss|get_rss]] -- retrieve and display an RSS feed as a list (ordering optional) (included in rss_functions.php)
|valign=&quot;top&quot; bgcolor=&quot;#f0f0ff&quot; style=&quot;border:1px solid #c6c9ff;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Link Functions ==
[[Function Reference/get category link|get_category_link]]
|- valign=&quot;top&quot;
|bgcolor=&quot;#fbfbef&quot; style=&quot;border:1px solid #ffc9c9;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Administration Functions ==
* [[Function_Reference/insert_with_markers|insert_with_markers]] -- Writes a string (e.g. rewrite rules for the .htaccess file) to a given file namne between two markers, BEGIN and END.
*Please Contribute more...
|valign=&quot;top&quot; bgcolor=&quot;#f0f0ff&quot; style=&quot;border:1px solid #c6c9ff;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
== Classes ==
===WordPress classes===
* [[Function_Reference/WP_Cache|Object Cache]]
* [[Function_Reference/wpdb Class|wpdb]] - Database Interface
* [[Function_Reference/WP_Query|WP_Query]] - Request parsing and manipulation, posts fetching
* [[Function_Reference/WP_Rewrite|WP_Rewrite]] - Rewrite rules
* retrospam_mgr - Spam management
* WP - general request handling (in [[Version 1.6]])
* Capabilities Classes (WP_Roles, WP_Role, WP_User) (in [[Version 2.0]])
===External classes===
* [http://scripts.incutio.com/xmlrpc/ IXR] - XML-RPC Classes
* [http://sourceforge.net/projects/snoopy/ Snoopy] - HTTP client
* gettext_reader (part of [http://savannah.nongnu.org/projects/php-gettext/ PHP-gettext]) - Localization Class
* [http://magpierss.sourceforge.net/ RSS Classes (Magpie and RSSCache)]
|- valign=&quot;top&quot;
|bgcolor=&quot;#fbfbef&quot; style=&quot;border:1px solid #ffc9c9;padding:1em;padding-top:0.5em; color: black;&quot; width=&quot;50%&quot;|
==User Functions==
* [[Function Reference/get_currentuserinfo|get_currentuserinfo]] &amp;mdash; get information on the current user
* [[Function Reference/get_userdata|get_userdata]] &amp;mdash; get information on any user
* [[Function_Reference/get_usernumposts|get_usernumposts]] &amp;mdash; get post count for a specific user
* [[Function_Reference/get_usermeta|get_usermeta]] &amp;mdash; get meta data for a specific user
* [[Function_Reference/wp_create_user|wp_create_user]] &amp;mdash; Create a user and add it to the user database.
|}
==Functions by file==
The functions are defined in several PHP files, nearly all residing in the &lt;tt&gt;wp-includes&lt;/tt&gt; directory:
; &lt;tt&gt;classes.php&lt;/tt&gt;, &lt;tt&gt;class-IXR.php&lt;/tt&gt;, &lt;tt&gt;class-pop3.php&lt;/tt&gt;, &lt;tt&gt;class-snoopy.php&lt;/tt&gt;, &lt;tt&gt;gettext.php&lt;/tt&gt;, &lt;tt&gt;wp-db.php&lt;/tt&gt; : [[#Classes|Classes]].
; &lt;tt&gt;comment-functions.php&lt;/tt&gt; : [[#Comment_Functions|Comment functions]].
; &lt;tt&gt;feed-functions.php&lt;/tt&gt;, &lt;tt&gt;rss-functions.php&lt;/tt&gt; : [[#Feed_Functions|Feed functions]].
; &lt;tt&gt;functions-compat.php&lt;/tt&gt; : Compatibility functions for those running lower PHP versions.
; &lt;tt&gt;functions-formatting.php&lt;/tt&gt; : [[#Formatting_Functions|Formatting functions]].
; &lt;tt&gt;functions.php&lt;/tt&gt; : [[#Basic_Functions|Basic functions]].
; &lt;tt&gt;functions-post.php&lt;/tt&gt; : [[#Post_Functions|Post functions]].
; &lt;tt&gt;links.php&lt;/tt&gt; : [[#Link_Functions|Link functions]].
; &lt;tt&gt;pluggable-functions.php&lt;/tt&gt; : Pluggable functions (1.5.1+).
; &lt;tt&gt;template-functions-*.php&lt;/tt&gt; : [[Template Tags]].
; &lt;tt&gt;registration-functions.php&lt;/tt&gt;, &lt;tt&gt;wp-admin/admin-functions.php&lt;/tt&gt; : [[#Administration_Functions|Administration functions]].
== DRAFT ==
The following functions are to be moved into their appropriate categories above.
* [[Function Reference/add_action|add_action]]
* add_filter
* add_magic_quotes
* add_post_meta
* add_query_arg
* apply_filters
* auth_redirect
* date_i18n
* debug_fclose
* debug_fopen
* delete_post_meta
* [[Function Reference/do_action|do_action]]
* do_enclose
* generic_ping
* get_404_template
* get_archive_template
* [[Function Reference/get_approved_comments|get_approved_comments]]
* get_author_template
* get_category_template
* get_catname
* get_comments_popup_template
* get_current_theme
* get_date_template
* get_home_template
* get_lastpostdate
* get_lastpostmodified
* get_page_template
* get_page_uri
* get_paged_template
* get_post_meta
* get_postdata
* get_posts
* get_profile
* get_query_template
* get_query_var
* get_search_template
* get_single_template
* get_stylesheet
* get_stylesheet_directory
* get_stylesheet_directory_uri
* get_stylesheet_uri
* get_template
* get_template_directory
* get_template_directory_uri
* get_theme
* [[Function Reference/get_theme_data|get_theme_data]]
* get_theme_root
* get_theme_root_uri
* get_themes
* get_userdatabylogin
* get_userid
* get_weekstartend
* gzip_compression
* have_posts
* htmlentities2
* is_404
* is_archive
* is_author
* is_category
* is_comments_popup
* is_date
* is_day
* is_home
* is_month
* is_new_day
* is_page
* is_paged
* is_plugn_page
* is_search
* is_single
* is_time
* is_trackback
* is_year
* load_template
* make_url_footnote
* merge_filters
* mysql2date
* query_posts
* remove_action
* remove_filter
* remove_query_arg
* rewind_posts
* setup_postdata
* start_wp
* the_post
* [[Function Reference/timer_stop|timer_stop]]
* trackback
* update_category_cache
* update_post_caches
* update_post_meta
* update_user_cache
* url_to_postid
* user_pass_ok
* weblog_ping
* wp_clearcookie
* wp_head
* wp_insert_post
* wp_login
* wp_mail
* wp_setcookie
* xmlrpc_getpostcategory
* xmlrpc_getposttitle
* xmlrpc_removepostdata
[[Category:Advanced Topics]]
[[Category:Functions]]
[[Category:WordPress Development]]
[[Category:Redundant]]</p>
</d:entry>
<d:entry id="get_settings" d:title="get settings">
<d:index d:value="get settings"/>
<h1>get settings</h1>
<p>{{Deprecated}}
== Description ==
* '''NB:''' instead of get_settings, use [[Function_Reference/get_option|get_option($optionname)]]
A safe way of getting values for a named option from the options database table.
=== Note ===
For a complete list of all options available through this function, go to
&lt;nowiki&gt; http://www.yoursite.com/wp-admin/options.php &lt;/nowiki&gt;
'''Also:''' You can modify any/all of the options from the same page.
=== Aliases ===
%%% get_option($optionname) %%%
This is a wrapper around the get_settings function, added for readability and a more humane interface.
== Usage ==
%%% &lt;?php echo get_settings('show'); ?&gt; %%%
or
%%% &lt;?php echo get_option('show'); ?&gt; %%%
== Examples ==
=== Show Blog Title ===
Displays your blog's title in a &amp;lt;h1&amp;gt; tag.
%%% &lt;h1&gt;&lt;?php echo get_settings('blogname'); ?&gt;&lt;/h1&gt; %%%
or
%%% &lt;h1&gt;&lt;?php echo get_option('blogname'); ?&gt;&lt;/h1&gt; %%%
=== Show Character Set ===
Displays the character set your blog is using (ex: UTF-8)
%%% &lt;p&gt;Character set: &lt;?php echo get_settings('blog_charset'); ?&gt; &lt;/p&gt; %%%
or
%%% &lt;p&gt;Character set: &lt;?php echo get_option('blog_charset'); ?&gt; &lt;/p&gt; %%%
===Retrieve Administrator E-mail===
Retrieve the e-mail of the blog administrator, storing it in a variable.
%%%&lt;?php $admin_email = get_settings('admin_email'); ?&gt;%%%
or
%%% &lt;?php $admin_email = get_option('admin_email'); ?&gt; %%%
== Parameters ==
; show : (''string'') Name of the option. Underscores separate words, lowercase only - this is going to be in a database. Valid values:
:* &lt;tt&gt;'admin_email'&lt;/tt&gt; - E-mail address of blog administrator.
:* &lt;tt&gt;'blogname'&lt;/tt&gt; - Weblog title; set in General Options.
:* &lt;tt&gt;'blogdescription'&lt;/tt&gt; - Tagline for your blog; set in General Options.
:* &lt;tt&gt;'blog_charset'&lt;/tt&gt; - Character encoding for your blog; set in Reading Options.
:* &lt;tt&gt;'date_format'&lt;/tt&gt; - Default date format; set in General Options.
:* &lt;tt&gt;'default_category'&lt;/tt&gt; - Default post category; set in Writing Options.
:* &lt;tt&gt;'home'&lt;/tt&gt; - The blog's home web address; set in General Options.
:* &lt;tt&gt;'siteurl'&lt;/tt&gt; - WordPress web address; set in General Options.&lt;br /&gt;'''Warning:''' This is not the same as get_bloginfo('siteurl'); which will return the homepage url. Use get_bloginfo('wpurl'), get_settings() has been deprecated.
:* &lt;tt&gt;'template'&lt;/tt&gt; - The current theme's name; set in Presentation.
:* &lt;tt&gt;'start_of_week'&lt;/tt&gt; - Day of week calendar should start on; set in General Options.
:* &lt;tt&gt;'upload_path'&lt;/tt&gt; - Default upload location; set in Miscellaneous Options.
:* &lt;tt&gt;'posts_per_page'&lt;/tt&gt; - Maximum number of posts to show on a page; set in Reading Options.
:* &lt;tt&gt;'posts_per_rss'&lt;/tt&gt; - Maximum number of most recent posts to show in the syndication feed; set in Reading Options.
:There are many more options available, a lot of which depend on what plugins you have installed. Visit the /wp-admin/options.php page for a complete list.
== Related ==
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="form_option" d:title="form option">
<d:index d:value="form option"/>
<h1>form option</h1>
<p>== Description ==
Echo option value after sanitizing for forms.
== Usage ==
%%%&lt;?php form_option( $option ) ?&gt;%%%
== Parameters ==
{{Parameter|$option|string|Option name.}}
== Return Values ==
; (Echo) : '''echos''' the value in a get_option after its passed through esc_attr()
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/esc_attr|&lt;tt&gt;esc_attr()&lt;/tt&gt;]] to sanitize option value.
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;form_option()&lt;/tt&gt; is located in {{Trac|wp-includes/option.php}}.
== Related ==
{{Option Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_create_user" d:title="wp create user">
<d:index d:value="wp create user"/>
<h1>wp create user</h1>
<p>== Description ==
The [[Function_Reference/wp_create_user|wp_create_user]] function allows you to insert a new user into the WordPress database. It uses the $wpdb class to escape the variable values, preparing it for insertion into the database. Then the [http://php.net/compact PHP compact() function] is used to create an array with these values. To create a user with additional parameters, use [[Function_Reference/wp_insert_user|wp_insert_user()]].
== Usage ==
%%% &lt;?php wp_create_user( $username, $password, $email ); ?&gt; %%%
== Example ==
As used in wp-admin/upgrade-functions.php:
&lt;pre&gt;
$user_id = username_exists( $user_name );
if ( !$user_id and email_exists($user_email) == false ) {
$random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
$user_id = wp_create_user( $user_name, $random_password, $user_email );
} else {
$random_password = __('User already exists. Password inherited.');
}
&lt;/pre&gt;
== Parameters ==
{{Parameter|$username|string|The username of the user to be created.}}
{{Parameter|$password|string|The password of the user to be created.}}
{{Parameter|$email|string|The email address of the user to be created.|optional}}
== Returns ==
When successful - this function returns the user ID of the created user.
In case of failure (username or email already exists) the function returns an [[Class_Reference/WP_Error|error object]], with these possible values and messages;
* ''empty_user_login'', Cannot create a user with an empty login name.
* ''existing_user_login'', This username is already registered.
* ''existing_user_email'', This email address is already registered.
== Source File ==
&lt;tt&gt;wp_create_user()&lt;/tt&gt; is located in {{Trac|wp-includes/user.php}}.
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_userdata" d:title="get userdata">
<d:index d:value="get userdata"/>
<h1>get userdata</h1>
<p>{{Languages|
{{en|Function_Reference/get_userdata}}
{{ko|Function_Reference/get_userdata}}
{{tr|Fonksiyon Listesi/get_userdata}}
}}
== Description ==
Returns a [[Class_Reference/WP_User|WP_User]] object with the information pertaining to the user whose ID is passed to it. Properties de-referenced with &quot;-&amp;gt;&quot; map directly to wp_users and wp_usermeta tables in the database (see [[Database Description#Table:_wp_users|Database Description]]).
If the user does not exist, the function returns &lt;code&gt;false&lt;/code&gt;.
An alias of [[Function_Reference/get_user_by|get_user_by('id')]].
== Usage ==
%%% &lt;?php get_userdata( $userid ); ?&gt; %%%
== Parameters ==
{{Parameter|$userid|integer|The ID of the user whose data should be retrieved.}}
== Return Values ==
; &lt;tt&gt;(bool|object)&lt;/tt&gt; : False on failure, &lt;tt&gt;[[Class_Reference/WP_User | WP_User]]&lt;/tt&gt; object on success.
== Examples ==
=== Basic Usage ===
The &lt;tt&gt;get_userdata()&lt;/tt&gt; function returns an object of the user's data. You can echo various parts of the returned object or loop through the data to display it all.
Example displaying certain parts:
&lt;?php $user_info = get_userdata(1);
echo 'Username: ' . $user_info-&gt;user_login . &quot;\n&quot;;
echo 'User roles: ' . implode(', ', $user_info-&gt;roles) . &quot;\n&quot;;
echo 'User ID: ' . $user_info-&gt;ID . &quot;\n&quot;;
?&gt;
Results in: &lt;div style=&quot;border:1px solid lightblue; display_inline-block; margin: 1em; padding: 1em;&quot;&gt;Username: admin&lt;br /&gt;User roles: administrator&lt;br /&gt;User ID: 1&lt;/div&gt;
You can also assign certain parts into individual variables for displaying later or in multiple places.
Example for extracting certain parts:
&lt;?php $user_info = get_userdata(1);
$username = $user_info-&gt;user_login;
$first_name = $user_info-&gt;first_name;
$last_name = $user_info-&gt;last_name;
echo &quot;$first_name $last_name logs into her WordPress site with the user name of $username.&quot;;
?&gt;
Results in: &lt;div style=&quot;border:1px solid lightblue; display_inline-block; margin: 1em; padding: 1em;&quot;&gt;Harriet Smith logs into her WordPress site with the user name of mrssmith.&lt;/div&gt;
=== Accessing Usermeta Data ===
&lt;?php $user_info = get_userdata(1);
echo $user_info-&gt;last_name . &quot;, &quot; . $user_info-&gt;first_name . &quot;\n&quot;;
?&gt;
Results in: &lt;div style=&quot;border:1px solid lightblue; display_inline-block; margin: 1em; padding: 1em;&quot;&gt;Doe, John&lt;/div&gt;
== Notes ==
Here are some of the useful values in the &lt;tt&gt;wp_users&lt;/tt&gt; and &lt;tt&gt;wp_usermeta&lt;/tt&gt; tables you can access with this function for use in your theme or plugin:
* '''users'''
** ID
** user_login
** user_pass
** user_nicename
** user_email
** user_url
** user_registered
** display_name
* '''user_meta'''
** user_firstname
** user_lastname
** nickname
** description
** wp_capabilities (array)
** admin_color (Theme of your admin page. Default is fresh.)
** closedpostboxes_page
** primary_blog
** rich_editing
** source_domain
&lt;b&gt;Note:&lt;/b&gt; the WP_User object uses PHP 5 &quot;magic&quot; methods to provide some of its properties. For example:&lt;br/&gt;
&lt;tt&gt;$user_info-&gt;user_login&lt;/tt&gt; is shorthand for &lt;tt&gt;$user_info-&gt;data-&gt;user_login&lt;/tt&gt;, and&lt;br/&gt;
&lt;tt&gt;$user_info-&gt;rich_editing&lt;/tt&gt; is shorthand for &lt;tt&gt;get_user_meta($user_info-&gt;ID, 'rich_editing', true)&lt;/tt&gt;.
== Source File ==
&lt;tt&gt;get_userdata()&lt;/tt&gt; is located in {{Trac|wp-includes/pluggable.php}}.
== See Also ==
* [[Author Templates]]
== Related ==
{{Get User Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="add_filter" d:title="add filter">
<d:index d:value="add filter"/>
<h1>add filter</h1>
<p>{{Languages|
{{en|Function_Reference/add_filter}}
{{it|Function_Reference/it:add_filter}}
{{ja|関数リファレンス/add_filter}}
{{ru|Справочник_по_функциям/add_filter}}
}}
== Description ==
Hook a function to a specific filter action.
* Glossary: [http://codex.wordpress.org/Glossary#Filter Filters]
== Usage ==
%%% &lt;?php add_filter( $tag, $function_to_add, $priority, $accepted_args ); ?&gt; %%%
== Parameters ==
{{Parameter|$tag|string|The name of the existing Filter to Hook the &lt;tt&gt;$function_to_add&lt;/tt&gt; argument to. You can find a [http://codex.wordpress.org/Plugin_API/Filter_Reference list of Filter Hooks here].}}
{{Parameter|$function_to_add|callback|The name of the function to be called when the custom Filter is [[Function Reference/apply_filters|applied]].}}
{{Parameter|$priority|integer|Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the filter.|optional|10}}
{{Parameter|$accepted_args|integer|The number of arguments the function(s) accept(s). In WordPress 1.5.1 and newer hooked functions can take extra arguments that are set when the matching apply_filters() call is run.|optional|1}}
== Return ==
The function returns true if the attempted function hook succeeds or false if not. There is no test that the function exists nor whether the &lt;tt&gt;$function_to_add&lt;/tt&gt; is even a string. It is up to you to take care.
This is done for optimization purposes, so everything is as quick as possible.
== Example ==
The filter &lt;tt&gt;img_caption_shortcode&lt;/tt&gt; is applied in &lt;tt&gt;media.php&lt;/tt&gt; using the following call:
&lt;pre&gt;
// Allow plugins/themes to override the default caption template.
$output = apply_filters('img_caption_shortcode', '', $attr, $content);
if ( $output != '' )
return $output;
&lt;/pre&gt;
The target filter function will be called with three arguments:
* &amp;#39;&amp;#39; &amp;lt;= This is normally the value the filter will be modifying
* $attr
* $content
In order for the filter function to actually receive the full argument list, the call to &lt;tt&gt;add_filter()&lt;/tt&gt; must
be modified to specify there are 3 arguments on the parameter list.
&lt;pre&gt;
add_filter('img_caption_shortcode', 'my_img_caption_shortcode_filter',10,3);
/**
* Filter to replace the [caption] shortcode text with HTML5 compliant code
*
* @return text HTML content describing embedded figure
**/
function my_img_caption_shortcode_filter($val, $attr, $content = null)
{
extract(shortcode_atts(array(
'id' =&gt; '',
'align' =&gt; '',
'width' =&gt; '',
'caption' =&gt; ''
), $attr));
if ( 1 &gt; (int) $width || empty($caption) )
return $val;
$capid = '';
if ( $id ) {
$id = esc_attr($id);
$capid = 'id=&quot;figcaption_'. $id . '&quot; ';
$id = 'id=&quot;' . $id . '&quot; aria-labelledby=&quot;figcaption_' . $id . '&quot; ';
}
return '&lt;figure ' . $id . 'class=&quot;wp-caption ' . esc_attr($align) . '&quot; style=&quot;width: '
. (10 + (int) $width) . 'px&quot;&gt;' . do_shortcode( $content ) . '&lt;figcaption ' . $capid
. 'class=&quot;wp-caption-text&quot;&gt;' . $caption . '&lt;/figcaption&gt;&lt;/figure&gt;';
}
&lt;/pre&gt;
== Notes ==
* Hooked functions can take extra arguments that are set when the matching &lt;tt&gt;[[Function_Reference/do_action | do_action()]]&lt;/tt&gt; or &lt;tt&gt;[[Function_Reference/apply_filters | apply_filters()]]&lt;/tt&gt; call is run. For example, the action &lt;tt&gt;[[Plugin_API/Action_Reference/comment_id_not_found | 'comment_id_not_found']]&lt;/tt&gt; will pass the comment ID to each callback.
* Although you can pass the number of &lt;tt&gt;$accepted_args&lt;/tt&gt;, you can only manipulate the &lt;tt&gt;[http://codex.wordpress.org/Function_Reference/apply_filters#Parameters $value]&lt;/tt&gt;. The other arguments are only to provide context, and their values cannot be changed by the filter function.
* You can also pass a class method as a callback.
:Static class method:
:&lt;pre&gt;add_filter( 'media_upload_newtab', array( 'My_Class', 'media_upload_callback' ) );&lt;/pre&gt;
:Instance method:
:&lt;pre&gt;add_filter( 'media_upload_newtab', array( $this, 'media_upload_callback' ) );&lt;/pre&gt;
* You can also pass an an anonymous function as a callback. For example:
:&lt;pre&gt;add_filter( 'the_title', function( $title ) { return '&lt;b&gt;' . $title . '&lt;/b&gt;'; } );&lt;/pre&gt;
:[http://www.php.net/manual/functions.anonymous.php Anonymous functions] were introduced in PHP 5.3.0. Check [[Hosting WordPress]] requirements and double check your PHP version before using them.
:If your version of PHP is older than 5.3.0, you can use &lt;tt&gt;[http://www.php.net/manual/function.create-function.php create_function()]&lt;/tt&gt; instead. But keep in mind that lambda functions created by &lt;tt&gt;create_function()&lt;/tt&gt; are not [http://framework.zend.com/issues/browse/ZF-7646 cached by APC or any other optimizer]. So don't use &lt;tt&gt;create_function()&lt;/tt&gt; if callback is supposed to be used more than few times or it has complex logic.
== Change Log ==
* Since: 0.71
== Source File ==
&lt;tt&gt;add_filter()&lt;/tt&gt; is located in {{Trac|wp-includes/plugin.php}}.
== See Also ==
* [http://stackoverflow.com/questions/13797313/wordpress-how-to-return-value-when-use-add-filter/13797597#13797597 A good explanation on Filter hooks on stackoverflow.com] (2012-12-10)
== Related ==
{{Filter Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_currentuserinfo" d:title="get currentuserinfo">
<d:index d:value="get currentuserinfo"/>
<h1>get currentuserinfo</h1>
<p>== Description ==
Retrieves the information pertaining to the currently logged in user, and places it in the global variable &lt;tt&gt;$current_user&lt;/tt&gt;. Properties map directly to the wp_users table in the database (see [[Database Description#Table:_wp_users|Database Description]]).
Also places the individual attributes into the following separate global variables:
:* &lt;tt&gt;$user_login&lt;/tt&gt;
:* &lt;tt&gt;$user_ID&lt;/tt&gt; (Equal $current_user-&gt;ID, not $current_user-&gt;user_ID)
:* &lt;tt&gt;$user_email&lt;/tt&gt;
:* &lt;tt&gt;$user_url&lt;/tt&gt; (User's website, as entered in the user's Profile)
:* &lt;tt&gt;$user_pass&lt;/tt&gt; (The phpass hash of the user password - useful for comparing input at a password prompt with the actual user password.)
:* &lt;tt&gt;$display_name&lt;/tt&gt; (User's name, displayed according to the 'How to display name' User option)
:* &lt;tt&gt;$user_identity&lt;/tt&gt; (User's name, displayed according to the 'How to display name' User option (since 3.0))
== Usage ==
%%% &lt;?php get_currentuserinfo(); ?&gt; %%%
== Examples ==
=== Default Usage ===
The call to &lt;tt&gt;get_currentuserinfo()&lt;/tt&gt; places the current user's info into &lt;tt&gt;$current_user&lt;/tt&gt;, where it can be retrieved using member variables.
&lt;?php global $current_user;
get_currentuserinfo();
echo 'Username: ' . $current_user-&gt;user_login . &quot;\n&quot;;
echo 'User email: ' . $current_user-&gt;user_email . &quot;\n&quot;;
echo 'User first name: ' . $current_user-&gt;user_firstname . &quot;\n&quot;;
echo 'User last name: ' . $current_user-&gt;user_lastname . &quot;\n&quot;;
echo 'User display name: ' . $current_user-&gt;display_name . &quot;\n&quot;;
echo 'User ID: ' . $current_user-&gt;ID . &quot;\n&quot;;
?&gt;
&lt;div style=&quot;border:1px solid blue; width:70%; padding:10px&quot;&gt;Username: Zedd&lt;br /&gt;
User email: my@email.com&lt;br /&gt;
User first name: John&lt;br /&gt;
User last name: Doe&lt;br /&gt;
User display name: John Doe&lt;br /&gt;
User ID: 1&lt;/div&gt;
=== Using Separate Globals ===
Much of the user data is placed in separate global variables, which can be accessed directly.
&lt;?php global $display_name , $user_email;
get_currentuserinfo();
echo $display_name . &quot;'s email address is: &quot; . $user_email;
?&gt;
&lt;div style=&quot;border:1px solid blue; width:50%; padding:10px&quot;&gt;Zedd's email address is: john@example.com&lt;/div&gt;
''' NOTE:''' $display_name does not appear to work in 2.5+? Use $user_identity
&lt;?php global $user_login , $user_email;
get_currentuserinfo();
echo($user_login . &quot;'s email address is: &quot; . $user_email;
?&gt;
== Parameters ==
This function does not accept any parameters.
To determine if there is a user currently logged in, do this:
&lt;?php
if(!is_user_logged_in()) {
//no user logged in
}
?&gt;
Here is another example:
&lt;pre&gt;
&lt;?php if ( is_user_logged_in() ) { ?&gt;
&lt;!-- text that logged in users will see --&gt;
&lt;?php } else { ?&gt;
&lt;!-- here is a paragraph that is shown to anyone not logged in --&gt;
&lt;p&gt;By &lt;a href=&quot;&lt;?php home_url(); ?&gt;/wp-register.php&quot;&gt;registering&lt;/a&gt;, you can save your favorite posts for future reference.&lt;/p&gt;
&lt;?php } ?&gt;
&lt;/pre&gt;
Here is yet another example using logical conditionals to restrict access to pages:
&lt;pre&gt;
&lt;?php if ($current_user-&gt;user_login == 'the_username') { ?&gt;
&lt;!-- Welcome the user or show the page content --&gt;
&lt;h1&gt;Welcome &lt;?php echo $current_user-&gt;user_firstname ?&gt;&lt;/h1&gt;
&lt;?php } else { ?&gt;
&lt;!-- Let the visitor know access is denied --&gt;
&lt;h1&gt;Go away!&lt;/h1&gt;
&lt;?php } ?&gt;
&lt;/pre&gt;
== Source File ==
&lt;tt&gt;get_currentuserinfo()&lt;/tt&gt; is located in {{Trac|wp-includes/pluggable.php}}.
== Related ==
{{Get User Tags}}
{{Current User Tags}}
{{Tag Footer}}
{{Copyedit}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_all_category_ids" d:title="get all category ids">
<d:index d:value="get all category ids"/>
<h1>get all category ids</h1>
<p>{{Languages|
{{en|Function Reference/get_all_category_ids}}
{{it|Riferimento_funzioni/get_all_category_ids}}
}}
== Description ==
Retrieves all category IDs.
== Usage ==
%%%&lt;?php get_all_category_ids() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (array) : A list of all of the category IDs.
== Examples ==
To print a list of categories by id: name
&lt;pre&gt;&lt;?php
$category_ids = get_all_category_ids();
foreach($category_ids as $cat_id) {
$cat_name = get_cat_name($cat_id);
echo $cat_id . ': ' . $cat_name;
}
?&gt;&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_all_category_ids()&lt;/tt&gt; is located in {{Trac|wp-includes/category.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="Category:Template_Tags" d:title="Category:Template Tags">
<d:index d:value="Category:Template Tags"/>
<h1>Category:Template Tags</h1>
<p>Articles in the Template Tags Category document the proper use and syntax of the Template Tags used in WordPress
[[Category:Advanced Topics]]
[[Category:Design and Layout]]
[[Category:WordPress Development]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="fetch_rss" d:title="fetch rss">
<d:index d:value="fetch rss"/>
<h1>fetch rss</h1>
<p>{{Deprecated}}
==Description==
Retrieves an RSS feed and parses it. Uses the [http://magpierss.sourceforge.net/ MagpieRSS and RSSCache] functions for parsing and automatic caching and the [http://sourceforge.net/projects/snoopy/ Snoopy HTTP client] for the actual retrieval.
Deprecated note: Switch to using [[Function_Reference/fetch_feed|fetch_feed]] instead.
==Usage==
%%% &lt;?php
include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_rss($uri);
?&gt; %%%
==Parameters==
{{Parameter|$uri|URI|The URI of the RSS feed you want to retrieve. The resulting parsed feed is returned, with the more interesting and useful bits in the items array.}}rray.
==Example==
To get and display a list of links for an existing RSS feed, limiting the selection to the most recent 5 items:
%%%
&lt;h2&gt;&lt;?php _e('Headlines from AP News'); ?&gt;&lt;/h2&gt;
&lt;?php // Get RSS Feed(s)
include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_rss('http://example.com/rss/feed/goes/here');
$maxitems = 5;
$items = array_slice($rss-&gt;items, 0, $maxitems);
?&gt;
&lt;ul&gt;
&lt;?php if (empty($items)): ?&gt;
&lt;li&gt;No items&lt;/li&gt;
&lt;?php else:
foreach ( $items as $item ):
?&gt;
&lt;li&gt;
&lt;a href='&lt;?php echo $item['link']; ?&gt;' title='&lt;?php echo $item['title']; ?&gt;'&gt;
&lt;?php echo $item['title']; ?&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;?php
endforeach;
endif;
?&gt;
&lt;/ul&gt;
%%%
== Change Log ==
* Since [[Version 1.5]]
* Deprecated in [[Version 3.0]]
== Source File ==
&lt;code&gt;fetch_rss&lt;/code&gt; is defined in {{Trac|wp-includes/rss.php}}.
== Related ==
* [[Function_Reference/fetch_feed|fetch_feed]]
* [[Function_Reference/wp_rss|wp_rss()]]
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="add_action" d:title="add action">
<d:index d:value="add action"/>
<h1>add action</h1>
<p>{{Languages|
{{en|Function_Reference/add_action}}
{{ja|関数リファレンス/add_action}}
{{zh-hans|函数参考/add_action}}
{{ko|한국어/add_action}}
}}
== Description ==
Hooks a function on to a specific [http://codex.wordpress.org/Glossary#Action action].
More specifically, this function will run the function &lt;tt&gt;$function_to_add&lt;/tt&gt; when the event &lt;tt&gt;$hook&lt;/tt&gt; occurs.
This function is an alias to [[Function_Reference/add_filter|add_filter()]].
See [[Plugin_API/Action_Reference|Plugin API/Action Reference]] for a list of action hooks. Actions are (usually) triggered when the WordPress core calls [[Function_Reference/do_action|do_action()]].
== Usage ==
%%%&lt;?php add_action( $hook, $function_to_add, $priority, $accepted_args ); ?&gt;%%%
==Parameters==
{{Parameter|$hook|string|The name of the action to which $function_to_add is hooked. (See [[Plugin_API/Action_Reference|Plugin API/Action Reference]] for a list of action hooks). Can also be the name of an action inside a theme or plugin file, or the special tag &quot;all&quot;, in which case the function will be called for all hooks)}}
{{Parameter|$function_to_add|callback|The name of the function you wish to be hooked.}}
{{Parameter|$priority|int|Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.|optional|10}}
{{Parameter|$accepted_args|int|The number of arguments the hooked function accepts. In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching [[Function_Reference/do_action|do_action()]] or [[Function_Reference/apply_filters|apply_filters()]] call is run. For example, the action &lt;tt&gt;comment_id_not_found&lt;/tt&gt; will pass any functions that hook onto it the ID of the requested comment.|optional|1}}
== Return Values ==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : Always True.
== Examples ==
=== Simple Hook ===
To email some friends whenever an entry is posted on your blog:
&lt;pre&gt;
function email_friends( $post_ID ) {
$friends = 'bob@example.org, susie@example.org';
wp_mail( $friends, &quot;sally's blog updated&quot;, 'I just put something on my blog: http://blog.example.com' );
return $post_ID;
}
add_action( 'publish_post', 'email_friends' );
&lt;/pre&gt;
=== Accepted Arguments ===
A hooked function can optionally accept arguments from the action call, if any are set to be passed. In this simplistic example, the &lt;tt&gt;echo_comment_id&lt;/tt&gt; function takes the &lt;tt&gt;$comment_id&lt;/tt&gt; argument, which is automatically passed to when the [[Function_Reference/do_action|do_action()]] call using the &lt;tt&gt;comment_id_not_found&lt;/tt&gt; filter hook is run.
&lt;pre&gt;
function echo_comment_id( $comment_id ) {
echo 'Comment ID ' . $comment_id . ' could not be found';
}
add_action( 'comment_id_not_found', 'echo_comment_id', 10, 1 );
&lt;/pre&gt;
=== Using with a Class ===
To use &lt;tt&gt;add_action()&lt;/tt&gt; when your plugin or theme is built using classes, you need to use [http://www.php.net/manual/en/language.types.callable.php#language.types.callable.passing the array callable syntax]. You would pass the function to &lt;tt&gt;add_action()&lt;/tt&gt; as an array, with $this as the first element, then the name of the class method, like so:
&lt;pre&gt;
class MyPluginClass {
public function __construct() {
add_action( 'save_post', array( $this, 'myplugin_save_posts' ) );
}
public function myplugin_save_posts() {
// do stuff here...
}
}
&lt;/pre&gt;
== Notes ==
To find out the number and name of arguments for an action, simply search the code base for the matching do_action() call. For example, if you are hooking into 'save_post', you would find it in post.php:
%%% &lt;?php do_action( 'save_post', $post_ID, $post, $update ); ?&gt; %%%
Your add_action call would look like:
%%% &lt;?php add_action( 'save_post', 'my_save_post', 10, 3 ); ?&gt; %%%
And your function would be:
&lt;pre&gt;
function my_save_post( $post_ID, $post, $update ) {
// do stuff here
}
&lt;/pre&gt;
== Change Log ==
Since [[Version 1.2|1.2.0]]
== Source File ==
&lt;tt&gt;add_action()&lt;/tt&gt; is located in {{Trac|wp-includes/plugin.php}}.
== Related ==
{{Action Tags}}
{{Tag Footer}}
[[Category:Functions]]
{{Copyedit}}</p>
</d:entry>
<d:entry id="wp_rss" d:title="wp rss">
<d:index d:value="wp rss"/>
<h1>wp rss</h1>
<p>{{Deprecated}}
==Description==
Retrieves an RSS feed and parses it, then displays it as an unordered list of links. Uses the [http://magpierss.sourceforge.net/ MagpieRSS and RSSCache] functions for parsing and automatic caching and the [http://sourceforge.net/projects/snoopy/ Snoopy HTTP client] for the actual retrieval.
Deprecated note: Switch to using [[Function_Reference/fetch_feed|fetch_feed]] instead.
==Usage==
%%%&lt;?php
include_once(ABSPATH . WPINC . '/rss.php');
wp_rss($uri, $num);
?&gt;%%%
==Parameters==
{{Parameter|$uri|URI|The URI of the RSS feed you want to retrieve. The resulting parsed feed is returned, with the more interesting and useful bits in the items array.}}
{{Parameter|$num|integer|The number of items to display.}}
==Output==
The output will look like the following:
%%%&lt;ul&gt;
&lt;li&gt;
&lt;a href='LINK FROM FEED' title='DESCRIPTION FROM FEED'&gt;TITLE FROM FEED&lt;/a&gt;
&lt;/li&gt;
(repeat for number of links specified)
&lt;/ul&gt;%%%
==Example==
To get and display a list of 5 links from an existing RSS feed:
%%%&lt;?php
include_once(ABSPATH . WPINC . '/rss.php');
wp_rss('http://example.com/rss/feed/goes/here', 5);
?&gt;%%%
== Related ==
[[Function_Reference/fetch_rss|fetch_rss]], [[Function_Reference/get_rss|get_rss]]
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wptexturize" d:title="wptexturize">
<d:index d:value="wptexturize"/>
<h1>wptexturize</h1>
<p>{{Languages|
{{en|Function Reference/wptexturize}}
{{it|Riferimento funzioni/wptexturize}}
}}
{{Stub}}
== Description ==
This returns given text with transformations of quotes to smart quotes, apostrophes, dashes, ellipses, the trademark symbol, and the multiplication symbol. Text enclosed in the tags &lt;tt&gt;&lt;nowiki&gt;&lt;pre&gt;&lt;/nowiki&gt;&lt;/tt&gt;, &lt;tt&gt;&lt;nowiki&gt;&lt;code&gt;&lt;/nowiki&gt;&lt;/tt&gt;, &lt;tt&gt;&lt;nowiki&gt;&lt;kbd&gt;&lt;/nowiki&gt;&lt;/tt&gt;, &lt;tt&gt;&lt;nowiki&gt;&lt;style&gt;&lt;/nowiki&gt;&lt;/tt&gt;, &lt;tt&gt;&lt;nowiki&gt;&lt;script&gt;&lt;/nowiki&gt;&lt;/tt&gt;, &lt;tt&gt;&lt;nowiki&gt; and &lt;tt&gt;&lt;/nowiki&gt;&lt;/tt&gt; will be skipped.
== Usage ==
%%% &lt;?php wptexturize( $text ); ?&gt; %%%
== Parameters ==
{{Parameter|$text|string|The text to be formatted.}}
== Return Values ==
; (string) : The string replaced with html numeric character references.
== Notes ==
Opening and closing quotes can be customized in a WordPress translation file. Here are some of the text transformations:
{|
! source text !! transformed text !! symbol name
|-
| &quot;---&quot; || &quot;&amp;#8212;&quot; || em-dash
|-
| &quot; -- &quot; || &quot;&amp;#8212;&quot; || em-dash
|-
| &quot;--&quot; || &quot;&amp;#8211;&quot; || en-dash
|-
| &quot; - &quot; || &quot;&amp;#8211;&quot; || en-dash
|-
| &quot;xn&amp;#8211;&quot; || &quot;xn--&quot; ||
|-
| &quot;...&quot; || &quot;&amp;#8230;&quot; || ellipsis
|-
| `` || &amp;#8220; || opening quote
|-
| &lt;nowiki&gt;''&lt;/nowiki&gt; || &amp;#8221; || closing quote
|-
| &quot; (tm)&quot; || &quot; &amp;#8482;&quot; || trademark symbol
|-
| 1234&quot; || 1234&amp;#8243; || double prime symbol
|-
| 1234' || 1234&amp;#8242; || prime symbol
|-
| 1234x1234 || 1234&amp;#215;1234 || multiplication symbol
|-
|}
There is a small &quot;cockney&quot; list of transformations, as well. They can be replaced if the variable &lt;tt&gt;$wp_cockneyreplace&lt;/tt&gt; is defined and contains an associative array with the keys containing the source strings and the values containing the transformed strings. By default the following strings will be transformed:
* 'tain't
* 'twere
* 'twas
* 'tis
* 'twill
* 'til
* 'bout
* 'nuff
* 'round
* 'cause
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;wptexturize()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
* Function: [[Function_Reference/wpautop|wpautop()]]
* Filter: [[Plugin API/Filter Reference/no_texturize_shortcodes|no_texturize_shortcodes]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="wpautop" d:title="wpautop">
<d:index d:value="wpautop"/>
<h1>wpautop</h1>
<p>{{Languages|
{{en|Function Reference/wpautop}}
{{it|Riferimento funzioni/wpautop}}
}}
== Description ==
Changes double line-breaks in the text into HTML paragraphs (&lt;tt&gt;&lt;nowiki&gt;&lt;p&gt;...&lt;/p&gt;&lt;/nowiki&gt;&lt;/tt&gt;).
WordPress uses it to filter [[Template_Tags/the_content|the content]] and [[Template_Tags/the_excerpt|the excerpt]].
== Usage ==
%%% &lt;?php wpautop( $foo, $br ); ?&gt; %%%
== Parameters ==
{{Parameter|$foo|string|The text to be formatted.}}
{{Parameter|$br|boolean| Preserve line breaks. When set to true, any line breaks remaining after paragraph conversion are converted to HTML &lt;tt&gt;&lt;nowiki&gt;&lt;br /&gt;&lt;/nowiki&gt;&lt;/tt&gt;. Line breaks within &lt;tt&gt;script&lt;/tt&gt; and &lt;tt&gt;style&lt;/tt&gt; sections are not affected.|optional|true}}
== Return Values ==
; (string) : Text which has been converted into correct paragraph tags.
== Examples ==
=== Basic usage ===
&lt;?php
$some_long_text = // Start Text
Some long text
that has many lines
and paragraphs in it.
// end text
echo wpautop( $some_long_text );
?&gt;
This should echo the string with &lt;nowiki&gt;&lt;p&gt;&lt;/nowiki&gt; tags around the paragraphs, like this:
&lt;nowiki&gt;&lt;p&gt;Some long text&lt;br/&gt;
that has many lines&lt;/p&gt;
&lt;p&gt;and paragraphs in it.&lt;/p&gt;&lt;/nowiki&gt;
== Notes ==
=== Disabling the filter ===
Some people choose to disable the wpautop filter from within their theme's &lt;tt&gt;functions.php&lt;/tt&gt;:
&lt;pre&gt;
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
&lt;/pre&gt;
There's also a [http://wordpress.org/extend/plugins/wpautop-control/ plugin] available to enable/disable the filter on a post-by-post basis.
== Changelog ==
Since: 0.71
== Source File ==
&lt;tt&gt;wpautop()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Resources ==
http://ma.tt/scripts/autop/
== Related ==
{{Tag Footer}}
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="wp_reschedule_event" d:title="wp reschedule event">
<d:index d:value="wp reschedule event"/>
<h1>wp reschedule event</h1>
<p>== Description ==
This function is used internally by WordPress to reschedule a recurring event. You'll likely never need to use this function manually, it is documented here for completeness.
== Usage ==
%%% &lt;?php wp_reschedule_event( $timestamp, $recurrence, $hook, $args); ?&gt;%%%
== Parameters ==
{{Parameter|$timestamp|integer|The time the scheduled event will occur (unix timestamp)|required}}
{{Parameter|$recurrence|string|How often the event recurs, either 'hourly' or 'daily'|required}}
{{Parameter|$hook|string|Name of action hook to fire (string)|required}}
{{Parameter|$args|array|Arguments to pass into the hook function(s)|optional|array()}}
== Return Value ==
{{Return||boolean&amp;#124;null|False on failure. Null when event is rescheduled.}}
== Examples ==
== Notes ==
== Change Log ==
Since: [[Version 2.1|2.1.0]]
== Source File ==
&lt;tt&gt;wp_reschedule_event()&lt;/tt&gt; is located in {{Trac|wp-includes/cron.php}}
== Related ==
For a comprehensive list of functions, take a look at the [http://codex.wordpress.org/Category:Functions category Functions]
* [[Function_Reference]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New page created]]
[[Category:WP-Cron Functions]]</p>
</d:entry>
<d:entry id="wp_insert_post" d:title="wp insert post">
<d:index d:value="wp insert post"/>
<h1>wp insert post</h1>
<p>{{Languages|
{{en|Function_Reference/wp_insert_post}}
{{ru|Справочник по функциям/wp insert post}}
{{ja|関数リファレンス/wp insert post}}
{{tr|Fonksiyon Listesi/wp insert post}}
{{zh-cn|函数参考/wp_insert_post}}
}}
==Description==
This function inserts posts (and pages) in the database. It sanitizes variables, does some checks, fills in missing variables like date/time, etc. It takes an array as its argument and returns the post ID of the created post (or &lt;tt&gt;0&lt;/tt&gt; if there is an error).
== Usage ==
%%% &lt;?php wp_insert_post( $post, $wp_error ); ?&gt; %%%
==Parameters==
{{Parameter|$post|array|An array representing the elements that make up a post. There is a one-to-one relationship between these elements and the names of columns in the wp_posts table in the database.}}
'''IMPORTANT''': Setting a value for $post['ID'] WILL NOT create a post with that ID number. Setting this value will cause the function to update the post with that ID number with the other values specified in $post. In short, to insert a new post, $post['ID'] must be blank or not set at all.
The contents of the post array can depend on how much (or little) you want to trust the defaults. Here is a list with a short description of all the keys you can set for a post:
&lt;pre&gt;
$post = array(
'ID' =&gt; [ &lt;post id&gt; ] // Are you updating an existing post?
'post_content' =&gt; [ &lt;string&gt; ] // The full text of the post.
'post_name' =&gt; [ &lt;string&gt; ] // The name (slug) for your post
'post_title' =&gt; [ &lt;string&gt; ] // The title of your post.
'post_status' =&gt; [ 'draft' | 'publish' | 'pending'| 'future' | 'private' | custom registered status ] // Default 'draft'.
'post_type' =&gt; [ 'post' | 'page' | 'link' | 'nav_menu_item' | custom post type ] // Default 'post'.
'post_author' =&gt; [ &lt;user ID&gt; ] // The user ID number of the author. Default is the current user ID.
'ping_status' =&gt; [ 'closed' | 'open' ] // Pingbacks or trackbacks allowed. Default is the option 'default_ping_status'.
'post_parent' =&gt; [ &lt;post ID&gt; ] // Sets the parent of the new post, if any. Default 0.
'menu_order' =&gt; [ &lt;order&gt; ] // If new post is a page, sets the order in which it should appear in supported menus. Default 0.
'to_ping' =&gt; // Space or carriage return-separated list of URLs to ping. Default empty string.
'pinged' =&gt; // Space or carriage return-separated list of URLs that have been pinged. Default empty string.
'post_password' =&gt; [ &lt;string&gt; ] // Password for post, if any. Default empty string.
'guid' =&gt; // Skip this and let Wordpress handle it, usually.
'post_content_filtered' =&gt; // Skip this and let Wordpress handle it, usually.
'post_excerpt' =&gt; [ &lt;string&gt; ] // For all your post excerpt needs.
'post_date' =&gt; [ Y-m-d H:i:s ] // The time post was made.
'post_date_gmt' =&gt; [ Y-m-d H:i:s ] // The time post was made, in GMT.
'comment_status' =&gt; [ 'closed' | 'open' ] // Default is the option 'default_comment_status', or 'closed'.
'post_category' =&gt; [ array(&lt;category id&gt;, ...) ] // Default empty.
'tags_input' =&gt; [ '&lt;tag&gt;, &lt;tag&gt;, ...' | array ] // Default empty.
'tax_input' =&gt; [ array( &lt;taxonomy&gt; =&gt; &lt;array | string&gt; ) ] // For custom taxonomies. Default empty.
'page_template' =&gt; [ &lt;string&gt; ] // Requires name of template file, eg template.php. Default empty.
);
&lt;/pre&gt;
'''Notes'''
* 'post_status': If providing a post_status of 'future' you must specify the post_date in order for WordPress to know when to publish your post. See also [[Post Status Transitions]].
* 'post_category': Equivalent to calling [[Function Reference/wp_set_post_categories|wp_set_post_categories()]].
* 'tags_input': Equivalent to calling [[Function Reference/wp_set_post_tags|wp_set_post_tags()]].
* 'tax_input': Equivalent to calling [[Function Reference/wp_set_post_terms|wp_set_post_terms()]] for each custom taxonomy in the array. If the current user doesn't have the capability to work a taxonomy, the you must use wp_set_object_terms() instead.
* 'page_template': If post_type is 'page', will attempt to set the [[Page_Templates|page template]]. On failure, the function will return either a WP_Error or 0, and stop before the final actions are called. If the post_type is not 'page', the parameter is ignored. You can set the page template for a non-page by calling [[Function Reference/update_post_meta|update_post_meta()]] with a key of '_wp_page_template'.
{{Parameter|$wp_error|bool|Allow return of [[Class Reference/WP_Error|WP_Error]] object on failure|optional|false}}
==Return==
The ID of the post if the post is successfully added to the database. On failure, it returns &lt;tt&gt;0&lt;/tt&gt; if $wp_error is set to false, or a [[Class Reference/WP_Error|WP_Error]] object if $wp_error is set to true.
==Usage==
%%% &lt;?php wp_insert_post( $post, $wp_error ); ?&gt; %%%
==Example==
Before calling wp_insert_post() it is necessary to create an array to pass the necessary elements that make up a post. The wp_insert_post() will fill out a default list of these but the user is required to provide the title and content otherwise the database write will fail.
The next example shows the post title, content, status, author, and post categories being set. You can add further key-value pairs, making sure the keys match the names of the columns in the wp_posts table in the database.
&lt;pre&gt;
// Create post object
$my_post = array(
'post_title' =&gt; 'My post',
'post_content' =&gt; 'This is my post.',
'post_status' =&gt; 'publish',
'post_author' =&gt; 1,
'post_category' =&gt; array(8,39)
);
// Insert the post into the database
wp_insert_post( $my_post );
&lt;/pre&gt;
Insert a new post and return the new post id.
&lt;pre&gt;
$post_id = wp_insert_post( $post, $wp_error );
//now you can use $post_id withing add_post_meta or update_post_meta
&lt;/pre&gt;
The default list referred to above is defined in the function body. It is as follows:
&lt;pre&gt;
$defaults = array(
'post_status' =&gt; 'draft',
'post_type' =&gt; 'post',
'post_author' =&gt; $user_ID,
'ping_status' =&gt; get_option('default_ping_status'),
'post_parent' =&gt; 0,
'menu_order' =&gt; 0,
'to_ping' =&gt; '',
'pinged' =&gt; '',
'post_password' =&gt; '',
'guid' =&gt; '',
'post_content_filtered' =&gt; '',
'post_excerpt' =&gt; '',
'import_id' =&gt; 0
);
&lt;/pre&gt;
===Categories===
Categories need to be passed as an array of integers that match the category IDs in the database. This is the case even where only one category is assigned to the post.
See also: [[Function_Reference/wp_set_post_terms|wp_set_post_terms()]]
==Security==
&lt;tt&gt;wp_insert_post()&lt;/tt&gt; passes data through sanitize_post(), which itself handles all necessary sanitization and validation (kses, etc.).
As such, you don't need to worry about that.
You may wish, however, to remove HTML, JavaScript, and PHP tags from the post_title and any other fields. Surprisingly, WordPress does not do this automatically. This can be easily done by using the wp_strip_all_tags() function (as of 2.9) and is especially useful when building front-end post submission forms.
&lt;pre&gt;
// Create post object
$my_post = array(
'post_title' =&gt; wp_strip_all_tags( $_POST['post_title'] ),
'post_content' =&gt; $_POST['post_content'],
'post_status' =&gt; 'publish',
'post_author' =&gt; 1,
'post_category' =&gt; array( 8,39 )
);
// Insert the post into the database
wp_insert_post( $my_post );
&lt;/pre&gt;
==Change Log==
* Since: [[Version 1.0|1.0]]
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_insert_post()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
==Related==
[[Function Reference/wp update post|wp_update_post()]],
[[Function Reference/wp delete post|wp_delete_post()]],
[[Function Reference/wp publish post|wp_publish_post()]],
[[Function Reference/wp delete attachment|wp_delete_attachment()]],
[[Function Reference/wp get attachment url|wp_get_attachment_url()]],
[[Function Reference/wp insert attachment|wp_insert_attachment()]],
[[Plugin API/Filter Reference/wp insert post data|wp_insert_post_data()]]
{{Tag Footer}}
{{Copyedit}}
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="wp_clear_scheduled_hook" d:title="wp clear scheduled hook">
<d:index d:value="wp clear scheduled hook"/>
<h1>wp clear scheduled hook</h1>
<p>== Description ==
Un-schedules all previously-scheduled cron jobs using a particular hook name or a specific combination of hook name and arguments.
== Usage ==
%%% &lt;?php wp_clear_scheduled_hook( $hook, $args ); ?&gt; %%%
== Parameters ==
{{Parameter|$hook|string|The name of an action hook to execute.}}
{{Parameter|$args|array|Arguments to pass to the hook function(s)|optional}}
== Return Value ==
No value is returned by this function.
== Examples ==
=== Clear a scheduled event ===
&lt;pre&gt;
// If you previously added for example
// wp_schedule_single_event( time() + 3600, 'my_new_event' );
wp_clear_scheduled_hook( 'my_new_event' );
// or this if you created something like
// wp_schedule_single_event( time() + 3600, 'my_new_event', array( 'some_arg' ) );
wp_clear_scheduled_hook( 'my_new_event', array( 'some_arg' ) );
&lt;/pre&gt;
== Notes ==
If you created a scheduled job using a hook and arguments you cannot delete it by supplying only the hook. Similarly if you created a set of scheduled jobs that share a hook but have different arguments you cannot delete them using only the hook name, you have to delete them all individually using the hook name and arguments.
== Change Log ==
Since: [[Version 2.1|2.1.0]]
== Source File ==
&lt;tt&gt;wp_clear_scheduled_hook()&lt;/tt&gt; is located in {{Trac|wp-includes/cron.php}}
== Related ==
{{Cron Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_unschedule_event" d:title="wp unschedule event">
<d:index d:value="wp unschedule event"/>
<h1>wp unschedule event</h1>
<p>== Description ==
Unschedules a previously-scheduled cron job.
Note that you need to know the exact time of the next occurrence when scheduled hook was set to run, and the function arguments it was supposed to have, in order to unschedule it. All future occurrences are unscheduled by calling this function.
== Usage ==
%%% &lt;?php wp_unschedule_event( $timestamp, $hook, $args ); ?&gt; %%%
== Parameters ==
{{Parameter|$timestamp|integer|Timestamp originally provided for when to run the event.|required}}
{{Parameter|$hook|string|Action hook originally provided, the execution of which will be unscheduled.|required}}
{{Parameter|$args|array|Arguments to pass to the hook's callback function. These arguments are used to uniquely identify the scheduled event, so they must be the same as those used when originally scheduling the event.|optional|&lt;tt&gt;array()&lt;/tt&gt;}}
== Return Value ==
This function does not return a value.
== Example ==
&lt;pre&gt;
&lt;?php
// Get the timestamp for the next event.
$timestamp = wp_next_scheduled( 'my_schedule_hook' );
// If this event was created with any special arguments, you need to get those too.
$original_args = array();
wp_unschedule_event( $timestamp, 'my_schedule_hook', $original_args );
?&gt;
&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: [[Version 2.1|2.1.0]]
== Source File ==
&lt;tt&gt;wp_unschedule_event()&lt;/tt&gt; is located in {{Trac|wp-includes/cron.php}}
== Related ==
* [[Function_Reference/wp_schedule_event|wp_schedule_event]]
* [[Function_Reference/wp_reschedule_event | wp_reschedule_event]]
* [[Function_Reference/wp_schedule_single_event|wp_schedule_single_event]]
* [[Function_Reference/wp_clear_scheduled_hook|wp_clear_scheduled_hook]]
* [[Function_Reference/wp_next_scheduled|wp_next_scheduled]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:WP-Cron Functions]]</p>
</d:entry>
<d:entry id="wp_next_scheduled" d:title="wp next scheduled">
<d:index d:value="wp next scheduled"/>
<h1>wp next scheduled</h1>
<p>== Description ==
Returns the next timestamp for a cron event.
== Usage ==
%%%&lt;?php $timestamp = wp_next_scheduled( $hook, $args ); ?&gt;%%%
== Parameters ==
{{Parameter|$hook|string|Name of the action hook for event.}}
{{Parameter|$args|array|Arguments to pass to the hook function(s).|optional}}
== Return Value ==
{{Return||string&amp;#124;boolean|Timestamp, the time the scheduled event will next occur (unix timestamp). False, if the event isn't scheduled.}}
== Notes ==
* Cron is named after a unix program which runs unattended scheduled tasks.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;wp_next_scheduled()&lt;/tt&gt; is located in {{Trac|wp-includes/cron.php}}
== Related ==
* [[Function_Reference/wp_schedule_event|wp_schedule_event]]
* [[Function_Reference/wp_schedule_single_event|wp_schedule_single_event]]
* [[Function_Reference/wp_clear_scheduled_hook|wp_clear_scheduled_hook]]
* [[Function_Reference/wp_unschedule_event|wp_unschedule_event]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New page created]]
[[Category:WP-Cron Functions]]</p>
</d:entry>
<d:entry id="wp_schedule_event" d:title="wp schedule event">
<d:index d:value="wp schedule event"/>
<h1>wp schedule event</h1>
<p>== Description ==
Schedules a hook which will be executed by the WordPress actions core on a specific interval, specified by you. The action will trigger when someone visits your WordPress site, if the scheduled time has passed. See the [[Plugin API]] for a list of hooks.
== Usage ==
%%% &lt;?php wp_schedule_event($timestamp, $recurrence, $hook, $args); ?&gt; %%%
== Parameters ==
{{Parameter|$timestamp|integer|The first time that you want the event to occur. This must be in a UNIX timestamp format. WP cron uses UTC/GMT time, not local time. Use &lt;tt&gt;[http://php.net/manual/en/function.time.php time()]&lt;/tt&gt;, which is always GMT in WordPress. (&lt;tt&gt;[[Function_Reference/current_time|current_time( 'timestamp' )]]&lt;/tt&gt; is local time in WordPress.)}}
{{Parameter|$recurrence|string|How often the event should reoccur. Valid values are below. You can create custom intervals using the &lt;tt&gt;cron_schedules&lt;/tt&gt; filter in &lt;tt&gt;[[Function_Reference/wp_get_schedules|wp_get_schedules()]]&lt;/tt&gt;. &lt;ul&gt;&lt;li&gt;&lt;tt&gt;hourly&lt;/tt&gt;&lt;/li&gt;&lt;li&gt;&lt;tt&gt;twicedaily&lt;/tt&gt;&lt;/li&gt;&lt;li&gt;&lt;tt&gt;daily&lt;/tt&gt;&lt;/li&gt;&lt;/ul&gt;}}
{{Parameter|$hook|string|The name of an action hook to execute. For some reason there seems to be a problem on some systems where the hook must not contain underscores or uppercase characters.}}
{{Parameter|$args|array|Arguments to pass to the hook function(s).|optional}}
== Return Value ==
{{Return||boolean&amp;#124;null|False on failure, null when complete with scheduling event.}}
== Examples ==
=== Schedule an hourly event ===
To schedule an hourly event in a plugin, call &lt;tt&gt;wp_schedule_event&lt;/tt&gt; on activation (otherwise you will end up with a lot of scheduled events!):
&lt;pre&gt;
register_activation_hook( __FILE__, 'prefix_activation' );
/**
* On activation, set a time, frequency and name of an action hook to be scheduled.
*/
function prefix_activation() {
wp_schedule_event( time(), 'hourly', 'prefix_hourly_event_hook' );
}
add_action( 'prefix_hourly_event_hook', 'prefix_do_this_hourly' );
/**
* On the scheduled action hook, run the function.
*/
function prefix_do_this_hourly() {
// do something every hour
}
&lt;/pre&gt;
Don't forget to clean the scheduler on deactivation:
&lt;pre&gt;
register_deactivation_hook( __FILE__, 'prefix_deactivation' );
/**
* On deactivation, remove all functions from the scheduled action hook.
*/
function prefix_deactivation() {
wp_clear_scheduled_hook( 'prefix_hourly_event_hook' );
}
&lt;/pre&gt;
=== A simple way to schedule an hourly event ===
This example doesn't rely on plugin activation (via the plugins directory) rather it simply adds the event if it is missing.
&lt;pre&gt;
add_action( 'wp', 'prefix_setup_schedule' );
/**
* On an early action hook, check if the hook is scheduled - if not, schedule it.
*/
function prefix_setup_schedule() {
if ( ! wp_next_scheduled( 'prefix_hourly_event' ) ) {
wp_schedule_event( time(), 'hourly', 'prefix_hourly_event');
}
}
add_action( 'prefix_hourly_event', 'prefix_do_this_hourly' );
/**
* On the scheduled action hook, run a function.
*/
function prefix_do_this_hourly() {
// do something every hour
}
&lt;/pre&gt;
== Notes ==
The array passed as the &lt;tt&gt;$args&lt;/tt&gt; parameter needs to be an indexed array. Each element in the array is sliced into a separate argument in the &lt;tt&gt;do_action_ref_array()&lt;/tt&gt; call. Despite the name, your array is not passed by reference.
When you add the action that calls your scheduled function, you must specify a priority and the number of elements in the array. Your scheduled function declaration must accept each array element as individual parameters
Example passing multiple arguments
&lt;pre&gt;add_action('wp', 'prefix_setup_schedule');
function prefix_setup_schedule() {
if ( ! wp_next_scheduled('prefix_hourly_event')) {
wp_schedule_event( time(), 'hourly', 'prefix_hourly_event',
array( 'example', 'values')
);
}
}
add_action('prefix_hourly_event', 'prefix_do_this_hourly', 10 ,2 );
function prefix_do_this_hourly( $parm1, $parm2 ) {
error_log(&quot;Function prefix_do_this_hourly() received '$parm1' and '$parm2' as parameters.&quot;);
}
// PHP error log will have this line entered every hour:
// Function prefix_do_this_hourly() received 'example' and 'values' as parameters.&lt;/pre&gt;
= Cron Data =
Cron data is saved to the options table. Use &lt;tt&gt;get_option('cron');&lt;/tt&gt; to get the cron array from the database.
== Change Log ==
Since: [[Version 2.1|2.1.0]]
== Source File ==
&lt;tt&gt;wp_schedule_event()&lt;/tt&gt; is located in {{Trac|wp-includes/cron.php}}
== Related ==
* [[Function_Reference/wp_schedule_event|wp_schedule_event]]
* [[Function_Reference/wp_schedule_single_event|wp_schedule_single_event]]
* [[Function_Reference/wp_clear_scheduled_hook|wp_clear_scheduled_hook]]
* [[Function_Reference/wp_next_scheduled|wp_next_scheduled]]
* [[Function_Reference/wp_unschedule_event|wp_unschedule_event]]
* [[Function_Reference/wp_get_schedule|wp_get_schedule]]
== Further Reading ==
For a comprehensive list of functions, take a look at the [http://codex.wordpress.org/Category:Functions category Functions]
Also, see [[Function_Reference]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New page created]]
[[Category:WP-Cron Functions]]</p>
</d:entry>
<d:entry id="wp_schedule_single_event" d:title="wp schedule single event">
<d:index d:value="wp schedule single event"/>
<h1>wp schedule single event</h1>
<p>== Description ==
Schedules a hook which will be executed once by the WordPress actions core at a time which you specify. The action will fire off when someone visits your WordPress site, if the schedule time has passed.
== Usage ==
%%% &lt;?php wp_schedule_single_event( $timestamp, $hook, $args ); ?&gt; %%%
Note that scheduling an event to occur before 10 minutes after an existing event of the same name will be ignored, unless you pass unique values for &lt;tt&gt;$args&lt;/tt&gt; to each scheduled event. See &lt;tt&gt;[[Function_Reference/wp_next_scheduled | wp_next_scheduled()]]&lt;/tt&gt; for more information.
&lt;i&gt;This behavior is subject to change, as the [https://core.trac.wordpress.org/ticket/6966 original intention] of the code was to prevent scheduling two identical events within ten minutes of each other, not preventing scheduling of identical events until ten minutes after the next scheduled occurrence.&lt;/i&gt;
Attempts to schedule an event after an event of the same name and &lt;tt&gt;$args&lt;/tt&gt; will also be ignored.
== Parameters ==
{{Parameter|$timestamp|integer|The time you want the event to occur. This must be in a UNIX timestamp format.}}
{{Parameter|$hook|string|The name of an action hook to execute.}}
{{Parameter|$args|array|Arguments to pass to the hook function(s)|optional|&lt;tt&gt;array()&lt;/tt&gt;}}
== Return Value ==
{{Return||boolean&amp;#124;null|False if the event was cancelled by a plugin, &lt;tt&gt;null&lt;/tt&gt; otherwise.}}
== Examples ==
=== Schedule an event one hour from now ===
&lt;pre&gt;
function do_this_in_an_hour() {
// do something
}
add_action( 'my_new_event','do_this_in_an_hour' );
// put this line inside a function,
// presumably in response to something the user does
// otherwise it will schedule a new event on every page visit
wp_schedule_single_event( time() + 3600, 'my_new_event' );
// time() + 3600 = one hour from now.
&lt;/pre&gt;
=== Schedule an event one hour from now with arguments ===
&lt;pre&gt;
function do_this_in_an_hour( $arg1, $arg2, $arg3 ) {
// do something
}
add_action( 'my_new_event', 'do_this_in_an_hour', 10, 3 );
// put this line inside a function,
// presumably in response to something the user does
// otherwise it will schedule a new event on every page visit
wp_schedule_single_event( time() + 3600, 'my_new_event', array( $arg1, $arg2, $arg3 ) );
// time() + 3600 = one hour from now.
&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: [[Version 2.1|2.1.0]]
== Source File ==
&lt;tt&gt;wp_schedule_single_event()&lt;/tt&gt; is located in {{Trac|wp-includes/cron.php}}
== Related ==
{{Cron Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:WP-Cron Functions]]</p>
</d:entry>
<d:entry id="get_tag_link" d:title="get tag link">
<d:index d:value="get tag link"/>
<h1>get tag link</h1>
<p>{{Languages|
{{en|Function Reference/get_tag_link}}
{{it|Riferimento funzioni/get_tag_link}}
{{ja|関数リファレンス/get_tag_link}}
}}
== Description ==
Returns the correct link url for a given Tag ID.
== Usage ==
&lt;a href=&quot;&lt;?php echo get_tag_link($tag_id); ?&gt;&quot;&gt;tag name&lt;/a&gt;
== Parameters ==
{{Parameter|$tag_id|integer|The Tag ID.}}
== Return Values ==
{{Return|URL|string|URL with a link to the tag.}}
== Filters ==
Output from this function is [[Plugin_API/Filter_Reference | filtered]] by the 'tag_link' filter. The first argument ($taglink) is the url as the function would normally output it, the second is the ID passed into the function.
[[Function Reference/apply_filters|apply_filters]]('tag_link', $taglink, $tag_id);
== Source File ==
&lt;tt&gt;get_tag_link()&lt;/tt&gt; is located in {{Trac|wp-includes/category-template.php}}.
== Related ==
{{Tag Tags}}
[[Function_Reference/get_the_terms|get_the_terms()]],
[[Function_Reference/get_term_link|get_term_link()]],
[[Function_Reference/wp_get_object_terms|wp_get_object_terms()]]
{{Tag Footer}}
[[Category:Functions]]
{{Copyedit}}</p>
</d:entry>
<d:entry id="get_categories" d:title="get categories">
<d:index d:value="get categories"/>
<h1>get categories</h1>
<p>{{Languages|
{{en|Function Reference/get_categories}}
{{ja|関数リファレンス/get_categories}}
}}
== Description ==
Returns an array of category objects matching the query parameters.
Arguments are pretty much the same as [[Template_Tags/wp_list_categories|wp_list_categories]] and can be passed as either array or in query syntax. &lt;!--The array returned seems to be always flat (no nesting for subcategories) but I'm not sure yet.--&gt;
== Usage ==
%%% &lt;?php $categories = get_categories( $args ); ?&gt; %%%
=== Default Usage ===
&lt;pre&gt;&lt;?php
$args = array(
'type' =&gt; 'post',
'child_of' =&gt; 0,
'parent' =&gt; '',
'orderby' =&gt; 'name',
'order' =&gt; 'ASC',
'hide_empty' =&gt; 1,
'hierarchical' =&gt; 1,
'exclude' =&gt; '',
'include' =&gt; '',
'number' =&gt; '',
'taxonomy' =&gt; 'category',
'pad_counts' =&gt; false
);
?&gt;&lt;/pre&gt;
== Parameters ==
; '''type''' : (''string'') Type of category to retrieve
:* &lt;tt&gt;post&lt;/tt&gt; - default
:* &lt;tt&gt;link&lt;/tt&gt;
''&lt;span style=&quot;color:red;&quot;&gt;Note:&lt;/span&gt;'' '''&lt;tt&gt;type=link&lt;/tt&gt;''' has been deprecated from WordPress 3.0 onwards. Use '''&lt;tt&gt;taxonomy=link_category&lt;/tt&gt;''' instead.
; '''child_of''' : (''integer'') Display all categories that are descendants (i.e. children &amp; grandchildren) of the category identified by its ID. There is no default for this parameter. If the parameter is used, the '''hide_empty''' parameter is set to ''false''.
; '''parent''' : (''integer'') Display only categories that are direct descendants (i.e. children only) of the category identified by its ID. This does NOT work like the 'child_of' parameter. There is no default for this parameter. [In 2.8.4]
; '''orderby''' : (''string'') Sort categories alphabetically or by unique category ID. The default is ''sort by name''. Valid values:
:* &lt;tt&gt;id&lt;/tt&gt;
:* &lt;tt&gt;name&lt;/tt&gt; - default
:* &lt;tt&gt;slug&lt;/tt&gt;
:* &lt;tt&gt;count&lt;/tt&gt;
:* &lt;tt&gt;term_group&lt;/tt&gt;
; '''order''' : (''string'') Sort order for categories (either ascending or descending). The default is ''ascending''. Valid values:
:* &lt;tt&gt;asc&lt;/tt&gt; - default
:* &lt;tt&gt;desc&lt;/tt&gt;
; '''hide_empty''' : (''boolean'') Toggles the display of categories with no posts. The default is ''1'' for true or you can add '0' for false (show empty categories). Valid values:
:* &lt;tt&gt;1&lt;/tt&gt; - default
:* &lt;tt&gt;0&lt;/tt&gt;
; '''hierarchical''' : (''boolean'') When ''true'', the results will include sub-categories that are empty, as long as those sub-categories have sub-categories that are not empty. The default is ''true''. Valid values:
:* &lt;tt&gt;1 (true)&lt;/tt&gt; - default
:* &lt;tt&gt;0 (false)&lt;/tt&gt;
; '''exclude''' : (''string'') Excludes one or more categories from the list generated by ''wp_list_categories''. This parameter takes a comma-separated list of categories by unique ID, in ascending order. See [[Template_Tags/wp_list_categories#Include_or_Exclude_Categories|the example]].
; '''include''' : (''string'') Only include certain categories in the list generated by ''wp_list_categories''. This parameter takes a comma-separated list of categories by unique ID, in ascending order. See [[Template_Tags/wp_list_categories#Include_or_Exclude_Categories|the example]].
:* &lt;tt&gt;list&lt;/tt&gt; - default.
:* &lt;tt&gt;none&lt;/tt&gt;
; '''number''' : (''string'') The number of categories to return
; '''taxonomy''' : (''string or array'') Taxonomy to return. This parameter added at [[Version 3.0]] Valid values:
:* &lt;tt&gt;category&lt;/tt&gt; - default
:* &lt;tt&gt;taxonomy&lt;/tt&gt; - or any registered taxonomy
; '''pad_counts''' : (''boolean'') Calculates link or post counts by including items from child categories. Valid values:
:* &lt;tt&gt;1 (true)&lt;/tt&gt;
:* &lt;tt&gt;0 (false)&lt;/tt&gt; - default
== Return values ==
; (array) : Returns an array of category objects matching the query parameters.
The complete content of $category is:
&lt;pre&gt;
$category-&gt;term_id
$category-&gt;name
$category-&gt;slug
$category-&gt;term_group
$category-&gt;term_taxonomy_id
$category-&gt;taxonomy
$category-&gt;description
$category-&gt;parent
$category-&gt;count
$category-&gt;cat_ID
$category-&gt;category_count
$category-&gt;category_description
$category-&gt;cat_name
$category-&gt;category_nicename
$category-&gt;category_parent
&lt;/pre&gt;
== Examples ==
=== Dropdown Box as used in Parent category at post category page ===
This is the code used in the build in category page.
Code from 3.0.1
&lt;pre&gt;
wp_dropdown_categories(array('hide_empty' =&gt; 0, 'name' =&gt; 'category_parent', 'orderby' =&gt; 'name', 'selected' =&gt; $category-&gt;parent, 'hierarchical' =&gt; true, 'show_option_none' =&gt; __('None')));&lt;/pre&gt;
This slightly altered code will grab all categories and display them with indent for a new level (child category). The select box will have a name= and id= called 'select_name'.
This select will not display a default &quot;none&quot; as the original code was used to attach a category as a child to another category (or none).
&lt;pre&gt;
wp_dropdown_categories(array('hide_empty' =&gt; 0, 'name' =&gt; 'select_name', 'hierarchical' =&gt; true));
&lt;/pre&gt;
=== Dropdown Box ===
Here's how to create a dropdown box of the subcategories of, say, a category that archives information on past events. This mirrors the example of the dropdown example of [[Template_Tags/wp_get_archives | wp_get_archives]] which shows how to create a dropdown box for monthly archives.
Suppose the category whose subcategories you want to show is category 10, and that its category &quot;nicename&quot; is &quot;archives&quot;.
&lt;pre&gt;
&lt;select name=&quot;event-dropdown&quot; onchange='document.location.href=this.options[this.selectedIndex].value;'&gt;
&lt;option value=&quot;&quot;&gt;&lt;?php echo esc_attr(__('Select Event')); ?&gt;&lt;/option&gt;
&lt;?php
$categories = get_categories('child_of=10');
foreach ($categories as $category) {
$option = '&lt;option value=&quot;/category/archives/'.$category-&gt;category_nicename.'&quot;&gt;';
$option .= $category-&gt;cat_name;
$option .= ' ('.$category-&gt;category_count.')';
$option .= '&lt;/option&gt;';
echo $option;
}
?&gt;
&lt;/select&gt;
&lt;/pre&gt;
===List Categories and Descriptions===
This example will list in alphabetic order, all categories presented as links to the corresponding category archive. Each category descripition is listed after the category link.
&lt;pre&gt;
&lt;?php
$args = array(
'orderby' =&gt; 'name',
'order' =&gt; 'ASC'
);
$categories = get_categories($args);
foreach($categories as $category) {
echo '&lt;p&gt;Category: &lt;a href=&quot;' . get_category_link( $category-&gt;term_id ) . '&quot; title=&quot;' . sprintf( __( &quot;View all posts in %s&quot; ), $category-&gt;name ) . '&quot; ' . '&gt;' . $category-&gt;name.'&lt;/a&gt; &lt;/p&gt; ';
echo '&lt;p&gt; Description:'. $category-&gt;description . '&lt;/p&gt;';
echo '&lt;p&gt; Post Count: '. $category-&gt;count . '&lt;/p&gt;'; }
?&gt;
&lt;/pre&gt;
===Get only top level categories ===
To get the top level categories only, set parent value to zero. This example gets link and name of top level categories.
&lt;pre&gt;
&lt;?php
$args = array(
'orderby' =&gt; 'name',
'parent' =&gt; 0
);
$categories = get_categories( $args );
foreach ( $categories as $category ) {
echo '&lt;a href=&quot;' . get_category_link( $category-&gt;term_id ) . '&quot;&gt;' . $category-&gt;name . '&lt;/a&gt;&lt;br/&gt;';
}
?&gt;
&lt;/pre&gt;
== Source File ==
&lt;tt&gt;get_categories()&lt;/tt&gt; is located in {{Trac|wp-includes/category.php}}.
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_enqueue_script" d:title="wp enqueue script">
<d:index d:value="wp enqueue script"/>
<h1>wp enqueue script</h1>
<p>__TOC__
{{Languages|
{{en|Function Reference/wp_enqueue_script}}
{{es|Referencia de Funciones/wp_enqueue_script}}
{{ja|関数リファレンス/wp_enqueue_script}}
{{ko|Function Reference/wp_enqueue_script}}
{{ru|Справочник по функциям/wp_enqueue_script}}
{{zh-cn|函数参考/wp_enqueue_script}}
}}
== Description ==
Links a script file to the generated page at the right time according to the script dependencies, if the script has not been already included and if all the dependencies have been registered. You could either link a script with a handle previously registered using the &lt;tt&gt;[[Function Reference/wp_register_script|wp_register_script()]]&lt;/tt&gt; function, or provide this function with all the parameters necessary to link a script.
This is the recommended method of linking JavaScript to a WordPress generated page.
== Usage ==
%%%&lt;?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?&gt;%%%
See [[#Notes|Notes]] for information about what action [[Glossary#Hook|hooks]] should be used to call the function.
== Parameters ==
{{Parameter|$handle|string|Name used as a handle for the script. As a special case, if the string contains a '?' character, the preceding part of the string refers to the registered handle, and the succeeding part is appended to the URL as a query string. A version must be used with this special case.}}
{{Parameter|$src|string|URL to the script, e.g. ''http://&lt;nowiki/&gt;example.com/wp-content/themes/my-theme/my-theme-script.js''. You should never hardcode URLs to local scripts. To get a&nbsp;proper URL to local scripts, use &lt;tt&gt;[[Function Reference/plugins_url|plugins_url()]]&lt;/tt&gt; for [[Glossary#Plugin|plugins]] and &lt;tt&gt;[[Function Reference/get_template_directory_uri|get_template_directory_uri()]]&lt;/tt&gt; for [[Glossary#Themes|themes]]. Remote scripts can be specified with a protocol-agnostic URL, e.g.&nbsp;''//otherdomain.com/js/their-script.js''. This parameter is only required when the script with the given &lt;tt&gt;$handle&lt;/tt&gt; has not been already registered using &lt;tt&gt;[[Function Reference/wp_register_script|wp_register_script()]]&lt;/tt&gt;. See [[#Default Scripts Included and Registered by WordPress|Default Scripts Included and Registered by WordPress]].|optional|false}}
{{Parameter|$deps|array|Array of the handles of all the registered scripts that this script depends on, that is the scripts that must be loaded before this script. This parameter is only required when the script with the given &lt;tt&gt;$handle&lt;/tt&gt; has not been already registered using &lt;tt&gt;[[Function Reference/wp_register_script|wp_register_script()]]&lt;/tt&gt;. Default handles are all in lower case.|optional|array()}}
{{Parameter|$ver|string|String specifying the script version number, if it has one, which is concatenated to the end of the path as a query string. If no version is specified or set to ''false'', then WordPress automatically adds a version number equal to the current version of WordPress you are running. If set to ''null'' no version is added. This parameter is used to ensure that the correct version is sent to the client regardless of caching, and so should be included if a version number is available and makes sense for the script.|optional|false}}
{{Parameter|$in_footer|boolean|Normally, scripts are placed in &lt;tt&gt;&lt;head&gt;&lt;/tt&gt; of the HTML document. If this parameter is ''true'', the script is placed before the &lt;tt&gt;&lt;/body&gt;&lt;/tt&gt; end tag. This requires the theme to have the &lt;tt&gt;[[Plugin API/Action Reference/wp footer|wp_footer()]]&lt;/tt&gt; template tag in the appropriate place.|optional|false}}
== Return Values ==
{{Return||void|This function does not return a value.}}
== Examples ==
== Using a Hook ==
Scripts and styles from a single action hook
&lt;pre&gt;
/**
* Proper way to enqueue scripts and styles
*/
function theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() );
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
&lt;/pre&gt;
=== Link the script.aculo.us Library ===
The following is an example of basic usage which links the script.aculo.us library [[#Default_Scripts_Included_and_Registered_by_WordPress|already included and registered]] by WordPress with the ''scriptaculous'' handle.
&lt;pre&gt;
&lt;?php
function my_scripts_method() {
wp_enqueue_script( 'scriptaculous' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method' ); // wp_enqueue_scripts action hook to link only on the front-end
?&gt;
&lt;/pre&gt;
The above example links the script.aculo.us library only on the front-end. If the library was needed within the [[Administration Screens|administration screens]], you could use the [[Plugin_API/Action_Reference/admin_enqueue_scripts|admin_enqueue_scripts]] action [[Glossary#Hook|hook]] instead, however, this would enqueue it on ''all'' the administration screens, which often leads to plugin/core conflicts, ultimately breaking the WordPress administration screens experience. Instead, you should only link it on the individual screens you need it, see the [[#Link_Scripts_Only_on_a_Plugin_Administration_Screen|Link Scripts Only on a Plugin Administration Screen]] section for an example of that.
=== Link a Theme Script Which Depends on jQuery ===
JavaScript files included in themes often require another JavaScript file to be loaded in advance to use its functions or variables. [[#Parameters|Using the &lt;tt&gt;$deps&lt;/tt&gt; parameter]], the &lt;tt&gt;wp_enqueue_script()&lt;/tt&gt; and &lt;tt&gt;[[Function Reference/wp_register_script|wp_register_script()]]&lt;/tt&gt; functions allows you to mark dependencies when registering a new script. This will cause WordPress to automatically link these dependencies to the HTML page before the new script is linked. If the [[#Default_Scripts_Included_and_Registered_by_WordPress|handles]] of these dependencies are [[Function Reference/wp_deregister_script|not registered]], WordPress will not link the new script. This example requires the jQuery library for the ''custom_script.js'' theme script:
&lt;pre&gt;
&lt;?php
function my_scripts_method() {
wp_enqueue_script(
'custom-script',
get_stylesheet_directory_uri() . '/js/custom_script.js',
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
?&gt;
&lt;/pre&gt;
=== Link a Plugin Script That Depends on script.aculo.us ===
This example is intended to be used within a [[Writing a Plugin#Plugin_Files|plugin file]] to register and link a new plugin script that depends on the script.aculo.us library. See the [[#Link_a_Theme_Script_Which_Depends_on_jQuery|example above]] for information about dependencies.
&lt;pre&gt;
&lt;?php
function my_scripts_method() {
wp_enqueue_script(
'newscript',
plugins_url( '/js/newscript.js' , __FILE__ ),
array( 'scriptaculous' )
);
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
?&gt;
&lt;/pre&gt;
=== Link Scripts Only on a Plugin Administration Screen ===
This example links a script only on a specific [[Administration Screens|administration screen]], as opposed to the scenario described in the paragraph below the code of the [[#Link_the_script.aculo.us_Library|first example]].
&lt;pre&gt;
&lt;?php
add_action( 'admin_init', 'my_plugin_admin_init' );
add_action( 'admin_menu', 'my_plugin_admin_menu' );
function my_plugin_admin_init() {
/* Register our script. */
wp_register_script( 'my-plugin-script', plugins_url( '/script.js', __FILE__ ) );
}
function my_plugin_admin_menu() {
/* Add our plugin submenu and administration screen */
$page_hook_suffix = add_submenu_page( 'edit.php', // The parent page of this submenu
__( 'My Plugin', 'myPlugin' ), // The submenu title
__( 'My Plugin', 'myPlugin' ), // The screen title
'manage_options', // The capability required for access to this submenu
'my_plugin-options', // The slug to use in the URL of the screen
'my_plugin_manage_menu' // The function to call to display the screen
);
/*
* Use the retrieved $page_hook_suffix to hook the function that links our script.
* This hook invokes the function only on our plugin administration screen,
* see: http://codex.wordpress.org/Administration_Menus#Page_Hook_Suffix
*/
add_action('admin_print_scripts-' . $page_hook_suffix, 'my_plugin_admin_scripts');
}
function my_plugin_admin_scripts() {
/* Link our already registered script to a page */
wp_enqueue_script( 'my-plugin-script' );
}
function my_plugin_manage_menu() {
/* Display our administration screen */
}
?&gt;
&lt;/pre&gt;
=== Load a Script from a Child Theme without Dependencies ===
Register and enqueue the script in the same callback function with no dependencies, in the footer. See [[Function_Reference/wp_register_script|wp_register_script()]] for details. In this example, &lt;tt&gt;google_analytics_object.js&lt;/tt&gt; is the Google Analytics tracking code (provided by Google) in a file.
&lt;pre&gt;
&lt;?php
add_action( 'wp_enqueue_scripts', 'child_add_scripts' );
/**
* Register and enqueue a script that does not depend on a JavaScript library.
*/
function child_add_scripts() {
wp_register_script(
'google-analytics',
get_stylesheet_directory_uri() . '/google_analytics_object.js',
false,
'1.0',
true
);
wp_enqueue_script( 'google-analytics' );
}
&lt;/pre&gt;
== jQuery noConflict Wrappers ==
The jQuery library included with WordPress is set to the [http://docs.jquery.com/Using_jQuery_with_Other_Libraries ''noConflict()''] mode (see {{Trac|wp-includes/js/jquery/jquery.js|tags/{{CurrentVersion}}|3}}). This is to prevent compatibility problems with other JavaScript libraries that WordPress can link.
In the ''noConflict()'' mode, the global &lt;tt&gt;$&lt;/tt&gt; shortcut for &lt;tt&gt;jQuery&lt;/tt&gt; is not available, so you can still use:
&lt;pre&gt;
jQuery(document).ready(function(){
jQuery(#somefunction) ...
});
&lt;/pre&gt;
but the following will either throw an error, or use the &lt;tt&gt;$&lt;/tt&gt; shortcut as assigned by other library.
&lt;pre&gt;
$(document).ready(function(){
$(#somefunction) ...
});
&lt;/pre&gt;
However, if you really like the short &lt;tt&gt;$&lt;/tt&gt; instead of &lt;tt&gt;jQuery&lt;/tt&gt;, you can use the following wrapper around your code:
&lt;pre&gt;
jQuery(document).ready(function($) {
// Inside of this function, $() will work as an alias for jQuery()
// and other libraries also using $ will not be accessible under this shortcut
});
&lt;/pre&gt;
That wrapper will cause your code to be executed when the DOM is fully constructed. If, for some reason, you want your code to execute immediately instead of waiting for the [http://api.jquery.com/ready/ DOM ready] event, then you can use this wrapper method instead:
&lt;pre&gt;
(function($) {
// Inside of this function, $() will work as an alias for jQuery()
// and other libraries also using $ will not be accessible under this shortcut
})(jQuery);
&lt;/pre&gt;
Alternatively, you can always reasign &lt;tt&gt;jQuery&lt;/tt&gt; to another shortcut of your choice and leave the &lt;tt&gt;$&lt;/tt&gt; shorcut to other libraries:
&lt;pre&gt;
var $j = jQuery;
&lt;/pre&gt;
== Default Scripts Included and Registered by WordPress ==
By default, WordPress installation includes many popular scripts commonly used by web developers besides the scripts used by WordPress itself. Some of them are listed in the table below.
For a detailed list of names that can be used in place of the &lt;code&gt;$handle&lt;/code&gt; parameter, see [[Function Reference/wp_register_script#Handles and Their Script Paths Registered by WordPress|Handles and Their Script Paths Registered by WordPress]].
Note that in [[Version 3.5]], WordPress changed its naming convention for minified scripts and styles. Before, minified scripts and styles had the ''.js'' and ''.css'' extensions, unminified had ''.dev.js'' and ''.dev.css''. However, following the change, the extensions are ''.min.js'' and ''.min.css'' for minified files, ''.js'' and ''.css'' for unminified, respectively.
{| class=&quot;wikitable&quot; style=&quot;width:100%;&quot;
|-
! width=&quot;25%&quot; | '''Script Name'''
! width=&quot;35%&quot; | '''Handle'''
! width=&quot;40%&quot; | '''Needed Dependency *'''
|-
| [http://www.defusion.org.uk/ Image Cropper]
| Image cropper (not used in core, see jcrop)
|-
| [http://deepliquid.com/content/Jcrop.html Jcrop]
| jcrop
|-
| [http://code.google.com/p/swfobject/ SWFObject]
| swfobject
|-
| [http://swfupload.org/ SWFUpload]
| swfupload
|-
| [http://swfupload.org/ SWFUpload Degrade]
| swfupload-degrade
|-
| [http://swfupload.org/ SWFUpload Queue]
| swfupload-queue
|-
| [http://swfupload.org/ SWFUpload Handlers]
| swfupload-handlers
|-
| [http://jquery.com/ jQuery]
| jquery
| json2 (for AJAX calls)
|-
| [http://plugins.jquery.com/project/form/ jQuery Form]
| jquery-form
| jquery
|-
| [http://plugins.jquery.com/project/color/ jQuery Color]
| jquery-color
| jquery
|-
| [http://masonry.desandro.com/ jQuery Masonry]
| jquery-masonry
| jquery
|-
| [http://jqueryui.com/ jQuery UI Core]
| jquery-ui-core
| jquery
|-
| jQuery UI Widget
| jquery-ui-widget
| jquery
|-
| jQuery UI Mouse
| jquery-ui-mouse
| jquery
|-
| [http://jqueryui.com/demos/accordion/ jQuery UI Accordion]
| jquery-ui-accordion
| jquery
|-
| [http://jqueryui.com/demos/autocomplete/ jQuery UI Autocomplete]
| jquery-ui-autocomplete
| jquery
|-
| [http://jqueryui.com/demos/slider/ jQuery UI Slider]
| jquery-ui-slider
| jquery
|-
| [http://jqueryui.com/demos/progressbar/ jQuery UI Progressbar]
| jquery-ui-progressbar
| jquery
|-
| [http://jqueryui.com/demos/tabs/ jQuery UI Tabs]
| jquery-ui-tabs
| jquery
|-
| [http://jqueryui.com/demos/sortable/ jQuery UI Sortable]
| jquery-ui-sortable
| jquery
|-
| [http://jqueryui.com/demos/draggable/ jQuery UI Draggable]
| jquery-ui-draggable
| jquery
|-
| [http://jqueryui.com/demos/droppable/ jQuery UI Droppable]
| jquery-ui-droppable
| jquery
|-
| [http://jqueryui.com/demos/selectable/ jQuery UI Selectable]
| jquery-ui-selectable
| jquery
|-
| [http://jqueryui.com/demos/position/ jQuery UI Position]
| jquery-ui-position
| jquery
|-
| [http://jqueryui.com/demos/datepicker/ jQuery UI Datepicker]
| jquery-ui-datepicker
| jquery
|-
| [http://jqueryui.com/demos/tooltip/ jQuery UI Tooltips]
| jquery-ui-tooltip
| jquery
|-
| [http://jqueryui.com/demos/resizable/ jQuery UI Resizable]
| jquery-ui-resizable
| jquery
|-
| [http://jqueryui.com/demos/dialog/ jQuery UI Dialog]
| jquery-ui-dialog
| jquery
|-
| [http://jqueryui.com/demos/button/ jQuery UI Button]
| jquery-ui-button
| jquery
|-
| [http://jqueryui.com/effect/ jQuery UI Effects]
| jquery-effects-core
| jquery
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Blind]
| jquery-effects-blind
| jquery-effects-core
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Bounce]
| jquery-effects-bounce
| jquery-effects-core
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Clip]
| jquery-effects-clip
| jquery-effects-core
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Drop]
| jquery-effects-drop
| jquery-effects-core
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Explode]
| jquery-effects-explode
| jquery-effects-core
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Fade]
| jquery-effects-fade
| jquery-effects-core
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Fold]
| jquery-effects-fold
| jquery-effects-core
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Highlight]
| jquery-effects-highlight
| jquery-effects-core
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Pulsate]
| jquery-effects-pulsate
| jquery-effects-core
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Scale]
| jquery-effects-scale
| jquery-effects-core
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Shake]
| jquery-effects-shake
| jquery-effects-core
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Slide]
| jquery-effects-slide
| jquery-effects-core
|-
| [http://jqueryui.com/effect/ jQuery UI Effects - Transfer]
| jquery-effects-transfer
| jquery-effects-core
|-
| [http://mediaelementjs.com/ MediaElement.js (WP 3.6+)]
| wp-mediaelement
| jquery
|-
| [http://trainofthoughts.org/blog/2007/02/15/jquery-plugin-scheduler/ jQuery Schedule]
| schedule
| jquery
|-
| [https://web.archive.org/web/20111017233444/http://plugins.jquery.com/project/suggest jQuery Suggest]
| suggest
| jquery
|-
| [http://codex.wordpress.org/ThickBox ThickBox]
| thickbox
|-
| [http://cherne.net/brian/resources/jquery.hoverIntent.html jQuery HoverIntent]
| hoverIntent
| jquery
|-
| [http://plugins.jquery.com/project/hotkeys jQuery Hotkeys]
| jquery-hotkeys
| jquery
|-
| [http://code.google.com/p/tw-sack/ Simple AJAX Code-Kit]
| sack
|-
| [http://www.alexking.org QuickTags]
| quicktags
|-
| [https://github.com/automattic/Iris Iris (Colour picker)]
| iris
| jquery
|-
| [http://acko.net/dev/farbtastic Farbtastic (deprecated)]
| farbtastic
| jquery
|-
| [http://mattkruse.com ColorPicker (deprecated)]
| colorpicker
| jquery
|-
| [http://tinymce.moxiecode.com/ Tiny MCE]
| tiny_mce
|-
| Autosave
| autosave
|-
| WordPress AJAX Response
| wp-ajax-response
|-
| List Manipulation
| wp-lists
|-
| WP Common
| common
|-
| WP Editor
| editorremov
|-
| WP Editor Functions
| editor-functions
|-
| AJAX Cat
| ajaxcat
|-
| Admin Categories
| admin-categories
|-
| Admin Tags
| admin-tags
|-
| Admin custom fields
| admin-custom-fields
|-
| Password Strength Meter
| password-strength-meter
|-
| Admin Comments
| admin-comments
|-
| Admin Users
| admin-users
|-
| Admin Forms
| admin-forms
|-
| XFN
| xfn
|-
| Upload
| upload
|-
| PostBox
| postbox
|-
| Slug
| slug
|-
| Post
| post
|-
| Page
| page
|-
| Link
| link
|-
| Comment
| comment
|-
| Threaded Comments
| comment-reply
|-
| Admin Gallery
| admin-gallery
|-
| Media Upload
| media-upload
|-
| Admin widgets
| admin-widgets
|-
| Word Count
| word-count
|-
| Theme Preview
| theme-preview
|-
| [https://github.com/douglascrockford/JSON-js JSON for JS]
| json2
|-
| [http://www.plupload.com/ Plupload Core]
| plupload
|-
| [http://www.plupload.com/example_all_runtimes.php Plupload All Runtimes]
| plupload-all
|-
| [http://www.plupload.com/example_all_runtimes.php Plupload HTML4]
| plupload-html4
|-
| [http://www.plupload.com/example_all_runtimes.php Plupload HTML5]
| plupload-html5
|-
| [http://www.plupload.com/example_all_runtimes.php Plupload Flash]
| plupload-flash
|-
| [http://www.plupload.com/example_all_runtimes.php Plupload Silverlight]
| plupload-silverlight
|-
| [http://underscorejs.org/ Underscore js]
| underscore
|-
| [http://backbonejs.org/ Backbone js]
| backbone
|}
{| class=&quot;wikitable&quot; style=&quot;width:100%;&quot;
|-
! colspan=4 | '''Removed from Core'''
|-
! width=&quot;25%&quot; | '''Script Name'''
! width=&quot;30%&quot; | '''Handle'''
! width=&quot;20%&quot; | '''Removed Version'''
! width=&quot;25%&quot; | '''Replaced With'''
|-
| [http://script.aculo.us Scriptaculous Root]
| scriptaculous-root
| WP 3.5
| Google Version
|-
| [http://script.aculo.us Scriptaculous Builder]
| scriptaculous-builder
| WP 3.5
| Google Version
|-
| [http://script.aculo.us Scriptaculous Drag &amp;amp; Drop]
| scriptaculous-dragdrop
| WP 3.5
| Google Version
|-
| [http://script.aculo.us Scriptaculous Effects]
| scriptaculous-effects
| WP 3.5
| Google Version
|-
| [http://script.aculo.us Scriptaculous Slider]
| scriptaculous-slider
| WP 3.5
| Google Version
|-
| [http://script.aculo.us/ Scriptaculous] Sound
| scriptaculous-sound
| WP 3.5
| Google Version
|-
| [http://script.aculo.us Scriptaculous Controls]
| scriptaculous-controls
| WP 3.5
| Google Version
|-
| [http://script.aculo.us Scriptaculous]
| scriptaculous
| WP 3.5
| Google Version
|-
| [http://www.prototypejs.org/ Prototype Framework]
| prototype
| WP 3.5
| Google Version
|-
|}
'''The list is far from complete.''' For a complete list of registered files inspect &lt;tt&gt;$GLOBALS['wp_scripts']&lt;/tt&gt; in the admin UI. Registered scripts might change per requested page.
--------
''* The listed dependencies are not complete.''
== Notes ==
* The function should be called using the [[Plugin API/Action Reference/wp_enqueue_scripts|wp_enqueue_scripts]] action [[Glossary#Hook|hook]] if you want to call it on the front-end of the site, like in the [[#Examples|examples above]]. To call it on the [[Administration Screens|administration screens]], use the [[Plugin_API/Action_Reference/admin_enqueue_scripts|admin_enqueue_scripts]] action hook. For the [[Login Screen|login screen]], use the [[Plugin_API/Action_Reference/login_enqueue_scripts|login_enqueue_scripts]] action hook. Calling it outside of an action hook can lead to problems, see the [http://core.trac.wordpress.org/ticket/11526 ticket #11526] for details.
* Prior to [[Version 3.3]], the function will have no effect if it is called using the [[Plugin_API/Action_Reference/wp_head|wp_head]] or [[Plugin_API/Action_Reference/wp_print_scripts|wp_print_scripts]] action hooks or later, as this is too late to enqueue the files even if the &lt;tt&gt;$in_footer&lt;/tt&gt; parameter is set to ''true''.
* As of [[Version 3.3]], the function can be called mid-page (before the &lt;tt&gt;[[Plugin API/Action Reference/wp footer|wp_footer()]]&lt;/tt&gt; template tag) or using the [[Plugin_API/Action_Reference/wp_head|wp_head]] action hook. This will place the script in the footer as if the &lt;tt&gt;$in_footer&lt;/tt&gt; parameter was set to ''true''.
* If you try to register or enqueue an already registered handle with different parameters, the new parameters will be ignored. Instead, use &lt;tt&gt;[[Function_Reference/wp_deregister_script|wp_deregister_script()]]&lt;/tt&gt; and register the script again with the new parameters.
* jQuery UI Effects is '''not''' included with the ''jquery-ui-core'' handle.
* Uses: &lt;tt&gt;WP_Scripts::add()&lt;/tt&gt;, &lt;tt&gt;WP_Scripts::add_data()&lt;/tt&gt; and &lt;tt&gt;WP_Scripts::enqueue()&lt;/tt&gt;.
* Uses global: (&lt;tt&gt;unknown type&lt;/tt&gt;) &lt;tt&gt;$wp_scripts&lt;/tt&gt;.
== Change Log ==
* Since: [[Version 2.6|2.6]] (BackPress version: r16)
== Source File ==
&lt;tt&gt;wp_enqueue_script()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.wp-scripts.php}}.
==Resources==
* [http://www.prelovac.com/vladimir/best-practice-for-adding-javascript-code-to-wordpress-plugin Best practice for adding JavaScript code to WordPress plugins]
*[http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/ How To: Load Javascript With Your WordPress Plugin]
*[http://noteslog.com/post/how-to-load-javascript-in-wordpress-plugins/ How to load JavaScript in WordPress plugins]
*[http://themocracy.com/2009/04/using-jquery-with-wordpress/ Using jQuery with WordPress]
*[http://www.devlounge.net/articles/using-javascript-and-css-with-your-wordpress-plugin Using JavaScript and CSS with your WordPress Plugin]
* [http://www.lost-in-code.com/platforms/wordpress/wordpress-using-javascript-libraries-with-your-plugin-or-theme/ Using Javascript libraries with your Wordpress plugin or theme]
* [http://www.ericmmartin.com/5-tips-for-using-jquery-with-wordpress/ 5 Tips For Using jQuery with WordPress]
* [http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/ How to Include CSS and JavaScript Conditionally, and Only When Needed by the Posts]
* [http://fusi0n.org/coding/make-your-wordpress-plugins-use-a-different-version-of-a-bundled-javascript-library Make Your WordPress Plugins Use a Different Version of a Bundled JavaScript Library] Replacing built-in JavaScript libraries is usually a bad idea. Do this only on sites you administer personally.
* [http://scribu.net/wordpress/optimal-script-loading.html How to load JavaScript like a WordPress Master] Highly recommended.
* [http://justintadlock.com/archives/2009/08/06/how-to-disable-scripts-and-styles How to disable scripts and styles]
* [http://twentyfiveautumn.com/2012/03/14/loading-javascript-on-the-frontend-with-your-wordpress-plugin/ Loading javascript on the frontend with your WordPress plugin]
* [http://www.cybersprocket.com/?s=wordpress+javascript JavaScript Tips and Tricks for WordPress 3.x]
* [[ThickBox|Developing for WordPress's customized version of ThickBox]]
* [http://generatewp.com/register_script/ WordPress Script Registration Generator]
== Related ==
{{Enqueue Functions Related}}
{{Tag Footer}}
{{Copyedit}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_option" d:title="get option">
<d:index d:value="get option"/>
<h1>get option</h1>
<p>{{Languages|
{{en|Function Reference/get option}}
{{es|Referencia de Funciones/get option}}
{{it|Riferimento funzioni/get_option}}
{{ja|関数リファレンス/get_option}}
{{ru|Справочник_по_функциям/get option}}
{{vi|Tham Khảo C&aacute;c H&agrave;m/get option}}
{{zh-cn|get_option}}
}}
== Description ==
A safe way of getting values for a named [[Option_Reference|option]] from the options database table. If the desired option does not exist, or no value is associated with it, &lt;tt&gt;FALSE&lt;/tt&gt; will be returned.
== Usage ==
%%% &lt;?php echo get_option( $option, $default ); ?&gt; %%%
== Parameters ==
{{Parameter|$option|string|Name of the option to retrieve. A concise list of valid options is below, but a more complete one can be found at the [[Option Reference]]. Matches &lt;tt&gt;$option_name&lt;/tt&gt; in &lt;tt&gt;[[Function Reference/register setting|register_setting()]]&lt;/tt&gt; for custom options.}}
:* &lt;tt&gt;'admin_email'&lt;/tt&gt; - E-mail address of blog administrator.
:* &lt;tt&gt;'blogname'&lt;/tt&gt; - Weblog title; set in General Options.
:* &lt;tt&gt;'blogdescription'&lt;/tt&gt; - Tagline for your blog; set in General Options.
:* &lt;tt&gt;'blog_charset'&lt;/tt&gt; - Character encoding for your blog; set in Reading Options.
:* &lt;tt&gt;'date_format'&lt;/tt&gt; - Default date format; set in General Options.
:* &lt;tt&gt;'default_category'&lt;/tt&gt; - Default post category; set in Writing Options.
:* &lt;tt&gt;'home'&lt;/tt&gt; - The blog's home web address; set in General Options.
:* &lt;tt&gt;'siteurl'&lt;/tt&gt; - WordPress web address; set in General Options.&lt;br /&gt;'''Warning:''' This is not the same as &lt;tt&gt;get_bloginfo('siteurl')&lt;/tt&gt; (which will return the homepage url), but as &lt;tt&gt;get_bloginfo('wpurl')&lt;/tt&gt;.
:* &lt;tt&gt;'template'&lt;/tt&gt; - The current theme's name; set in Presentation.
:* &lt;tt&gt;'start_of_week'&lt;/tt&gt; - Day of week calendar should start on; set in General Options.
:* &lt;tt&gt;'upload_path'&lt;/tt&gt; - Default upload location; set in Miscellaneous Options.
:* &lt;tt&gt;'posts_per_page'&lt;/tt&gt; - Maximum number of posts to show on a page; set in Reading Options.
:* &lt;tt&gt;'posts_per_rss'&lt;/tt&gt; - Maximum number of most recent posts to show in the syndication feed; set in Reading Options.
:There are many more options available, a lot of which depend on what plugins you have installed. Visit the &lt;tt&gt;[[Settings_General_Screen | /wp-admin/options.php]]&lt;/tt&gt; page for a complete list.
Underscores separate words, lowercase only - this is going to be in a database.
{{Parameter|$default|mixed|The default value to return if no value is returned (ie. the option is not in the database).|optional|&lt;tt&gt;false&lt;/tt&gt;}}
== Return Values ==
; (mixed) : Current value for the specified option. If the specified option does not exist, returns boolean &lt;tt&gt;FALSE&lt;/tt&gt;.
== Examples ==
%%%&lt;?php
$no_exists_value = get_option( 'no_exists_value' );
var_dump( $no_exists_value ); /* outputs false */
$no_exists_value = get_option( 'no_exists_value', 'default_value' );
var_dump( $no_exists_value ); /* outputs 'default_value' */
?&gt;%%%
=== Show Blog Title ===
Displays your blog's title in a &lt;tt&gt;&amp;lt;h1&amp;gt;&lt;/tt&gt; tag.
%%% &lt;h1&gt;&lt;?php echo get_option( 'blogname' ); ?&gt;&lt;/h1&gt; %%%
=== Show Character Set ===
Displays the character set your blog is using (ex: UTF-8)
%%% &lt;p&gt;Character set: &lt;?php echo get_option( 'blog_charset' ); ?&gt; &lt;/p&gt; %%%
===Retrieve Administrator E-mail===
Retrieve the e-mail of the blog administrator, storing it in a variable.
%%% &lt;?php $admin_email = get_option( 'admin_email' ); ?&gt; %%%
== Notes ==
* Uses: &lt;tt&gt;[[Function_Reference/apply_filters | apply_filters()]]&lt;/tt&gt;
** Calls &lt;tt&gt;[[Plugin_API/Filter_Reference/pre_option_$option | 'pre_option_$option']]&lt;/tt&gt; before checking the option. Any value other than &lt;tt&gt;false&lt;/tt&gt; will &quot;short-circuit&quot; the retrieval of the option and return the returned value. You should not try to override special options, but you will not be prevented from doing so.
** Calls &lt;tt&gt;[[Plugin_API/Filter_Reference/'option_$option' | 'option_$option']]&lt;/tt&gt;, after checking the option, with the option value.
** Calls &lt;tt&gt;[[Plugin_API/Filter_Reference/default_option_$option | 'default_option_$option']]&lt;/tt&gt; to filter &lt;tt&gt;$default&lt;/tt&gt; before returning it if it is set and the value doesn't exist.
* Uses: &lt;tt&gt;[[Function_Reference/maybe_unserialize | maybe_unserialize()]]&lt;/tt&gt; to unserialize the value before returning it.
== Changelog ==
* Since 1.5.0
== Source File ==
&lt;code&gt;get_option()&lt;/code&gt; is located in {{Trac|wp-includes/option.php}}.
== Related ==
{{Option Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_taxonomy" d:title="is taxonomy">
<d:index d:value="is taxonomy"/>
<h1>is taxonomy</h1>
<p>[[Function Reference|''&amp;larr; Return to function reference.'']]
{{Deprecated}}
== Description ==
'''This function is deprecated as of [[Version 3.0]]. Please use [[Function_Reference/is_tax]] instead.'''
This [[Conditional Tags|Conditional Tag]] checks if the taxonomy name exists by passing a taxonomy name as an argument to it. This is a boolean function uses a global &lt;tt&gt;$wp_taxonomies&lt;/tt&gt; variable for checking if taxonomy name existence, meaning it returns either TRUE if the taxonomy name exist or FALSE if it doesn't exist.
==Usage==
%%%&lt;?php is_taxonomy($taxonomy); ?&gt;%%%
==Parameters==
{{Parameter|$taxonomy|string|The name of the taxonomy}}
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
$taxonomy_exist = is_taxonomy('category');
//returns true
$taxonomy_exist = is_taxonomy('post_tag');
//returns true
$taxonomy_exist = is_taxonomy('link_category');
//returns true
$taxonomy_exist = is_taxonomy('my_taxonomy');
//returns false if global $wp_taxonomies['my_taxonomy'] is not set
==Notes==
* See Also: [[WordPress_Taxonomy]].
==Change Log==
Since: 2.3.0
==Source File==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_taxonomy()&lt;/tt&gt; is located in {{Trac|wp-includes/taxonomy.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_post" d:title="get post">
<d:index d:value="get post"/>
<h1>get post</h1>
<p>{{Languages|
{{en|Function Reference/get post}}
{{it|Riferimento_funzioni/get_post}}
{{ja|関数リファレンス/get post}}
{{ru|Справочник_по_функциям/get_post}}
{{tr|Fonksiyon Referans/get post}}
}}
==Description==
Takes a post ID and returns the database record for that post. You can specify, by means of the &lt;tt&gt;$output&lt;/tt&gt; parameter, how you would like the results returned.
==Usage==
%%%&lt;?php get_post( $id, $output, $filter ); ?&gt; %%%
==Parameters==
{{Parameter|$id|integer or object|The ID of the post you'd like to fetch, or an object that specifies the post. By default the current post is fetched.|optional|null}}
{{Parameter|$output|string|How you'd like the result. &lt;ul&gt;&lt;li&gt;''OBJECT'' - (''default'') returns a &lt;tt&gt;[[Class_Reference/WP_Post|WP_Post]]&lt;/tt&gt; object&lt;/li&gt;&lt;li&gt;''ARRAY_A'' - Returns an associative array of field names to values&lt;/li&gt;&lt;li&gt;''ARRAY_N'' - returns a numeric array of field values&lt;/li&gt;&lt;/ul&gt;|optional|OBJECT}}
{{Parameter|$filter|string|Filter the post. See [[Function_Reference/sanitize_post_field | sanitize_post_field()]] for a full list of values. &lt;ul&gt;&lt;li&gt;''raw'' - (''default'')&lt;/li&gt;&lt;/ul&gt;|optional|raw}}
==Return Values==
Returns a &lt;tt&gt;&lt;b&gt;[[Class_Reference/WP_Post|WP_Post]]&lt;/b&gt;&lt;/tt&gt; object, or &lt;tt&gt;&lt;b&gt;null&lt;/b&gt;&lt;/tt&gt; if the post doesnt exist or an error occurred.
==Example==
To get the title for a post with ID 7:
%%%&lt;?php
$post_7 = get_post(7);
$title = $post_7-&gt;post_title;
?&gt; %%%
Alternatively, specify the &lt;tt&gt;$output&lt;/tt&gt; parameter:
%%%&lt;?php
$post_7 = get_post(7, ARRAY_A);
$title = $post_7['post_title'];
?&gt; %%%
== Notes ==
Before version 3.5, the first parameter &lt;tt&gt;$post&lt;/tt&gt; was required to be a variable. For example, &lt;tt&gt;get_post(7)&lt;/tt&gt; would cause a fatal error.
== Source File ==
&lt;tt&gt;get_post()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}} and {{Trac|wp-includes/class-wp-atom-server.php}}.
== Change Log ==
*Since [[Version_1.5.1 | 1.5.1]]
*[[Version_3.5 | 3.5.0]] - the &lt;tt&gt;$post&lt;/tt&gt; parameter is no longer passed by reference.
== Related ==
* &lt;tt&gt;[[Function_Reference/get_post_field | get_post_field()]]&lt;/tt&gt; - Retrieve data from a post field based on post ID.
{{Tag Footer}}
{{Copyedit}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_user_logged_in" d:title="is user logged in">
<d:index d:value="is user logged in"/>
<h1>is user logged in</h1>
<p>{{Languages|
{{en|Function Reference/is_user_logged_in}}
{{it|Riferimento funzioni/is_user_logged_in}}
{{ja|関数リファレンス/is_user_logged_in}}
}}
== Description ==
This [[Conditional Tags|Conditional Tag]] checks if the current visitor is logged in. This is a boolean function, meaning it returns either TRUE or FALSE.
== Usage ==
%%% &lt;?php if ( is_user_logged_in() ) { ... } ?&gt; %%%
== Parameters ==
This function does not accept any parameters.
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True if user is logged in, false if not logged in.
== Examples ==
Display different output depending on whether the user is logged in or not.
&lt;pre&gt;&lt;?php
if ( is_user_logged_in() ) {
echo 'Welcome, registered user!';
} else {
echo 'Welcome, visitor!';
}
?&gt;&lt;/pre&gt;
From your functions file, this code displays a personal message for logged in users.
&lt;pre&gt;add_action( 'loop_start', 'personal_message_when_logged_in' );
function personal_message_when_logged_in() {
if ( is_user_logged_in() ) :
$current_user = wp_get_current_user();
echo 'Personal Message For ' . $current_user-&gt;user_firstname . '!';
else :
echo 'Non Personalized Message!';
endif;
}&lt;/pre&gt;
== Change Log ==
Since: [[Version 2.0|2.0.0]]
== Source File ==
&lt;tt&gt;is_user_logged_in()&lt;/tt&gt; is located in {{Trac|wp-includes/pluggable.php}}.
== Related ==
{{Conditional Tags}}
{{Login Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="Pluggable_Functions" d:title="Pluggable Functions">
<d:index d:value="Pluggable Functions"/>
<h1>Pluggable Functions</h1>
<p>Pluggable functions were introduced in [[Version 1.5.1|WordPress 1.5.1]] These functions let you override certain core functions via [[Plugin API|plugins]]. The most up-to-date list of core functions that WordPress allows plugins to override is available at {{Trac|wp-includes/pluggable.php}}. WordPress loads the built-in functions only if they are undefined after all plugins have been loaded.
Pluggable functions are no longer being added to WordPress core. All new functions instead use filters on their output to allow for similar overriding of their functionality.
'''Note:''' A function can only be reassigned this way once, so you can&rsquo;t install two plugins that plug the same function for different reasons. For safety, it is best to always wrap your functions with &lt;code&gt;if ( !function_exists() )&lt;/code&gt;, otherwise you '''will''' produce fatal errors on plugin activation.
== Full list of Pluggable Functions: ==
{| class=&quot;widefat&quot;
|- style=&quot;background:#464646; color:#d7d7d7;&quot;
! width=&quot;100%&quot; | '''Version 3.5'''
|-
|
*wp-includes\pluggable.php
** [[Function Reference/auth_redirect|auth_redirect]]
** [[Function Reference/cache_users|cache_users]]
** [[Function Reference/check_admin_referer|check_admin_referer]]
** [[Function Reference/check_ajax_referer|check_ajax_referer]]
** [[Function Reference/get_avatar|get_avatar]]
** [[Function Reference/get_currentuserinfo|get_currentuserinfo]]
** [[Function Reference/get_user_by_email|get_user_by_email]] (deprecated)
** [[Function Reference/get_user_by|get_user_by]]
** [[Function Reference/get_userdatabylogin|get_userdatabylogin]] (deprecated)
** [[Function Reference/get_userdata|get_userdata]]
** [[Function Reference/is_user_logged_in|is_user_logged_in]]
** [[Function Reference/wp_authenticate|wp_authenticate]]
** [[Function Reference/wp_check_password|wp_check_password]]
** [[Function Reference/wp_clear_auth_cookie|wp_clear_auth_cookie]]
** [[Function Reference/wp_create_nonce|wp_create_nonce]]
** [[Function Reference/wp_generate_auth_cookie|wp_generate_auth_cookie]]
** [[Function Reference/wp_generate_password|wp_generate_password]]
** [[Function Reference/wp_get_current_user|wp_get_current_user]]
** [[Function Reference/wp_hash_password|wp_hash_password]]
** [[Function Reference/wp_hash|wp_hash]]
** [[Function Reference/wp_logout|wp_logout]]
** [[Function Reference/wp_mail|wp_mail]]
** [[Function Reference/wp_new_user_notification|wp_new_user_notification]]
** [[Function Reference/wp_nonce_tick|wp_nonce_tick]]
** [[Function Reference/wp_notify_moderator|wp_notify_moderator]]
** [[Function Reference/wp_notify_postauthor|wp_notify_postauthor]]
** [[Function Reference/wp_parse_auth_cookie|wp_parse_auth_cookie]]
** [[Function Reference/wp_password_change_notification|wp_password_change_notification]]
** [[Function Reference/wp_rand|wp_rand]]
** [[Function Reference/wp_redirect|wp_redirect]]
** [[Function Reference/wp_safe_redirect|wp_safe_redirect]]
** [[Function Reference/wp_salt|wp_salt]]
** [[Function Reference/wp_sanitize_redirect|wp_sanitize_redirect]]
** [[Function Reference/wp_set_auth_cookie|wp_set_auth_cookie]]
** [[Function Reference/wp_set_current_user|wp_set_current_user]]
** [[Function Reference/wp_set_password|wp_set_password]]
** [[Function Reference/wp_text_diff|wp_text_diff]]
** [[Function Reference/wp_validate_auth_cookie|wp_validate_auth_cookie]]
** [[Function Reference/wp_validate_redirect|wp_validate_redirect]]
** [[Function Reference/wp_verify_nonce|wp_verify_nonce]]
|}
== Reference ==
; [[Function_Reference/get_currentuserinfo|&lt;tt&gt;get_currentuserinfo()&lt;/tt&gt;]] : Grabs the information of the current logged in user, if there is one. Essentially a wrapper for get_userdata(), but it also stores information in global variables.
; [[Function_Reference/get_userdata|&lt;tt&gt;get_userdata($userid)&lt;/tt&gt;]] : Pulls user information for the specified user from the database.
; [[Function Reference/wp_mail|&lt;tt&gt;wp_mail($to, $subject, $message, $headers = &lt;nowiki&gt;''&lt;/nowiki&gt;)&lt;/tt&gt;]] : A convenient wrapper for PHP's mail function.
; &lt;tt&gt;wp_login($username, $password, $already_md5 = false)&lt;/tt&gt; : Returns &lt;tt&gt;true&lt;/tt&gt; if the specified username and password correspond to a registered user.
; &lt;tt&gt;auth_redirect()&lt;/tt&gt; : If a user is not logged in, he or she will be redirected to WordPress' login page before being allowed to access content on the page from which this function was called. Upon successfully logging in, the user is sent back to the page in question.
; [[Function Reference/wp_redirect|&lt;tt&gt;wp_redirect($location)&lt;/tt&gt;]] : Redirects a browser to the ''absolute URI'' specified by the &lt;tt&gt;$location&lt;/tt&gt; parameter.
; &lt;tt&gt;&lt;nowiki&gt;wp_notify_postauthor($comment_id, $comment_type='')&lt;/nowiki&gt;&lt;/tt&gt;: Emails the author of the comment's post the content of the comment specified.
; &lt;tt&gt;wp_notify_moderator($comment_id)&lt;/tt&gt; : Informs the administrative email account that the comment specified needs to be moderated. See [[Administration_Panels|Administration]] &gt; [[Administration_Panels#General|Settings]] &gt; [[Settings_General_SubPanel|General]].
== Example ==
An example of what you can do with a pluggable function is replace the default email handler. To do this, you'd need to write a plugin that defines a &lt;tt&gt;wp_mail()&lt;/tt&gt; function. The default &lt;tt&gt;wp_mail()&lt;/tt&gt; function looks like this:
&lt;pre&gt;
function wp_mail( $to, $subject, $message, $headers = '' ) {
if( $headers == '' ) {
$headers = &quot;MIME-Version: 1.0\n&quot; .
&quot;From: &quot; . get_settings('admin_email') . &quot;\n&quot; .
&quot;Content-Type: text/plain; charset=\&quot;&quot; . get_settings('blog_charset') . &quot;\&quot;\n&quot;;
}
return @mail( $to, $subject, $message, $headers );
}
&lt;/pre&gt;
But, for example, if you wanted to CC all your mail to another address, you could use this code in a plugin:
&lt;pre&gt;
if( ! function_exists('wp_mail') ) {
function wp_mail( $to, $subject, $message, $headers = '' ) {
if( $headers == '' ) {
$headers = &quot;MIME-Version: 1.0\n&quot; .
&quot;From: &quot; . get_settings('admin_email') . &quot;\n&quot; .
&quot;Cc: dummy@example.com\n&quot; .
&quot;Content-Type: text/plain; charset=\&quot;&quot; . get_settings('blog_charset') . &quot;\&quot;\n&quot;;
}
return @mail($to, $subject, $message, $headers);
}
}
&lt;/pre&gt;
Notice that if you plug a core function like this the original is no longer available. I.e., the elegant solution here would have been to write a function that tacks our Cc header on the end of the exising &lt;tt&gt;$headers&lt;/tt&gt; string then call the original &lt;tt&gt;wp_mail()&lt;/tt&gt; with the extra header. However this would not work as the original &lt;tt&gt;wp_mail()&lt;/tt&gt; does not exist if you plug it.
[[Category:Functions]]
[[Category:Pluggable Functions]]</p>
</d:entry>
<d:entry id="plugin_basename" d:title="plugin basename">
<d:index d:value="plugin basename"/>
<h1>plugin basename</h1>
<p>== Description ==
Gets the path to a plugin file or directory, relative to the [[Glossary#Plugin|plugins]] directory, without the leading and trailing slashes.
== Usage ==
%%% &lt;?php plugin_basename($file); ?&gt; %%%
== Parameters ==
{{Parameter|$file|string|Absolute path to a plugin file or directory within the plugins directory.}}
== Return ==
{{Return||string| Path to a plugin file or directory, relative to the plugins directory (without the leading and trailing slashes).}}
== Example ==
If your plugin file is located at ''/home/www/wp-content/plugins/&lt;b&gt;my-plugin/my-plugin.php&lt;/b&gt;'', and you call:
$x = plugin_basename(__FILE__);
The &lt;tt&gt;$x&lt;/tt&gt; variable will equal to &quot;''&lt;b&gt;my-plugin/my-plugin.php&lt;/b&gt;''&quot;.
== Notes ==
* Uses both the &lt;tt&gt;WP_PLUGIN_DIR&lt;/tt&gt; and &lt;tt&gt;WPMU_PLUGIN_DIR&lt;/tt&gt; constants internally, to test for and strip the plugins directory path from the &lt;tt&gt;$file&lt;/tt&gt; path. Note that the direct usage of WordPress internal constants [[Determining Plugin and Content Directories|is not recommended]].
== Change Log ==
* Since: [[Version 1.5|1.5]]
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;plugin_basename()&lt;/tt&gt; is located in {{Trac|wp-includes/plugin.php}}.
== Related ==
{{Tag Plugin Paths}}
{{Directory URL Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_mail" d:title="wp mail">
<d:index d:value="wp mail"/>
<h1>wp mail</h1>
<p>== Description ==
Send mail, similar to PHP's &lt;tt&gt;[http://php.net/manual/en/function.mail.php mail()]&lt;/tt&gt;.
The default sender name is &quot;WordPress&quot; and the default sender email address is wordpress@yoursite.com. These may be overridden by including a header like:
&lt;pre&gt;From: &quot;Example User&quot; &lt;email@example.com&gt;&lt;/pre&gt;
Then, the optional hooks &lt;tt&gt;[[Plugin_API/Filter_Reference/wp_mail_from | 'wp_mail_from']]&lt;/tt&gt; and &lt;tt&gt;[[Plugin_API/Filter_Reference/wp_mail_from_name | 'wp_mail_from_name']]&lt;/tt&gt; are run on the sender email address and name. The return values are reassembled into a 'from' address like &lt;tt&gt;'&quot;Example User&quot; &lt;email@address.com&gt;'&lt;/tt&gt; If only &lt;tt&gt;'wp_mail_from'&lt;/tt&gt; returns a value, then just the email address will be used with no name.
The default content type is &lt;tt&gt;'text/plain'&lt;/tt&gt; which does not allow using HTML. You can set the content type of the email either by using the &lt;tt&gt;[[Plugin_API/Filter_Reference/wp_mail_content_type | 'wp_mail_content_type']]&lt;/tt&gt; filter (see example below), or by including a header like &lt;tt&gt;&quot;Content-type: text/html&quot;&lt;/tt&gt;. Be careful to reset &lt;tt&gt;'wp_mail_content_type'&lt;/tt&gt; back to &lt;tt&gt;'text/plain'&lt;/tt&gt; after you send your message, though, because [http://core.trac.wordpress.org/ticket/23578 failing to do so could lead to unexpected problems with e-mails from WP or plugins/themes].
The default charset is based on the charset used on the blog. The charset can be set using the &lt;tt&gt;[[Plugin_API/Filter_Reference/wp_mail_charset | 'wp_mail_charset']]&lt;/tt&gt; filter.
== Usage ==
%%% &lt;?php wp_mail( $to, $subject, $message, $headers, $attachments ); ?&gt; %%%
== Parameters ==
{{Parameter|$to|string or array|The intended recipient(s). Multiple recipients may be specified using an array or a comma-separated string.}}
{{Parameter|$subject|string|The subject of the message.}}
{{Parameter|$message|string|Message content.}}
{{Parameter|$headers|string or array|Mail headers to send with the message. For the string version, each header line (beginning with From:, Cc:, etc.) is delimited with a newline (&quot;\r\n&quot;) (advanced)|optional|''Empty''}}
{{Parameter|$attachments|string or array|Files to attach: a single filename, an array of filenames, or a newline-delimited string list of multiple filenames. (advanced)|optional|''Empty''}}
== Return ==
; (bool) : Whether the email contents were sent successfully.
A &lt;tt&gt;true&lt;/tt&gt; return value does not automatically mean that the user received the email successfully. It just only means that the method used was able to process the request without any errors.
== Valid Address Formats ==
All email addresses supplied to &lt;tt&gt;wp_mail()&lt;/tt&gt; as the &lt;tt&gt;$to&lt;/tt&gt; parameter must comply with [http://www.faqs.org/rfcs/rfc2822.html RFC 2822]. Some valid examples:
*user@example.com
*user@example.com, anotheruser@example.com
*User &lt;user@example.com&gt;
*User &lt;user@example.com&gt;, Another User &lt;anotheruser@example.com&gt;
The same applies to Cc: and Bcc: fields in &lt;tt&gt;$headers&lt;/tt&gt;, but as noted in the next section, it's better to push multiple addresses into an array instead of listing them on a single line. Either address format, with or without the user name, may be used.
== Using $headers To Set &quot;From:&quot;, &quot;Cc:&quot; and &quot;Bcc:&quot; Parameters ==
To set the &quot;From:&quot; email address to something other than the WordPress default sender (see [[#Description]] above), or to add &quot;Cc:&quot; and/or &quot;Bcc:&quot; recipients, you must use the &lt;tt&gt;$headers&lt;/tt&gt; argument.
&lt;tt&gt;$headers&lt;/tt&gt; can be a string or an array, but is probably easiest to use in its array form. To use it, push a string onto the array, starting with &quot;From:&quot;, &quot;Bcc:&quot; or &quot;Cc:&quot; (note the use of the &quot;:&quot;), followed by a valid email address.
When you're using the array form, you do not need to supply linebreaks (&lt;tt&gt;&quot;\n&quot;&lt;/tt&gt; or &lt;tt&gt;&quot;\r\n&quot;&lt;/tt&gt;). Although the function can handle multiple emails per line, it may simply be easier to push each email address separately onto the &lt;tt&gt;$headers&lt;/tt&gt; array. The function will figure it out and will build the proper Mime header automagically. Just don't forget that each string you push must have the header type as the first part of the string (&quot;From:&quot;, &quot;Cc:&quot; or &quot;Bcc:&quot;)
== Examples ==
&lt;pre&gt; &lt;?php wp_mail( 'me@example.net', 'The subject', 'The message' ); ?&gt; &lt;/pre&gt;
&lt;pre&gt;
&lt;?php
$attachments = array( WP_CONTENT_DIR . '/uploads/file_to_attach.zip' );
$headers = 'From: My Name &lt;myname@example.com&gt;' . &quot;\r\n&quot;;
wp_mail('test@example.org', 'subject', 'message', $headers, $attachments );
?&gt;
&lt;/pre&gt;
&lt;pre&gt;
&lt;?php
$multiple_to_recipients = array(
'recipient1@example.com',
'recipient2@foo.example.com'
);
add_filter( 'wp_mail_content_type', 'set_html_content_type' );
wp_mail( $multiple_to_recipients, 'The subject', '&lt;p&gt;The &lt;em&gt;HTML&lt;/em&gt; message&lt;/p&gt;' );
// Reset content-type to avoid conflicts -- http://core.trac.wordpress.org/ticket/23578
remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
function set_html_content_type() {
return 'text/html';
}
?&gt;
&lt;/pre&gt;
&lt;pre&gt;
&lt;?php
// Example using the array form of $headers
// assumes $to, $subject, $message have already been defined earlier...
$headers[] = 'From: Me Myself &lt;me@example.net&gt;';
$headers[] = 'Cc: John Q Codex &lt;jqc@wordpress.org&gt;';
$headers[] = 'Cc: iluvwp@wordpress.org'; // note you can just use a simple email address
wp_mail( $to, $subject, $message, $headers );
?&gt;
&lt;/pre&gt;
== Notes ==
* A &lt;tt&gt;true&lt;/tt&gt; return value does not automatically mean that the user received the email successfully.
* For this function to work, the settings &lt;code&gt;SMTP&lt;/code&gt; and &lt;code&gt;smtp_port&lt;/code&gt; (default: 25) need to be set in your php.ini file.
* The function is available after the hook [[Plugin_API/Action_Reference/plugins_loaded|&lt;code&gt;'plugins_loaded'&lt;/code&gt;]].
* The filenames in the &lt;code&gt;$attachments&lt;/code&gt; attribute have to be filesystem paths.
* The example to add_filter to set the html content type, send the email (wp_mail) and remove the filter did not work. I had to set the content type header with the $headers = array('Content-Type: text/html; charset=UTF-8');
== Change Log ==
Since: [[Version 1.2.1|1.2.1]]
== Source File ==
&lt;tt&gt;wp_mail()&lt;/tt&gt; is located in {{Trac|wp-includes/pluggable.php}}.
== Related ==
* Function: [[Function_Reference/wp_mail|wp_mail]]
* Filter: [[Plugin API/Filter Reference/wp_mail|wp_mail]]
* Filter: [[Plugin API/Filter Reference/wp_mail_from|wp_mail_from]]
* Filter: [[Plugin API/Filter Reference/wp_mail_from_name|wp_mail_from_name]]
* Filter: [[Plugin API/Filter Reference/wp_mail_content_type|wp_mail_content_type]]
* Filter: [[Plugin API/Filter Reference/wp_mail_charset|wp_mail_charset]]
* Action: [[Plugin_API/Action_Reference/phpmailer_init|phpmailer_init]]
[[Category:Functions]]
{{Copyedit}}</p>
</d:entry>
<d:entry id="remove_action" d:title="remove action">
<d:index d:value="remove action"/>
<h1>remove action</h1>
<p>== Description ==
This function is an alias to [[Function Reference/remove filter|remove_filter()]].
This function removes a function attached to a specified action hook. This method can be used to remove default functions attached to a specific action hook and possibly replace them with a substitute. See also [[Function Reference/remove filter|remove_filter()]], [[Function Reference/add action|add_action()]] and [[Function Reference/add filter|add_filter()]].
'''''Important:''' To remove a hook, the &lt;tt&gt;$function_to_remove&lt;/tt&gt; and &lt;tt&gt;$priority&lt;/tt&gt; arguments must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure.''
== Usage ==
%%%&lt;?php remove_action( $tag, $function_to_remove, $priority ); ?&gt;%%%
== Parameters ==
{{Parameter|$tag|string|The action hook to which the function to be removed is hooked.}}
{{Parameter|$function_to_remove|callable|The name of the function which should be removed.}}
{{Parameter|$priority|int|The priority of the function (as defined when the function was originally hooked).|optional|10}}
== Return ==
; (''boolean'') : Whether the function is removed.
:* &lt;tt&gt;True&lt;/tt&gt; - The function was successfully removed.
:* &lt;tt&gt;False&lt;/tt&gt; - The function could not be removed.
== Example ==
This function is identical to the [[Function Reference/remove filter|remove_filter()]] function.
%%% &lt;?php remove_action( $tag, $function_to_remove, $priority ); ?&gt; %%%
If an action has been added from within a &lt;em&gt;class&lt;/em&gt;, for example by a plugin, removing it will require accessing the class variable.
&lt;pre&gt;
global $my_class;
remove_action( 'the_content', array( $my_class, 'class_filter_function' ) );
&lt;/pre&gt;
It is also worth noting that you may need to prioritise the removal of the action to a hook that occurs after the action is added. You cannot successfully remove the action before it has been added.
== Notes ==
== Change Log ==
Since: 1.2.0
== Source File ==
&lt;tt&gt;remove_action()&lt;/tt&gt; is located in {{Trac|wp-includes/plugin.php}}.
== Related ==
{{Action Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="do_action_ref_array" d:title="do action ref array">
<d:index d:value="do action ref array"/>
<h1>do action ref array</h1>
<p>{{Languages|
{{ja|関数リファレンス/do_action_ref_array}}
}}
== Description ==
Execute functions hooked on a specific action hook, specifying arguments in an array.
This function is identical to &lt;tt&gt;[[Function Reference/do_action|do_action]]&lt;/tt&gt;, but the arguments passed to the functions hooked to &lt;tt&gt;$tag&lt;/tt&gt; are supplied using an array.
== Usage ==
%%% &lt;?php do_action_ref_array( $tag, $args ); ?&gt; %%%
== Parameters ==
{{Parameter|$tag|string|The name of the action to be executed.}}
{{Parameter|$args|array|The arguments supplied to the functions hooked to &lt;tt&gt;$tag&lt;/tt&gt;}}
== Example ==
Call an action and pass an array of arguments:
&lt;pre&gt;
$args = array( 'arg_1', true, 'foo', 'arg_4' );
do_action_ref_array( 'my_action', $args );
&lt;/pre&gt;
This is the same as:
do_action( 'my_action', 'arg_1', true, 'foo', 'arg_4' );
== Notes ==
* This function can be useful when your arguments are already in an array, and/or when there are many arguments to pass. Just make sure that your arguments are in the proper order!
* Before PHP 5.4, your callback is passed a reference pointer to the array. Your callback can use this pointer to access all the array elements. Adding an action and declaring a call back that hooks the above example action could look like this:
&lt;pre&gt;add_action('my_action', 'my_callback');
function my_callback( $args ) {
//access values with $args[0], $args[1] etc.
}&lt;/pre&gt;
Because the array was passed by reference, any changes to the array elements are applied to the original array outside of the function's scope.
* Regardless of PHP version, you can specify the number of array elements when adding the action, and receive each element in a separate parameter in the callback function declaration like so:
&lt;pre&gt;add_action('my_action', 'my_callback', 10, 4 );
function my_callback( $arg1, $arg2, $arg3, $arg4 ) {
//access values with $args1, $args2 etc.
}&lt;/pre&gt;
This method copies the array elements into the parameter variables. Any changes to the parameter variables do not affect the original array.
* As of PHP 5.4, the array is no longer passed by reference despite the function's name. You cannot even use the reference sign '&amp;' because call time pass by reference now throws an error. What you can do is pass the reference pointer as an array element. Doing so does require all callbacks added to the action to expect a reference pointer. This is not something you will see in WordPress actions. This technique is provided for informational purposes only.
&lt;pre&gt;do_action_ref_array( 'my_action', array( &amp;$args ));
add_action('my_action', 'my_callback');
function my_callback( &amp;$args ) {
//access values with $args[0], $args[1] etc.
}&lt;/pre&gt;
Because the original array was passed by reference, any changes to the array elements are applied to the original array outside of the function's scope.
== Change Log ==
Since: [[Version 2.1 | 2.1.0]]
== Source File ==
&lt;tt&gt;do_action_ref_array()&lt;/tt&gt; is located in {{Trac|wp-includes/plugin.php}}.
== Related ==
{{Action Tags}}
{{Tag Footer}}
[[Category:Functions]]
{{Copyedit}}</p>
</d:entry>
<d:entry id="did_action" d:title="did action">
<d:index d:value="did action"/>
<h1>did action</h1>
<p>== Description ==
Retrieve the number of times an action is fired.
== Usage ==
%%%&lt;?php did_action( $tag ); ?&gt;%%%
== Parameters ==
{{Parameter|$tag|string|The name of the action hook.}}
== Return Values ==
; (integer) : The number of times action hook &lt;tt&gt;$tag&lt;/tt&gt; is fired
== Examples ==
Using did_action() function to make sure custom meta field is only added during the first run since it can run multiple times.
&lt;pre&gt;
function my_sticky_option()
{
global $post;
// if the post is a custom post type and only during the first execution of the action quick_edit_custom_box
if ( $post-&gt;post_type == 'custom_post_type' &amp;&amp; did_action( 'quick_edit_custom_box' ) === 1 )
{
?&gt;
&lt;fieldset class=&quot;inline-edit-col-right&quot;&gt;
&lt;div class=&quot;inline-edit-col&quot;&gt;
&lt;label class=&quot;alignleft&quot;&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;sticky&quot; value=&quot;sticky&quot; /&gt;
&lt;span class=&quot;checkbox-title&quot;&gt;
&lt;?php _e( 'Featured (sticky)', 'textdomain_string' ); ?&gt;
&lt;/span&gt;
&lt;/label&gt;
&lt;/div&gt;
&lt;/fieldset&gt;
&lt;?php
} // endif;
}
// add the sticky option to the quick edit area
add_action( 'quick_edit_custom_box', 'my_sticky_option' );
&lt;/pre&gt;
== Notes ==
* Uses global: (&lt;tt&gt;unknown type&lt;/tt&gt;) &lt;tt&gt;$wp_actions&lt;/tt&gt;
== Change Log ==
Since: 2.1
== Source File ==
&lt;tt&gt;did_action()&lt;/tt&gt; is located in {{Trac|wp-includes/plugin.php}}.
== Related ==
{{Action Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="remove_filter" d:title="remove filter">
<d:index d:value="remove filter"/>
<h1>remove filter</h1>
<p>{{Languages|
{{en|Function Reference/remove filter}}
{{ja|関数リファレンス/remove_filter}}
}}
== Description ==
This function removes a function attached to a specified filter hook. This method can be used to remove default functions attached to a specific filter hook and possibly replace them with a substitute. See also [[Function Reference/remove action|remove_action()]], [[Function Reference/add filter|add_filter()]] and [[Function Reference/add action|add_action()]].
'''''Important:''' To remove a hook, the &lt;tt&gt;$function_to_remove&lt;/tt&gt; and &lt;tt&gt;$priority&lt;/tt&gt; arguments must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure.''
== Usage ==
%%%&lt;?php remove_filter( $tag, $function_to_remove, $priority ); ?&gt;%%%
== Parameters ==
{{Parameter|$tag|string|The action hook to which the function to be removed is hooked.}}
{{Parameter|$function_to_remove|callback|The callback for the function which should be removed.}}
{{Parameter|$priority|int|The priority of the function (as defined when the function was originally hooked).|optional|10}}
== Return ==
; (''boolean'') : Whether the function is removed.
:* &lt;tt&gt;True&lt;/tt&gt; - The function was successfully removed.
:* &lt;tt&gt;False&lt;/tt&gt; - The function could not be removed.
== Example ==
&lt;pre&gt;
remove_filter( 'the_content', 'wpautop' );
&lt;/pre&gt;
&lt;pre&gt;
foreach ( array( 'the_content', 'the_title', 'comment_text' ) as $hook )
remove_filter( $hook, 'capital_P_dangit' );
&lt;/pre&gt;
If a filter has been added from within a class, for example by a plugin, removing it will require accessing the class variable.
&lt;pre&gt;
global $my_class;
remove_filter( 'the_content', array($my_class, 'class_filter_function') );
&lt;/pre&gt;
It is also worth noting that you may need to prioritise the removal of the filter to a hook that occurs after the filter is added. You cannot successfully remove the filter before it has been added.
== Notes ==
When using filters passed with objects, you most often need to pass the exact same object back to the remove filter call, not just another instance of that object.(read _wp_filter_build_unique_id() for the gory details)
== Change Log ==
* Since: 1.2.0
== Source File ==
&lt;tt&gt;remove_filter()&lt;/tt&gt; is located in {{Trac|wp-includes/plugin.php}}.
== Related ==
{{Filter Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="merge_filters" d:title="merge filters">
<d:index d:value="merge filters"/>
<h1>merge filters</h1>
<p>== Description ==
!!! THIS FUNCTION DOES NOT EXISTS ANYMORE !!!
Old documentation :
Merge the filter functions of a specific filter hook with generic filter functions.
It is possible to defined generic filter functions using the filter hook ''all''. These functions are called for every filter tag. This function merges the functions attached to the ''all'' hook with the functions of a specific hook defined by &lt;tt&gt;$tag&lt;/tt&gt;.
== Usage ==
%%% &lt;?php merge_filters($tag); ?&gt; %%%
== Parameters ==
{{Parameter|$tag|string|The filter hook of which the functions should be merged.}}
== Examples ==
== Notes ==
== Change Log ==
Since: ?
== Source File ==
&lt;tt&gt;merge_filters()&lt;/tt&gt; is located in {{Trac|wp-includes/plugin.php}}.
== Related ==
{{Filter Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="apply_filters" d:title="apply filters">
<d:index d:value="apply filters"/>
<h1>apply filters</h1>
<p>{{Languages|
{{en|Function_Reference/apply_filters}}
{{it|Riferimento funzioni/apply_filters}}
{{ja|関数リファレンス/apply_filters}}
}}
== Description ==
Call the functions added to a filter hook. See the [[Plugin API]] for a list of filter hooks.
The callback functions attached to filter hook &lt;tt&gt;$tag&lt;/tt&gt; are invoked by calling this function. This function can be used to create a new filter hook by simply calling this function with the name of the new hook specified using the &lt;tt&gt;$tag&lt;/tt&gt; parameter.
== Usage ==
%%% &lt;?php apply_filters( $tag, $value, $var ... ); ?&gt; %%%
== Parameters ==
{{Parameter|$tag|string|The name of the filter hook.}}
{{Parameter|$value|mixed|The value which can be modified by filters hooked to &lt;tt&gt;$tag&lt;/tt&gt;}}
{{Parameter|$var|mixed|One or more additional variables passed to the filter functions. You can use this parameter in your function but it will not be returned. This parameter is available since [[Version 1.5.1]].|optional}}
== Return ==
; (''mixed'') : The result of &lt;tt&gt;$value&lt;/tt&gt; after all hooked functions are applied to it.
'''Note:''' The type of return should be the same as the type of $value: a string or an array, for example.
== Examples ==
=== Echo after Filtering ===
echo apply_filters( $tag, $value );
=== Get Filtered ===
$myvar = apply_filters( $tag, $value );
=== Additional Filter Arguments ===
$myvar = apply_filters( $tag, $value, $param, $otherparam );
For example:
$myvar = apply_filters( 'example_filter', 'filter me', 'arg1', 'arg2 ');
=== With the_title filter ===
$my_custom_title = apply_filters('the_title', ' My Custom Title (tm) ');
$my_custom_title will now contain 'My Custom Title &trade;', since [[Plugin API/Filter Reference/the title|the_title]] filter applies [[Function Reference/wptexturize|wptexturize()]] and [http://www.php.net/manual/en/function.trim.php trim()], among others.
== Notes ==
== Change Log ==
* Since: 0.71
== Source File ==
&lt;tt&gt;apply_filters()&lt;/tt&gt; is located in {{Trac|wp-includes/plugin.php}}.
== Related ==
{{Filter Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="force_balance_tags" d:title="force balance tags">
<d:index d:value="force balance tags"/>
<h1>force balance tags</h1>
<p>== Description ==
Balances tags of string using a modified stack.
Ignores the '&lt;tt&gt;use_balanceTags&lt;/tt&gt;' option.
== Usage ==
%%%&lt;?php force_balance_tags( $text ) ?&gt;%%%
This function is used in the short post excerpt list, to prevent unmatched elements.
For example, it makes
%%%&lt;div&gt;&lt;b&gt;This is an excerpt. &lt;!--more--&gt; and this is more text... &lt;/b&gt;&lt;/div&gt;%%%
not break, when the html after the more tag is cut off.
== Parameters ==
{{Parameter|$text|string|Text to be balanced.}}
== Return Values ==
; (string) : Balanced text.
== Examples ==
In the example above,
%%%&lt;div&gt;&lt;b&gt;This is an excerpt. %%%
should be changed to:
%%%&lt;div&gt;&lt;b&gt;This is an excerpt. &lt;/b&gt;&lt;/div&gt;%%%
by the force_balance_tags function.
== Notes ==
* See [[Function_Reference/balanceTags|&lt;tt&gt;balanceTags()&lt;/tt&gt;]]
* This is not used for all html, since there are some bugs and performance issues: http://wordpress.stackexchange.com/questions/89121/why-doesnt-default-wordpress-page-view-use-force-balance-tags
== Change Log ==
Since: 2.0.4
== Source File ==
&lt;tt&gt;force_balance_tags()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_redirect" d:title="wp redirect">
<d:index d:value="wp redirect"/>
<h1>wp redirect</h1>
<p>{{Languages|
{{en|Function Reference/wp_redirect}}
{{it|Riferimento funzioni/wp_redirect}}
}}
== Description ==
Redirects the user to a specified [[Glossary#Absolute_URI|''absolute'' URI]].
== Usage ==
&lt;code&gt;wp_redirect()&lt;/code&gt; does not exit automatically and should almost always be followed by &lt;code&gt;exit&lt;/code&gt;.
&lt;pre&gt;&lt;?php
wp_redirect( $location, $status );
exit;
?&gt;&lt;/pre&gt;
== Parameters ==
{{Parameter|$location|string|The '''absolute''' URI which the user will be redirected to.}}
{{Parameter|$status|integer|The status code to use.|optional|302}}
== Return Values ==
; &lt;tt&gt;(bool|void)&lt;/tt&gt; : False if $location is not set, returns nothing otherwise.
== Examples ==
&lt;?php wp_redirect( home_url() ); exit; ?&gt;
Redirects can also be external, and/or use a &quot;Moved Permanently&quot; code :
&lt;pre&gt;&lt;nowiki&gt;&lt;?php wp_redirect( 'http://www.example.com', 301 ); exit; ?&gt;&lt;/nowiki&gt;&lt;/pre&gt;
The code below redirects to the parent post URL which can be used to redirect attachment pages back to the parent.
&lt;pre&gt;&lt;?php wp_redirect( get_permalink( $post-&gt;post_parent )); exit; ?&gt;&lt;/pre&gt;
==Notes==
The HTTP/1.1 status code 302 is a temporary redirect. If the page has moved permanently, use the HTTP status code 301.
wp_redirect() is a [[Pluggable Functions|Pluggable Function]]
==Change Log==
* Since: 1.5.1
==Source File==
&lt;tt&gt;wp_redirect()&lt;/tt&gt; is located in {{Trac|wp-includes/pluggable.php}}.
==Related==
* See Also: [[Function_Reference/wp_safe_redirect|wp_safe_redirect()]], [[Plugin_API/Filter_Reference/wp_redirect|wp_redirect (filter)]], [[Plugin_API/Filter_Reference/wp_redirect_status|wp_redirect_status (filter)]], [[Pluggable Functions|Pluggable Functions]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="register_activation_hook" d:title="register activation hook">
<d:index d:value="register activation hook"/>
<h1>register activation hook</h1>
<p>{{Languages|
{{en|Function_Reference/register_activation_hook}}
{{ja|関数リファレンス/register_activation_hook}}
}}
== Description ==
The '''register_activation_hook''' function registers a plugin function to be run [[Managing_Plugins#Installing_Plugins|when the plugin is activated]].
When a plugin is activated, the action &lt;tt&gt;'activate_PLUGINNAME'&lt;/tt&gt; hook is called. In the name of this hook, &lt;tt&gt;PLUGINNAME&lt;/tt&gt; is replaced with the name of the plugin, including the optional subdirectory. For example, when the plugin is located in &lt;tt&gt;wp-content/plugin/sampleplugin/sample.php&lt;/tt&gt;, then the name of this hook will become &lt;tt&gt;'activate_sampleplugin/sample.php'&lt;/tt&gt;. When the plugin consists of only one file and is (as by default) located at &lt;tt&gt;wp-content/plugin/sample.php&lt;/tt&gt; the name of this hook will be &lt;tt&gt;'activate_sample.php'&lt;/tt&gt;.
This function is a wrapper for the &lt;tt&gt;'activate_PLUGINNAME'&lt;/tt&gt; action, and is easier to use.
== Usage ==
%%% &lt;?php register_activation_hook( $file, $function ); ?&gt; %%%
== Parameters ==
{{Parameter|$file|string|Path to the [[Writing_a_Plugin#Plugin_Files|main plugin file]] inside the &lt;tt&gt;wp-content/plugins&lt;/tt&gt; directory. A full path will work.}}
{{Parameter|$function|callback|The function to be run when the plugin is activated. Any of [http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback PHP's callback pseudo-types] will work.}}
== Examples ==
If you have a function called &lt;tt&gt;myplugin_activate()&lt;/tt&gt; in the [[Writing_a_Plugin#Plugin_Files|main plugin file]] at either
* &lt;tt&gt;wp-content/plugins/&lt;var&gt;myplugin&lt;/var&gt;.php&lt;/tt&gt; or
* &lt;tt&gt;wp-content/plugins/&lt;var&gt;myplugin&lt;/var&gt;/&lt;var&gt;myplugin&lt;/var&gt;.php&lt;/tt&gt;
use this code:
&lt;pre&gt;
function myplugin_activate() {
// Activation code here...
}
register_activation_hook( __FILE__, 'myplugin_activate' );
&lt;/pre&gt;
This will call the &lt;tt&gt;myplugin_activate()&lt;/tt&gt; function on activation of the plugin.
If your plugin uses the singleton class pattern, add the activation hook like so:
class MyPlugin {
static function install() {
// do not generate any output here
}
}
register_activation_hook( __FILE__, array( 'MyPlugin', 'install' ) );
If the class that holds your activation function/method is in some additional file, register your activation function like this:
&lt;pre&gt;
include_once dirname( __FILE__ ) . '/your_additional_file.php';
register_activation_hook( __FILE__, array( 'YourAdditionalClass', 'on_activate_function' ) );
&lt;/pre&gt;
Or if you're inside of a &lt;tt&gt;__construct()&lt;/tt&gt;:
&lt;pre&gt;register_activation_hook( __FILE__, array( $this, 'YOUR_METHOD_NAME' ) );&lt;/pre&gt;
== Notes ==
* Related discussion with another sample of working code: http://wordpress.org/support/topic/312342
* &lt;strong&gt;Registering the hook inside the 'plugins_loaded' hook will not work.&lt;/strong&gt; You can't call &lt;tt&gt;register_activation_hook()&lt;/tt&gt; inside a function hooked to the &lt;tt&gt;[[Plugin_API/Action_Reference/plugins_loaded | 'plugins_loaded']]&lt;/tt&gt; or &lt;tt&gt;[[Plugin_API/Action_Reference/init | 'init']]&lt;/tt&gt; hooks (or any other hook). These hooks are called ''before'' the plugin is loaded or activated.
* When a plugin is activated, all active plugins are loaded, then the plugin being activated. The plugin's activation hook is run and then the page is immediately redirected (see [[#Process_Flow|below]]).
=== Process Flow ===
If you are interested in doing something just after a plugin has been activated it is important to note that the hook process performs an instant redirect after it fires. So it is impossible to use &lt;tt&gt;[[Function_Reference/add_action | add_action()]]&lt;/tt&gt; or &lt;tt&gt;[[Function_Reference/add_filter | add_filter()]]&lt;/tt&gt; type calls until the redirect has occurred (e.g., only two hooks are fired after the plugin's activation hook: &lt;tt&gt;[[Plugin_API/Action_Reference/activated_plugin | 'activated_plugin']]&lt;/tt&gt; and &lt;tt&gt;[[Plugin_API/Action_Reference/shutdown | 'shutdown']]&lt;/tt&gt;). A quick workaround to this quirk is to use &lt;tt&gt;[[Function_Reference/add_option | add_option()]]&lt;/tt&gt; like so:
&lt;pre&gt;
/* Main Plugin File */
...
function my_plugin_activate() {
add_option( 'Activated_Plugin', 'Plugin-Slug' );
/* activation code here */
}
register_activation_hook( __FILE__, 'my_plugin_activate' );
function load_plugin() {
if ( is_admin() &amp;&amp; get_option( 'Activated_Plugin' ) == 'Plugin-Slug' ) {
delete_option( 'Activated_Plugin' );
/* do stuff once right after activation */
// example: add_action( 'init', 'my_init_function' );
}
}
add_action( 'admin_init', 'load_plugin' );
&lt;/pre&gt;
You can check out the full post @ http://stackoverflow.com/questions/7738953/is-there-a-way-to-determine-if-a-wordpress-plugin-is-just-installed/13927297#13927297.
However, it '''is''' possible to use &lt;tt&gt;[[Function_Reference/do_action | do_action()]]&lt;/tt&gt;, like this:
&lt;pre&gt;
function my_plugin_activate() {
do_action( 'my_plugin_activate' );
}
register_activation_hook( __FILE__, 'my_plugin_activate' );
&lt;/pre&gt;
Included plugin files and even other plugins ''will'' be able to hook into this action.
=== A Note on Variable Scope ===
If you're using global variables, you may find that the function you pass to &lt;tt&gt;register_activation_hook()&lt;/tt&gt; does not have access to global variables at the point when it is called, even though you state their global scope within the function like this:
&lt;pre&gt;
$myvar = 'whatever';
function myplugin_activate() {
global $myvar;
echo $myvar; // this will NOT be 'whatever'!
}
register_activation_hook( __FILE__, 'myplugin_activate' );
&lt;/pre&gt;
This is because on that very first include, your plugin is NOT included within the global scope. It's included in the &lt;tt&gt;[[Function_Reference/activate_plugin | activate_plugin()]]&lt;/tt&gt; function, and so its &quot;main body&quot; is not automatically in the global scope.
This is why you should ''always'' be explicit. If you want a variable to be global, then you need to declare it as such, and that means anywhere and everywhere you use it. If you use it in the main body of the plugin, then you need to declare it global there too.
When activation occurs, your plugin is included from another function and then your &lt;tt&gt;myplugin_activate()&lt;/tt&gt; is called from within that function (specifically, within the &lt;tt&gt;activate_plugin()&lt;/tt&gt; function) at the point where your plugin is activated. The main body variables are therefore in the scope of the &lt;tt&gt;activate_plugin()&lt;/tt&gt; function and are not global, unless you explicitly declare their global scope:
&lt;pre&gt;
global $myvar;
$myvar = 'whatever';
function myplugin_activate() {
global $myvar;
echo $myvar; // this will be 'whatever'
}
register_activation_hook( __FILE__, 'myplugin_activate' );
&lt;/pre&gt;
More information on this is available here: http://wordpress.org/support/topic/201309
== Discussions - External Resources ==
* [http://solislab.com/blog/plugin-activation-checklist/ Activation checklist for WordPress plugin developers]: A tutorial that explains not only the activation hook, but also other topics related to plugin activation such as how to manage updates, rewrite rules, welcome screen etc.
* A good example for a basic activation/deactivation/uninstall class by &quot;kaiser&quot; can be found here on WPSE: http://wordpress.stackexchange.com/questions/25910/uninstall-a-plugin-method-typical-features-how-to/25979#25979
== Changelog ==
* [[Version 3.1|3.1]] : This hook is now fired only when the user activates the plugin and not when an automatic plugin update occurs ([http://core.trac.wordpress.org/ticket/14915 #14915]).
** [http://wpdevel.wordpress.com/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/ Plugin activation hooks no longer fire for updates &laquo; WordPress Development Updates] (2010-10-28)
** [http://wpdevel.wordpress.com/2010/10/27/plugin-activation-hooks/ Plugin activation hooks &laquo; WordPress Development Updates] (2010-10-27)
* since [[Version 2.0|2.0]]
== Source File ==
&lt;tt&gt;register_activation_hook()&lt;/tt&gt; is located in {{Trac|wp-includes/plugin.php}}
== Related ==
* See also [[Function_Reference/register_deactivation_hook|register_deactivation_hook()]], [[Function_Reference/register_uninstall_hook|register_uninstall_hook()]]
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="register_deactivation_hook" d:title="register deactivation hook">
<d:index d:value="register deactivation hook"/>
<h1>register deactivation hook</h1>
<p>== Description ==
The function '''register_deactivation_hook''' (introduced in WordPress 2.0) registers a plugin function to be run when the plugin is deactivated.
== Usage ==
%%% &lt;?php register_deactivation_hook($file, $function); ?&gt; %%%
== Parameters ==
{{Parameter|$file|string|Path to the [[Writing_a_Plugin#Plugin_Files|main plugin file]] inside the &lt;tt&gt;wp-content/plugins&lt;/tt&gt; directory. A full path will work.}}
{{Parameter|$function|callback|The function to be run when the plugin is deactivated. Any of [http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback PHP's callback pseudo-types] will work.}}
== Examples ==
If you have a function called &lt;tt&gt;myplugin_deactivate()&lt;/tt&gt; in the [[Writing_a_Plugin#Plugin_Files|main plugin file]] at either
* &lt;tt&gt;wp-content/plugins/&lt;var&gt;myplugin&lt;/var&gt;.php&lt;/tt&gt; or
* &lt;tt&gt;wp-content/plugins/&lt;var&gt;myplugin&lt;/var&gt;/&lt;var&gt;myplugin&lt;/var&gt;.php&lt;/tt&gt;
use this code:
register_deactivation_hook( __FILE__, 'myplugin_deactivate' );
This will call the &lt;tt&gt;myplugin_deactivate()&lt;/tt&gt; function on deactivation of the plugin.
== Discussions ==
A good example for a basic activation/deactivation/uninstall class by &quot;kaiser&quot; can be found here on WPSE: http://wordpress.stackexchange.com/questions/25910/uninstall-a-plugin-method-typical-features-how-to/25979#25979
== Change Log ==
Since: [[Version 2.0|2.0]]
== Source File ==
&lt;tt&gt;register_deactivation_hook()&lt;/tt&gt; is located in {{Trac|wp-includes/plugin.php}}
== Related ==
* See also [[Function_Reference/register_activation_hook|register_activation_hook()]], [[Function_Reference/register_uninstall_hook|register_uninstall_hook()]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="Option_Reference" d:title="Option Reference">
<d:index d:value="Option Reference"/>
<h1>Option Reference</h1>
<p>{{Languages|
{{en|Option_Reference}}
{{es|Referencia de Opciones}}
{{ja|Option_Reference}}
{{tr|Secenek Listesi}}
}}
__TOC__
[[Option Reference|Options]] are pieces of data that WordPress uses to store various preferences and configuration settings. Listed below are the options, along with some of the default values from the current WordPress install. By using the appropriate function, options can be [[Function Reference/add_option|added]], [[Function Reference/update_option|changed]], [[Function Reference/delete_option|removed]], and [[Function_Reference/get_option|retrieved]], from the [[Database_Description#Table:_wp_options|wp_options table]]. This list reflects the WordPress 2.9 release, and does not include options that were deprecated by that version.
Definitions are normally typed, possible option-values are bolded, and option-value definitions are italicized. Data types are given after the possible values (if those are given) like this:
''Data type:'' '''Integer'''
&lt;div style=&quot;border:blue 1px solid;padding:10px; background: #E6CCFF&quot;&gt;
'''You can help make this page more complete!'''
Here are some things you can do to help:
* Add documentation to un-documented options, by adding a description, possible values, and the option's data type.
* List more options here, following the category structure (if they are not already listed).
* Correct errors by moving functions to better categories where appropriate, and of course fixing typos.
Read [[Contributing to WordPress]] to find out more about how you can contribute to the effort!
&lt;/div&gt;
{{Copyedit}}
== View By Category ==
=== Discussion ===
; &lt;tt&gt;blacklist_keys&lt;/tt&gt; : When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be marked as spam. One word or IP per line. It will match inside words, so &quot;press&quot; will match &quot;WordPress.&quot;
: Default: NULL
: ''Data type:'' '''String (possibly multi-line)'''
; &lt;tt&gt;comment_max_links&lt;/tt&gt; : Hold a comment in the queue if it contains the value of this option or more.
: Default: 2
: ''Data type:'' '''Integer'''
; &lt;tt&gt;comment_moderation&lt;/tt&gt; : Before a comment appears, an administrator must always approve the comment.
: '''1''' : ''Yes''
: '''0''' : ''False'' (default)
: ''Data type:'' '''Integer'''
; &lt;tt&gt;comments_notify&lt;/tt&gt; : E-mail me when anyone posts a comment.
: '''1''' : ''Yes'' (default)
: '''0''' : ''No''
: ''Data type:'' '''Integer'''
; &lt;tt&gt;default_comment_status&lt;/tt&gt; : Allow comments (can be overridden with individual posts)
: '''open''' : ''Allow comments'' (default)
: '''closed''' : ''Disallow comments''
: ''Data type:'' '''String'''
; &lt;tt&gt;default_ping_status&lt;/tt&gt; : Allow link notifications from other blogs (pingbacks and trackbacks).
: '''open''' : ''Allow pingbacks and trackbacks from other blogs'' (default)
: '''closed''' : ''Disallow pingbacks and trackbacks from other blogs''
: ''Data type:'' '''String'''
; &lt;tt&gt;default_pingback_flag&lt;/tt&gt; : Attempt to notify any blogs linked to from the article (slows down posting).
: '''1''' : ''Yes'' (default)
: '''0''' : ''No''
: ''Data type:'' '''Integer'''
; &lt;tt&gt;moderation_keys&lt;/tt&gt; : When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the moderation queue. One word or IP per line. It will match inside words, so &quot;press&quot; will match &quot;WordPress.&quot;
: Default: NULL
: ''Data type:'' '''String (possibly multi-line)'''
; &lt;tt&gt;moderation_notify&lt;/tt&gt; : E-mail me when a comment is held for moderation.
: '''1''' : ''Yes'' (default)
: '''0''' : ''No''
: ''Data type:'' '''Integer'''
; &lt;tt&gt;require_name_email&lt;/tt&gt; : Before a comment appears, the comment author must fill out his/her name and email.
: '''1''' : ''Yes'' (default)
: '''0''' : ''No''
: ''Data type:'' '''Integer'''
; &lt;tt&gt;thread_comments&lt;/tt&gt; : Enable WP-native threaded (nested) comments.
: '''1''' : ''Yes''
: '''0''' : ''No'' (default)
: ''Data type:'' '''Integer'''
; &lt;tt&gt;thread_comments_depth&lt;/tt&gt; : Set the number of threading levels for comments.
: '''1''' thru '''10''' : levels
: Default: 5
: ''Data type:'' '''Integer'''
; &lt;tt&gt;show_avatars&lt;/tt&gt;
: Avatar Display
: '''1''' : ''Yes'' - (default) Show Avatars
: '''0''' : ''No'' - Don&rsquo;t show Avatars
: ''Data type:'' '''Integer'''
; &lt;tt&gt;avatar_rating&lt;/tt&gt;
: Maximum Rating
: '''G''' : (default) ''Suitable for all audiences''
: '''PG''' : ''Possibly offensive, usually for audiences 13 and above''
: '''R''' : ''Intended for adult audiences above 17''
: '''X''' : ''Even more mature than above''
: ''Data type:'' '''String'''
; &lt;tt&gt;avatar_default&lt;/tt&gt;
: Default Avatar
: '''mystery''' : (default) ''Mystery Man''
: '''blank''' : ''Blank''
: '''gravatar_default''' : ''Gravatar Logo''
: '''identicon''' : ''Identicon (Generated)''
: '''wavatar''' : ''Wavatar (Generated)''
: '''monsterid''' : ''MonsterID (Generated)''
: ''Data type:'' '''String'''
; &lt;tt&gt;close_comments_for_old_posts&lt;/tt&gt;
: Automatically close comments on old articles
: '''1''' : ''Yes''
: '''0''' : ''No'' (default)
: ''Data type:'' '''Integer'''
; &lt;tt&gt;close_comments_days_old&lt;/tt&gt;
: Automatically close comments on articles older than x days
: Default: 14
: ''Data type:'' '''Integer'''
; &lt;tt&gt;page_comments&lt;/tt&gt;
: Break comments into pages
: '''1''' : ''Yes'' (default)
: '''0''' : ''No''
: ''Data type:'' '''Integer'''
; &lt;tt&gt;comments_per_page&lt;/tt&gt;
: Default: 50
: ''Data type:'' '''Integer'''
; &lt;tt&gt;default_comments_page&lt;/tt&gt;
: Default: 'newest'
: ''Data type:'' '''String'''
; &lt;tt&gt;comment_order&lt;/tt&gt;
: '''asc''' : (default)
: '''desc''' :
: ''Data type:'' '''String'''
; &lt;tt&gt;comment_whitelist&lt;/tt&gt;
: Comment author must have a previously approved comment
: '''1''' : ''Yes'' (default)
: '''0''' : ''No''
: ''Data type:''
=== General ===
; &lt;tt&gt;admin_email&lt;/tt&gt; : Administrator email
: Default: 'you@example.com'
: ''Data type:'' '''String'''
; &lt;tt&gt;blogdescription&lt;/tt&gt; : Blog tagline
: Default: '__('Just another WordPress weblog')'
: ''Data type:'' '''String'''
; &lt;tt&gt;blogname&lt;/tt&gt; : Blog title
: Default: '__('My Blog')'
: ''Data type:'' '''String'''
; &lt;tt&gt;comment_registration&lt;/tt&gt; : Users must be registered and logged in to comment
: '''1''' : ''Yes''
: '''0''' : ''No'' (default)
: ''Data type:'' '''Integer'''
; &lt;tt&gt;date_format&lt;/tt&gt; : Default date format (see [[Formatting Date and Time]])
: Default: '__('F j, Y')'
: ''Data type:'' '''String'''
; &lt;tt&gt;default_role&lt;/tt&gt; : The default [[Roles and Capabilities|role of users]] who register at the blog.
: '''subscriber''' : (default)
: '''administrator''' :
: '''editor''' :
: '''author''' :
: '''contributor''' :
: ''Data type:'' '''String'''
; &lt;tt&gt;gmt_offset&lt;/tt&gt; : Times in the blog should differ by this value.
: '''-6''' : ''GMT -6 (aka Central Time, USA)''
: '''0''' : ''GMT (aka Greenwich Mean Time)''
: Default: [http://www.php.net/manual/en/function.date.php date]('Z') / 3600
: ''Data type:'' '''Integer'''
; &lt;tt&gt;home&lt;/tt&gt; : Blog address (URL)
: Default: wp_guess_url()
: ''Data type:'' '''String (URI)'''
; &lt;tt&gt;siteurl&lt;/tt&gt; : WordPress address (URL)
: Default: wp_guess_url()
: ''Data type:'' '''String (URI)'''
; &lt;tt&gt;start_of_week&lt;/tt&gt; : The starting day of the week.
: '''0''' : ''Sunday''
: '''1''' : ''Monday'' (default)
: '''2''' : ''Tuesday''
: '''3''' : ''Wednesday''
: '''4''' : ''Thursday''
: '''5''' : ''Friday''
: '''6''' : ''Saturday''
: ''Data type:'' '''Integer'''
; &lt;tt&gt;time_format&lt;/tt&gt; : Default time format (see [[Formatting Date and Time]])
: Default: '__('g:i a')'
: ''Data type:'' '''String'''
; &lt;tt&gt;timezone_string&lt;/tt&gt;
: Timezone
: Default: NULL
: ''Data type:'' '''String'''
; &lt;tt&gt;users_can_register&lt;/tt&gt; : Anyone can register
: '''1''' : ''Yes''
: '''0''' : ''No'' (default)
: ''Data type:'' '''Integer'''
=== Links ===
; &lt;tt&gt;links_updated_date_format&lt;/tt&gt;
: Default: '__('F j, Y g:i a')'
: ''Data type:'' '''String'''
; &lt;tt&gt;links_recently_updated_prepend&lt;/tt&gt;
: Default: '&lt;em&gt;'
: ''Data type:'' '''String'''
; &lt;tt&gt;links_recently_updated_append&lt;/tt&gt;
: Default: '&lt;/em&gt;'
: ''Data type:'' '''String'''
; &lt;tt&gt;links_recently_updated_time&lt;/tt&gt;
: Default: 120
: ''Data type:'' '''Integer'''
=== Media ===
; &lt;tt&gt;thumbnail_size_w&lt;/tt&gt;
: Default: 150
: ''Data type:'' '''Integer'''
; &lt;tt&gt;thumbnail_size_h&lt;/tt&gt;
: Default: 150
: ''Data type:'' '''Integer'''
; &lt;tt&gt;thumbnail_crop&lt;/tt&gt;
: Crop thumbnail to exact dimensions (normally thumbnails are proportional)
: '''1''' : ''Yes'' (default)
: '''0''' : ''No''
: ''Data type:'' '''Integer'''
; &lt;tt&gt;medium_size_w&lt;/tt&gt;
: Default: 300
: ''Data type:'' '''Integer'''
; &lt;tt&gt;medium_size_h&lt;/tt&gt;
: Default: 300
: ''Data type:'' '''Integer'''
; &lt;tt&gt;large_size_w&lt;/tt&gt;
: Default: 1024
: ''Data type:'' '''Integer'''
; &lt;tt&gt;large_size_h&lt;/tt&gt;
: Default: 1024
: ''Data type:'' '''Integer'''
; &lt;tt&gt;embed_autourls&lt;/tt&gt;
: Attempt to automatically embed all plain text URLs
: Default: 1
: ''Data type:'' '''Integer'''
; &lt;tt&gt;embed_size_w&lt;/tt&gt;
: Default: NULL
: ''Data type:'' '''Integer'''
; &lt;tt&gt;embed_size_h&lt;/tt&gt;
: Default: 600
: ''Data type:'' '''Integer'''
=== Miscellaneous ===
; &lt;tt&gt;hack_file&lt;/tt&gt; : Use legacy &lt;tt&gt;my-hacks.php&lt;/tt&gt; file support
: '''1''' : ''Yes''
: '''0''' : ''No'' (default)
: ''Data type:'' '''Integer'''
; &lt;tt&gt;html_type&lt;/tt&gt; : Default MIME type for blog pages (&lt;tt&gt;text/html&lt;/tt&gt;, &lt;tt&gt;text/xml+html&lt;/tt&gt;, etc.)
: Default: 'text/html'
: ''Data type:'' '''String (MIME type)'''
; &lt;tt&gt;secret&lt;/tt&gt; : Secret value created during installation used with salting, etc.
: Default: wp_generate_password(64)
: ''Data type:'' '''String (MD5)'''
; &lt;tt&gt;upload_path&lt;/tt&gt; : Store uploads in this folder (relative to the WordPress root)
: Default: NULL
: ''Data type:'' '''String (relative path)'''
; &lt;tt&gt;upload_url_path&lt;/tt&gt; : URL path to upload folder (will be blank by default - Editable in Settings -&gt; Miscellaneous)
: ''Data type:'' '''String (url path)'''
; &lt;tt&gt;uploads_use_yearmonth_folders&lt;/tt&gt; : Organize my uploads into month- and year-based folders
: '''1''' : ''Yes'' (default)
: '''0''' : ''No'' (default for safe mode)
: ''Data type:'' '''Integer'''
; &lt;tt&gt;use_linksupdate&lt;/tt&gt; : Track links' update times
: '''1''' : ''Yes''
: '''0''' : ''No'' (default)
: ''Data type:'' '''Integer'''
=== Permalinks ===
; &lt;tt&gt;permalink_structure&lt;/tt&gt; : The desired structure of your blog's permalinks. Some examples:
: ''/%year%/%monthnum%/%day%/%postname%/'' : Date and name based
: ''/archives/%post_id%/'' : Numeric
: ''/%postname%/'' : Post name-based
: You can see more examples by viewing [[Using Permalinks]].
: Default: NULL
: ''Data type:'' '''String'''
; &lt;tt&gt;category_base&lt;/tt&gt;
: The default category base of your blog categories permalink.
: Default: NULL
: ''Data type:'' '''String'''
; &lt;tt&gt;tag_base&lt;/tt&gt;
: The default tag base for your blog tags permalink.
: Default: NULL
: ''Data type:'' '''String'''
=== Privacy ===
; &lt;tt&gt;blog_public&lt;/tt&gt;
: '''1''' : ''I would like my blog to be visible to everyone, including search engines (like Google, Sphere, Technorati) and archivers.'' (default)
: '''0''' : ''I would like to block search engines, but allow normal visitors.''
: ''Data type:'' '''Integer'''
=== Reading ===
; &lt;tt&gt;blog_charset&lt;/tt&gt; : Encoding for pages and feeds. The character encoding you write your blog in (UTF-8 is recommended).
: Default: 'UTF-8'
: ''Data type:'' '''String'''
; &lt;tt&gt;gzipcompression&lt;/tt&gt; : WordPress should compress articles (with gzip) if browsers ask for them.
: '''1''' : ''Yes''
: '''0''' : ''No'' (default)
: ''Data type:'' '''Integer'''
; &lt;tt&gt;page_on_front&lt;/tt&gt; : The ID of the page that should be displayed on the front page. Requires ''show_on_front'''s value to be '''page'''.
: ''Data type:'' '''Integer'''
; &lt;tt&gt;page_for_posts&lt;/tt&gt; : The ID of the page that displays posts. Useful when ''show_on_front'''s value is '''page'''.
: ''Data type:'' '''Integer'''
; &lt;tt&gt;posts_per_page&lt;/tt&gt; : Show at most '''x''' many posts on blog pages.
: Default: 10
: ''Data type:'' '''Integer'''
; &lt;tt&gt;posts_per_rss&lt;/tt&gt; : Show at most '''x''' many posts in RSS feeds.
: Default: 10
: ''Data type:'' '''Integer'''
; &lt;tt&gt;rss_language&lt;/tt&gt; : Language for RSS feeds (metadata purposes only)
: Default: 'en'
: ''Data type:'' '''String (ISO two-letter language code)'''
; &lt;tt&gt;rss_use_excerpt&lt;/tt&gt; : Show an excerpt instead of the full text of a post in RSS feeds
: '''1''' : ''Yes''
: '''0''' : ''No'' (default)
: ''Data type:'' '''Integer'''
; &lt;tt&gt;show_on_front&lt;/tt&gt; : What to show on the front page
: '''posts''' : ''Your latest posts'' (default)
: '''page''' : ''A static page (see page_on_front)''
: ''Data type:'' '''String'''
=== Themes ===
; &lt;tt&gt;template&lt;/tt&gt; : The slug of the currently activated theme (how it is accessed by path, ex. ''/wp-content/themes/'''''some-theme''': some-theme would be the value)
: Default: 'default'
: ''Data type:'' '''String'''
; &lt;tt&gt;stylesheet&lt;/tt&gt; : The slug of the currently activated stylesheet (style.css) (how it is accessed by path, ex. ''/wp-content/themes/'''''some-theme''': some-theme would be the value)
: Default: 'default'
: ''Data type:'' '''String'''
=== Writing ===
; &lt;tt&gt;default_category&lt;/tt&gt; : ID of the category that posts will be put in by default
: Default: 1
: ''Data type:'' '''Integer'''
; &lt;tt&gt;default_email_category&lt;/tt&gt; : ID of the category that posts will be put in by default when written via e-mail
: Default: 1
: ''Data type:'' '''Integer'''
; &lt;tt&gt;default_link_category&lt;/tt&gt; : ID of the category that links will be put in by default
: Default: 2
: ''Data type:'' '''Integer'''
; &lt;tt&gt;default_post_edit_rows&lt;/tt&gt; : Size of the post box (in lines)
: Default: 10
: ''Data type:'' '''Integer'''
; &lt;tt&gt;mailserver_login&lt;/tt&gt; : Mail server username for posting to WordPress by e-mail
: Default: 'login@example.com'
: ''Data type:'' '''String'''
; &lt;tt&gt;mailserver_pass&lt;/tt&gt; : Mail server password for posting to WordPress by e-mail
: Default: 'password'
: ''Data type:'' '''String'''
; &lt;tt&gt;mailserver_port&lt;/tt&gt; : Mail server port for posting to WordPress by e-mail
: Default: 110
: ''Data type:'' '''Integer'''
; &lt;tt&gt;mailserver_url&lt;/tt&gt; : Mail server for posting to WordPress by e-mail
: Default: 'mail.example.com'
: ''Data type:'' '''String'''
; &lt;tt&gt;ping_sites&lt;/tt&gt; : When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see [[Update Services]]. Separate multiple service URLs with line breaks. Requires ''blog_public'' to have a value of '''1'''.
: Default: 'http://rpc.pingomatic.com/'
: ''Data type:'' '''String (possibly multi-line)'''
; &lt;tt&gt;use_balanceTags&lt;/tt&gt; : Correct invalidly-nested XHTML automatically
: '''1''' : ''Yes''
: '''0''' : ''No'' (default)
: ''Data type:'' '''Integer'''
; &lt;tt&gt;use_smilies&lt;/tt&gt; : Convert emoticons like &lt;tt&gt;:-)&lt;/tt&gt; and &lt;tt&gt;:P&lt;/tt&gt; to graphics when displayed
: '''1''' : ''Yes'' (default)
: '''0''' : ''No''
: ''Data type:'' '''Integer'''
; &lt;tt&gt;use_trackback&lt;/tt&gt; : Enable sending and receiving of trackbacks
: '''1''' : ''Yes''
: '''0''' : ''No'' (default)
; &lt;tt&gt;enable_app&lt;/tt&gt;
: Enable the Atom Publishing Protocol
: '''1''' : ''Yes''
: '''0''' : ''No'' (default)
: ''Data type:'' '''Integer'''
; &lt;tt&gt;enable_xmlrpc&lt;/tt&gt;
: Enable the WordPress, Movable Type, MetaWeblog and Blogger XML-RPC publishing protocols
: '''1''' : ''Yes''
: '''0''' : ''No'' (default)
: ''Data type:'' '''Integer'''
=== Uncategorized ===
; &lt;tt&gt;active_plugins&lt;/tt&gt; : Returns an array of strings containing the path of the ''main'' php file of the plugin. The path is relative to the ''plugins'' folder. An example of path in the array : 'myplugin/mainpage.php'.
: Default: array()
: ''Data type:'' '''Array'''
; &lt;tt&gt;advanced_edit&lt;/tt&gt;
: Default: 0
: ''Data type:'' '''Integer'''
; &lt;tt&gt;recently_edited&lt;/tt&gt;
: Default: NULL
: ''Data type:''
; &lt;tt&gt;image_default_link_type&lt;/tt&gt;
: Default: 'file'
: ''Data type:''
; &lt;tt&gt;image_default_size&lt;/tt&gt;
: Default: NULL
: ''Data type:''
; &lt;tt&gt;image_default_align&lt;/tt&gt;
: Default: NULL
: ''Data type:''
; &lt;tt&gt;sidebars_widgets&lt;/tt&gt; : Returns array of sidebar states (list of active and inactive widgets).
: Default:
: ''Data type:'' '''Array'''
; &lt;tt&gt;sticky_posts&lt;/tt&gt;
: Default: array()
: ''Data type:''
; &lt;tt&gt;widget_categories&lt;/tt&gt;
: Default: array()
: ''Data type:''
; &lt;tt&gt;widget_text&lt;/tt&gt;
: Default: array()
: ''Data type:''
; &lt;tt&gt;widget_rss&lt;/tt&gt;
: Default: array()
: ''Data type:''
== Source Code ==
* &lt;tt&gt;populate_options()&lt;/tt&gt; is located in {{Trac|wp-admin/includes/schema.php}}.
== Changelog ==
* [[Version 2.9|2.9]] : Deleted &lt;tt&gt;rss_excerpt_length&lt;/tt&gt;.
[[Category:Plugins]]
[[Category:Functions]]
[[Category:Advanced Topics]]</p>
</d:entry>
<d:entry id="wp_get_attachment_url" d:title="wp get attachment url">
<d:index d:value="wp get attachment url"/>
<h1>wp get attachment url</h1>
<p>{{Languages|
{{en|Function Reference/wp_get_attachment_url}}
{{it|Riferimento funzioni/wp_get_attachment_url}}
{{ja|関数リファレンス/wp_get_attachment_url}}
}}
== Description ==
Returns a full URI for an [[Using_Image_and_File_Attachments|attachment file]] or &lt;var&gt;false&lt;/var&gt; on failure.
&lt;!-- Wordpress uses this function to generate a link when you insert an attachment into a post and choose &lt;tt&gt;Linked to file&lt;/tt&gt;. --&gt;
== Usage ==
%%%&lt;?php wp_get_attachment_url( $id ); ?&gt;%%%
== Default Usage ==
&lt;?php echo wp_get_attachment_url( 12 ); ?&gt;
outputs something like &lt;tt&gt;&lt;nowiki&gt;http://example.net&lt;/nowiki&gt;/wp-content/uploads/&lt;var&gt;filename&lt;/var&gt;&lt;/tt&gt;
== Parameters ==
{{Parameter|$id|integer|The ID of the desired attachment|required}}
== Return Value ==
{{Return||string/boolean|Returns URI to uploaded attachment or &quot;false&quot; on failure.}}
== Notes ==
You can change the output of this function through the &lt;tt&gt;[[Plugin_API/Filter_Reference#Link_Filters|wp get attachment url]]&lt;/tt&gt; filter.
If you want a URI for the [[Templates_Hierarchy#Attachment_display|attachment page]], not the attachment file itself, you can use [[Function_Reference/get_attachment_link|get_attachment_link]].
Also refer:
[[Function Reference/wp_insert_attachment|wp_insert_attachment]], [[Function Reference/wp_upload_dir|wp_upload_dir]], [[Function Reference/wp_get_attachment_image_src|wp_get_attachment_image_src]]
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;wp_get_attachment_url()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Attachment Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]
[[Category:Attachments]]</p>
</d:entry>
<d:entry id="wp_kses" d:title="wp kses">
<d:index d:value="wp kses"/>
<h1>wp kses</h1>
<p>== Description ==
This function makes sure that only the allowed HTML element names, attribute names and attribute values plus only sane HTML entities will occur in $string. You have to remove any slashes from PHP's magic quotes before you call this function.
== Usage ==
%%% &lt;?php wp_kses($string, $allowed_html, $allowed_protocols); ?&gt; %%%
== Parameters ==
{{Parameter|$string|string|Content to filter through kses}}
{{Parameter|$allowed_html|array|List of allowed HTML elements}}
{{Parameter|$allowed_protocols|array|Allow links in &lt;tt&gt;$string&lt;/tt&gt; to these protocols.|optional|The default allowed protocols are '''http''', '''https''', '''ftp''', '''mailto''', '''news''', '''irc''', '''gopher''', '''nntp''', '''feed''', and '''telnet'''. This covers all common link protocols, except for '''javascript''', which should not be allowed for untrusted users.}}
== Return ==
; (string) : Filtered string of HTML.
== Examples ==
=== Allowed HTML Tags Array ===
This is an example of how to format an array of allowed HTML tags and attributes.
array(
'a' =&gt; array(
'href' =&gt; array(),
'title' =&gt; array()
),
'br' =&gt; array(),
'em' =&gt; array(),
'strong' =&gt; array(),
);
== Notes ==
* KSES is an iterative acronym and stands for &ldquo;KSES Strips Evil Scripts&quot;.
== Change Log ==
* Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
* http://codex.wordpress.org/Function_Reference/wp_kses_post
* http://codex.wordpress.org/Function_Reference/wp_kses_allowed_html
See: [[Data_Validation|Data Validation]] article for an in-depth discussion of input and output sanitization.
{{Tag Footer}}
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="cat_is_ancestor_of" d:title="cat is ancestor of">
<d:index d:value="cat is ancestor of"/>
<h1>cat is ancestor of</h1>
<p>== Description ==
This [[Conditional Tags|Conditional Tag]] Check if a category is an ancestor of another category. This is a boolean function, meaning it returns either TRUE or FALSE.
== Usage ==
%%% &lt;?php cat_is_ancestor_of( $cat1, $cat2 ); ?&gt; %%%
== Parameters ==
{{Parameter|$cat1|int/object|ID or object to check if this is the parent category.}}
{{Parameter|$cat2|int/object|The child category.}}
== Return Values ==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True if cat1 is an ancestor of cat2, False if not.
== Examples ==
This example, placed in a theme's archive.php, uses [[Conditional Tags]] to show different content depending on the category being displayed. This is helpful when it is necessary to include something for any child category of a given category, instead of using ''category-slug.php'' method where you'd have to create ''category-slug.php'' files for each and every category.
The code snip below checks to see if the category called 'Music' (ID 4) is being processed, and if so, presents a [[Function Reference/wp_nav_menu|wp_nav_menu]] for the Music archive page, and any subcategories of Music (e.g. jazz, classical.)
&lt;pre&gt;
&lt;?php
// if the category is music or a music SUBcategory,
if (cat_is_ancestor_of(4, $cat) or is_category(4)): ?&gt;
&lt;div id=&quot;music_subnav_menu&quot; class=&quot;subnav_menu&quot;&gt;
&lt;?php wp_nav_menu( array('menu' =&gt; 'Music' )); ?&gt;
&lt;/div&gt;
&lt;? endif; ?&gt;
&lt;/pre&gt;
== Notes ==
* The function evaluates if the second category is a child of the first category.
* Any level of ancestry will return True.
* Arguments should be either integer or objects, If arguments are string representations of integers and not true integers '''cat_is_ancestor_of''' will return False.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;cat_is_ancestor_of()&lt;/tt&gt; is located in {{Trac|wp-includes/category.php}}.
== Related ==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_category_feed_link" d:title="get category feed link">
<d:index d:value="get category feed link"/>
<h1>get category feed link</h1>
<p>{{Languages|
{{en|Function Reference/get_category_feed_link}}
{{it|Riferimento funzioni/get_category_feed_link}}
}}
==Description==
This function returns a link to the feed for all posts in the specified category. A particular feed can be requested, but if the feed parameter is left blank, it returns the 'rss2' feed link.
== Usage ==
%%% &lt;?php get_category_feed_link( $cat_id, $feed ); ?&gt; %%%
=== Parameters ===
{{Parameter|$cat_id|string|Category ID of feed link to return.}}
{{Parameter|$feed|string|Type of feed, accepts 'rss2' or 'atom'.|optional|rss2}}
== Examples ==
Return the rss2 feed link for post in category 2
&lt;pre&gt;
&lt;?php get_category_feed_link('2', ''); ?&gt;
&lt;/pre&gt;
Display an rss link automatically when viewing a category. Insert this code on the category.php or archive.php page template.
&lt;pre&gt;
if ( is_category() ) {
$category = get_category( get_query_var('cat') );
if ( ! empty( $category ) )
echo '&lt;div class=&quot;category-feed&quot;&gt;&lt;a href=&quot;' . get_category_feed_link( $category-&gt;cat_ID ) . '&quot; title=&quot;' . sprintf( __( 'Subscribe to this category', 'appthemes' ), $category-&gt;name ) . '&quot; rel=&quot;nofollow&quot;&gt;' . __( 'Subscribe!', 'appthemes' ) . '&lt;/a&gt;&lt;/div&gt;';
}
&lt;/pre&gt;
== Notes==
== Resources ==
== Change Log ==
* Since: [[Version 2.5|2.5.0]]
* This function replaces the deprecated '''get_category_rss_link''' function.
== Source File ==
&lt;tt&gt;get_category_feed_link()&lt;/tt&gt; is located in {{Trac|wp-includes/link-template.php}}.
== Related==
&amp;nbsp;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="username_exists" d:title="username exists">
<d:index d:value="username exists"/>
<h1>username exists</h1>
<p>{{Languages|
{{en|Function Reference/username_exists}}
{{it|Riferimento funzioni/username_exists}}
}}
== Description ==
Returns the user ID if the user exists or &lt;tt&gt;null&lt;/tt&gt; if the user doesn't exist.
== Usage ==
%%%&lt;?php username_exists( $username ); ?&gt; %%%
== Parameters ==
{{Parameter|$username|string|a string representing the username to check for existence.}}
== Return Values ==
; (mixed) : This function returns the user ID if the user exists or &lt;tt&gt;null&lt;/tt&gt; if the user does not exist.
== Examples ==
Use &lt;tt&gt;username_exists()&lt;/tt&gt; in your scripts to decide whether the given username exists.
&lt;?php
$username = $_POST['username'];
if ( username_exists( $username ) )
echo &quot;Username In Use!&quot;;
else
echo &quot;Username Not In Use!&quot;;
?&gt;
== Notes ==
== Change Log ==
== Source File ==
&lt;tt&gt;username_exists()&lt;/tt&gt; is located in {{Trac|wp-includes/user.php}}.
== Related ==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:Conditional Tags]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="get_comment" d:title="get comment">
<d:index d:value="get comment"/>
<h1>get comment</h1>
<p>== Description ==
Retrieves comment data given a comment ID or comment object. You can specify, by means of the &lt;tt&gt;$output&lt;/tt&gt; parameter, how you would like the results returned.
If an object is passed then the comment data will be cached and then returned after being passed through a filter. If the comment is empty, then the global comment variable will be used, if it is set.
==Usage==
%%%&lt;?php get_comment( $id, $output ); ?&gt; %%%
==Parameters==
{{Parameter|$comment|integer|The ID of the comment you'd like to fetch. '''You must pass a variable containing an integer''' (e.g. &lt;tt&gt;$id&lt;/tt&gt;). A literal integer (e.g. &lt;tt&gt;7&lt;/tt&gt;) will cause a fatal error (''Only variables can be passed for reference'' or ''Cannot pass parameter 1 by reference'').}}
{{Parameter|$output|string|How you'd like the result. ''OBJECT'' &lt;nowiki&gt;=&lt;/nowiki&gt; an object, ''ARRAY_A'' &lt;nowiki&gt;=&lt;/nowiki&gt; an associative array of keys to values, and ''ARRAY_N'' &lt;nowiki&gt;=&lt;/nowiki&gt; a numerically indexed array of values.|optional|OBJECT}}
== Return ==
{{Return||object&amp;#124;array|On success, it returns the database fields for this comment from the &lt;tt&gt;[[Database_Description#Table:_wp_comments | wp_comments]]&lt;/tt&gt; table, in the format specified. On failure, &lt;tt&gt;null&lt;/tt&gt; is returned. The fields returned are:}}
; &lt;tt&gt;comment_ID&lt;/tt&gt; : (''integer'') The comment ID
; &lt;tt&gt;comment_post_ID&lt;/tt&gt; : (''integer'') The post ID of the associated post
; &lt;tt&gt;comment_author&lt;/tt&gt; : (''string'') The comment author's name
; &lt;tt&gt;comment_author_email&lt;/tt&gt; : (''string'') The comment author's email
; &lt;tt&gt;comment_author_url&lt;/tt&gt; : (''string'') The comment author's webpage
; &lt;tt&gt;comment_author_IP&lt;/tt&gt; : (''string'') The comment author's IP
; &lt;tt&gt;comment_date&lt;/tt&gt; : (''string'') The datetime of the comment (&lt;tt&gt;YYYY-MM-DD HH:MM:SS&lt;/tt&gt;)
; &lt;tt&gt;comment_date_gmt&lt;/tt&gt; : (''string'') The GMT datetime of the comment (&lt;tt&gt;YYYY-MM-DD HH:MM:SS&lt;/tt&gt;)
; &lt;tt&gt;comment_content&lt;/tt&gt; : (''string'') The comment's contents
; &lt;tt&gt;comment_karma&lt;/tt&gt; : (''integer'') The comment's karma
; &lt;tt&gt;comment_approved&lt;/tt&gt; : (''string'') The comment approbation (0, 1 or 'spam')
; &lt;tt&gt;comment_agent&lt;/tt&gt; : (''string'') The comment's agent (browser, Operating System, etc.)
; &lt;tt&gt;comment_type&lt;/tt&gt; : (''string'') The comment's type if meaningfull (&lt;tt&gt;pingback|trackback&lt;/tt&gt;), and empty for normal comments
; &lt;tt&gt;comment_parent&lt;/tt&gt; : (''string'') The parent comment's ID
; &lt;tt&gt;user_id&lt;/tt&gt; : (''integer'') The comment author's ID if he is registered (0 otherwise)
==Example==
To get the author's name of a comment with ID 7:
&lt;pre&gt;&lt;?php
$my_id = 7;
$comment_id_7 = get_comment( $my_id );
$name = $comment_id_7-&gt;comment_author;
?&gt; &lt;/pre&gt;
Alternatively, specify the &lt;tt&gt;$output&lt;/tt&gt; parameter:
&lt;pre&gt;&lt;?php
$my_id = 7;
$comment_id_7 = get_comment( $my_id, ARRAY_A );
$name = $comment_id_7['comment_author'];
?&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;?php
// Correct: pass a dummy variable as post_id
$the_comment = &amp; get_comment( $dummy_id = 7 );
// Incorrect: literal integer as post_id
$the_comment = &amp; get_comment( 7 );
// Fatal error: 'Only variables can be passed for reference' or 'Cannot pass parameter 1 by reference'
?&gt;&lt;/pre&gt;
== Notes ==
* Uses: &lt;tt&gt;[[Class_Reference/wpdb | $wpdb]]&lt;/tt&gt;
== Change Log ==
Since: [[Version 2.0|2.0.0]]
== Source File ==
&lt;tt&gt;get_comment()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}
== Related ==
&amp;nbsp;
{{Tag Footer}}
{{Copyedit}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_post_custom_keys" d:title="get post custom keys">
<d:index d:value="get post custom keys"/>
<h1>get post custom keys</h1>
<p>{{Languages|
{{en|Function Reference/get post custom keys}}
{{ja|関数リファレンス/get post custom keys}}
}}
== Description ==
Returns an array containing the keys of all custom fields of a particular post or page. See also [[Function_Reference/get_post_custom|get_post_custom()]] and [[Function_Reference/get_post_custom_values|get_post_custom_values()]]
== Usage ==
%%% &lt;?php get_post_custom_keys($post_id); ?&gt; %%%
== Parameters ==
{{Parameter|$post_id|integer|The post ID whose custom field keys will be retrieved.|optional|Current post}}
== Examples ==
=== Default Usage ===
The following example will set a variable (&lt;tt&gt;$custom_field_keys&lt;/tt&gt;) as an array containing the keys of all custom fields in the current post, and then print it. Note: the '''if''' test excludes values for WordPress internally maintained custom keys such as ''_edit_last'' and ''_edit_lock''.
&lt;pre&gt;&lt;?php
$custom_field_keys = get_post_custom_keys();
foreach ( $custom_field_keys as $key =&gt; $value ) {
$valuet = trim($value);
if ( '_' == $valuet{0} )
continue;
echo $key . &quot; =&gt; &quot; . $value . &quot;&lt;br /&gt;&quot;;
}
?&gt;&lt;/pre&gt;
If the post contains custom fields with the keys ''mykey'' and ''yourkey'', the output would be something like:
&lt;div style=&quot;border:1px solid blue; width:50%; margin: 20px; padding:20px&quot;&gt;
0 =&gt; mykey&lt;br /&gt;
1 =&gt; yourkey
&lt;/div&gt;
'''''Note:''' Regardless of how many values (custom fields) are assigned to one key, that key will only appear once in this array.''
== Source File ==
&lt;tt&gt;get_post_custom_keys()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Post Meta Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_post_custom" d:title="get post custom">
<d:index d:value="get post custom"/>
<h1>get post custom</h1>
<p>{{Languages|
{{en|Function Reference/get post custom}}
{{ru|Справочник_по_функциям/get post custom}}
{{ja|関数リファレンス/get post custom}}
}}
== Description ==
Returns a multidimensional array with all custom fields of a particular post or page. See also [[Function_Reference/get_post_custom_keys|get_post_custom_keys()]] and [[Function_Reference/get_post_custom_values|get_post_custom_values()]]
== Usage ==
%%% &lt;?php get_post_custom($post_id); ?&gt; %%%
== Parameters ==
{{Parameter|$post_id|integer|The post ID whose custom fields will be retrieved.|optional|Current post}}
== Examples ==
=== Default Usage ===
Use the following example to set a variable (&lt;tt&gt;$custom_fields&lt;/tt&gt;) as a multidimensional array containing all custom fields of the '''current''' post.
&lt;?php $custom_fields = get_post_custom(); ?&gt;
=== Retrieving data from the array ===
The following example will retrieve all custom field values with the key ''my_custom_field'' from post ID ''72'' (assuming there are three custom fields with this key, and the values are &quot;dogs&quot;, &quot;47&quot; and &quot;This is another value&quot;).
&lt;pre&gt;&lt;?php
$custom_fields = get_post_custom(72);
$my_custom_field = $custom_fields['my_custom_field'];
foreach ( $my_custom_field as $key =&gt; $value ) {
echo $key . &quot; =&gt; &quot; . $value . &quot;&lt;br /&gt;&quot;;
}
?&gt;
&lt;/pre&gt;
&lt;div style=&quot;border:1px solid blue; width:50%; margin: 20px; padding:20px&quot;&gt;
0 =&gt; dogs&lt;br/&gt;
1 =&gt; 47&lt;br/&gt;
2 =&gt; This is another value
&lt;/div&gt;
Note: not only does the function return a multi-dimensional array (ie: always be prepared to deal with an array of arrays, even if expecting array of single values), but it also returns serialized values of any arrays stored as meta values.
If you expect that possibly an array may be stored as a metavalue, then be prepared to &lt;tt&gt;[[Function Reference/maybe unserialize | maybe_unserialize]]&lt;/tt&gt;.
== Source Code ==
&lt;tt&gt;get_post_custom()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}
== Changelog ==
* since [[Version 1.5|1.5.0]]
== Related ==
{{Post Meta Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:UI Link]]</p>
</d:entry>
<d:entry id="get_post_custom_values" d:title="get post custom values">
<d:index d:value="get post custom values"/>
<h1>get post custom values</h1>
<p>{{Languages|
{{en|Function Reference/get post custom values}}
{{ja|関数リファレンス/get post custom values}}
}}
== Description ==
This function is useful if you wish to access a custom field that is not unique, i.e. has more than 1 value associated with it. Otherwise, you might wish to look at [[Function_Reference/get_post_meta|get_post_meta()]].
Returns an array containing all the values of the custom fields with a particular key (&lt;tt&gt;$key&lt;/tt&gt;) of a post with ID &lt;tt&gt;$post_id&lt;/tt&gt; (defaults to the current post if unspecified).
Returns nothing if no such key exists, or none is entered.
See also [[Function_Reference/get_post_custom|get_post_custom()]] and [[Function_Reference/get_post_custom_keys|get_post_custom_keys()]].
== Usage ==
%%% &lt;?php get_post_custom_values($key, $post_id); ?&gt; %%%
== Parameters ==
{{Parameter|$key|string|The key whose values you want returned.|required}}
{{Parameter|$post_id|integer|The post ID whose custom fields will be retrieved.|optional|Current post}}
== Examples ==
=== Default Usage ===
Let's assume the current post has 3 values associated with the (custom) field &lt;tt&gt;my_key&lt;/tt&gt;.
You could show them through:
&lt;pre&gt;&lt;?php
$mykey_values = get_post_custom_values( 'my_key' );
foreach ( $mykey_values as $key =&gt; $value ) {
echo &quot;$key =&gt; $value ( 'my_key' )&lt;br /&gt;&quot;;
}
?&gt;&lt;/pre&gt;
0 =&gt; First value ( 'my_key' )
1 =&gt; Second value ( 'my_key' )
2 =&gt; Third value ( 'my_key' )
== Source File ==
&lt;tt&gt;get_post_custom_values()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Post Meta Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="auth_redirect" d:title="auth redirect">
<d:index d:value="auth redirect"/>
<h1>auth redirect</h1>
<p>{{Languages|
{{en|Function Reference/auth_redirect}}
{{it|Riferimento_funzioni/auth_redirect}}
}}
==Description==
Checks user is logged in, if not it redirects them to login page.
When this code is called from a page, it checks to see if the user viewing the page is logged in. If the user is not logged in, they are redirected to the login page. The user is redirected in such a way that, upon logging in, they will be sent directly to the page they were originally trying to access.
== Usage ==
%%%&lt;?php auth_redirect(); ?&gt;%%%
==Parameters==
This function accepts no parameters.
== Return Values ==
Function redirects or exits, does not return
== Examples ==
== Notes ==
As a pluggable function, you can redefine it and your version will be used instead.
== Change Log ==
Since: [[Version 1.5|1.5]]
== Source File ==
auth_redirect() is located in {{Trac|wp-includes/pluggable.php}}
==Related==
[[Function Reference/is user logged in|is_user_logged_in()]], [[Function Reference/wp redirect|wp_redirect()]]
{{Tag Footer}}
[[Category:Needs Review]]
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="email_exists" d:title="email exists">
<d:index d:value="email exists"/>
<h1>email exists</h1>
<p>{{Languages|
{{en|Function Reference/email_exists}}
{{it|Riferimento funzioni/email_exists}}
}}
==Description==
This function will check whether or not a given email address (&lt;tt&gt;$email&lt;/tt&gt;) has already been registered to a username, and returns that users ID (or &lt;tt&gt;false&lt;/tt&gt; if none exists). See also [[Function Reference/username exists|username_exists]].
This function is normally used when a user is registering, to ensure that the E-mail address the user is attempting to register with has not already been registered.
== Usage ==
%%%&lt;?php
if( email_exists( $email )) {
/* stuff to do when mail exists */
}
?&gt;%%%
== Parameter ==
{{Parameter|$email|string|The E-mail address to check|required}}
== Return ==
* If the E-mail exists, function returns the ID of the user to whom the E-mail is registered.
* If the E-mail does not exist, function returns &lt;tt&gt;false&lt;/tt&gt;.
== Examples ==
If the E-mail exists, echo the ID number to which the E-mail is registered. Otherwise, tell the viewer that it does not exist.
&lt;pre&gt;&lt;?php
$email = 'myemail@example.com';
$exists = email_exists($email);
if ( $exists )
echo &quot;That E-mail is registered to user number &quot; . $exists;
else
echo &quot;That E-mail doesn't belong to any registered users on this site&quot;;
?&gt;&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: [[Version 2.1|2.1.0]]
== Source File ==
email_exists() is located in {{Trac|wp-includes/user.php}}
== Related ==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New page created]]
[[Category:Needs Review]]</p>
</d:entry>
<d:entry id="add_post_meta" d:title="add post meta">
<d:index d:value="add post meta"/>
<h1>add post meta</h1>
<p>{{Languages|
{{en|Function Reference/add_post_meta}}
{{ru|Справочник_по_функциям/add_post_meta}}
{{es|Referencia de Funciones/add_post_meta}}
{{ja|関数リファレンス/add_post_meta}}
{{pt-br|Fun&ccedil;&otilde;es e Refer&ecirc;ncias/add_post_meta}}
}}
==Description==
Adds a [[Custom Fields|custom field]] (also called ''meta-data'') to a specified post which could be of any [[Post Types|post type]]. A custom field is effectively a key&ndash;value pair.
Note that if the given key already exists among custom fields of the specified post, another custom field with the same key is added unless the &lt;tt&gt;$unique&lt;/tt&gt; argument is set to &lt;tt&gt;true&lt;/tt&gt;, in which case, no changes are made. If you want to update the value of an existing key, use the &lt;tt&gt;[[Function Reference/update_post_meta|update_post_meta()]]&lt;/tt&gt; function instead.
==Usage==
%%% &lt;?php add_post_meta($post_id, $meta_key, $meta_value, $unique); ?&gt; %%%
==Parameters==
{{Parameter|$post_id|integer|The ID of the post to which a custom field should be added.}}
{{Parameter|$meta_key|string|The key of the custom field which should be added.}}
{{Parameter|$meta_value|mixed|The value of the custom field which should be added. If an array is given, it will be serialized into a string.}}
{{Parameter|$unique|boolean|Whether or not you want the key to stay unique. When set to &lt;tt&gt;true&lt;/tt&gt;, the custom field will not be added if the given key already exists among custom fields of the specified post.|optional|false}}
==Return==
{{Return||boolean|Boolean &lt;tt&gt;true&lt;/tt&gt;, except if the &lt;tt&gt;$unique&lt;/tt&gt; argument was set to &lt;tt&gt;true&lt;/tt&gt; and a custom field with the given key already exists, in which case &lt;tt&gt;false&lt;/tt&gt; is returned.}}
==Examples==
===Default Usage===
&lt;?php add_post_meta( 68, 'my_key', 47 ); ?&gt;
===Adding or Updating a Unique Custom Field===
Adds a new custom field if the key does not already exist, or updates the value of the custom field with that key otherwise.
&lt;?php add_post_meta( 7, 'fruit', 'banana', true ) || update_post_meta( 7, 'fruit', 'banana' ); ?&gt;
The following will have the same effect:
&lt;?php
// Add or Update the meta field in the database.
if ( ! update_post_meta (7, 'fruit', 'banana') ) {
add_post_meta(7, 'fruit', 'banana', true );
};
?&gt;
===Other Examples===
Adds a new custom field only if a custom field with the given key does not already exists:
&lt;?php add_post_meta( 68, 'my_key', '47', true ); ?&gt;
Adds several custom fields with different values but with the same key &lt;tt&gt;'my_key'&lt;/tt&gt;:
&lt;pre&gt;
&lt;?php add_post_meta( 68, 'my_key', '47' ); ?&gt;
&lt;?php add_post_meta( 68, 'my_key', '682' ); ?&gt;
&lt;?php add_post_meta( 68, 'my_key', 'The quick, brown fox jumped over the lazy dog.' ); ?&gt;
...&lt;/pre&gt;
For a more detailed example, see the [[Function Reference/post_meta Function Examples|post_meta Functions Examples]] page.
=== Hidden Custom Fields ===
If you are a plugin or theme developer and you are planning to use custom fields to store parameters related to your plugin or template, it is interesting to note that WordPress will not show custom fields which have keys starting with an &lt;tt&gt;&quot;_&quot;&lt;/tt&gt; (underscore) in the custom fields list on the [[Writing Posts | post edit]] screen or when using the &lt;tt&gt;[[Function Reference/the_meta | the_meta()]]&lt;/tt&gt; template function. This can be for example used to show these custom fields in an unusual way by using the &lt;tt&gt;[[Function Reference/add_meta_box | add_meta_box()]]&lt;/tt&gt; function.
The following example:
&lt;?php add_post_meta( 68, '_color', 'red', true ); ?&gt;
will add a unique custom field with the key name &lt;tt&gt;'_color'&lt;/tt&gt; and the value &lt;tt&gt;'red'&lt;/tt&gt; but this custom field will not display in the post edit screen.
==== Hidden Arrays ====
In addition, if the &lt;tt&gt;$meta_value&lt;/tt&gt; argument is an array, it will &lt;strong&gt;not&lt;/strong&gt; be displayed on the page edit screen, even if you don't prefix the key name with an underscore.
== Notes ==
* Uses &lt;tt&gt;[[Function_Reference/add_metadata | add_metadata()]]&lt;/tt&gt;.
=== Character Escaping ===
Because meta values are passed through the &lt;tt&gt;[http://php.net/stripslashes stripslashes()]&lt;/tt&gt; function, you need to be careful about content escaped with &lt;tt&gt;\&lt;/tt&gt; characters. You can read more about the behavior, and a workaround example, in the &lt;tt&gt;[[Function_Reference/update_post_meta#Character_Escaping | update_post_meta()]]&lt;/tt&gt; documentation.
== Source Code ==
&lt;tt&gt;add_post_meta()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}
== Change Log ==
Since [[Version 1.5|1.5.0]]
==Related==
{{Post Meta Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="update_post_meta" d:title="update post meta">
<d:index d:value="update post meta"/>
<h1>update post meta</h1>
<p>{{Languages|
{{en|Function Reference/update post meta}}
{{ja|関数リファレンス/update post meta}}
}}
==Description==
The function &lt;tt&gt;update_post_meta()&lt;/tt&gt; updates the value of an existing meta key (custom field) for the specified post.
This may be used in place of &lt;tt&gt;[[Function Reference/add post meta | add_post_meta()]]&lt;/tt&gt; function. The first thing this function will do is make sure that &lt;tt&gt;$meta_key&lt;/tt&gt; already exists on &lt;tt&gt;$post_id&lt;/tt&gt;. If it does not, &lt;tt&gt;add_post_meta($post_id, $meta_key, $meta_value)&lt;/tt&gt; is called instead and its result is returned.
Returns &lt;tt&gt;meta_id&lt;/tt&gt; if the meta doesn't exist, otherwise returns &lt;tt&gt;true&lt;/tt&gt; on success and &lt;tt&gt;false&lt;/tt&gt; on failure. It also returns &lt;tt&gt;false&lt;/tt&gt; if the value submitted is the same as the value that is already in the database.
Please note that if your database collation is case insensitive (has with suffix &lt;tt&gt;_ci&lt;/tt&gt;) then &lt;tt&gt;update_post_meta&lt;/tt&gt; and &lt;tt&gt;[[Function_Reference/delete_post_meta | delete_post_meta]]&lt;/tt&gt; and &lt;tt&gt;[[Function_Reference/get_posts | get_posts]]&lt;/tt&gt; will update/delete/query the meta records with keys that are upper or lower case. However &lt;tt&gt;[[Function_Reference/get_post_meta | get_post_meta]]&lt;/tt&gt; will apparently be case sensitive due to [[Class_Reference/WP_Object_Cache | WordPress caching]]. See https://core.trac.wordpress.org/ticket/18210 for more info.
==Usage==
%%% &lt;?php update_post_meta($post_id, $meta_key, $meta_value, $prev_value); ?&gt; %%%
==Parameters==
{{Parameter|$post_id|integer|The ID of the post which contains the field you will edit.}}
{{Parameter|$meta_key|string|The key of the custom field you will edit. (this should be raw as opposed to sanitized for database queries)}}
{{Parameter|$meta_value|mixed|The new value of the custom field. A passed array will be serialized into a string.(this should be raw as opposed to sanitized for database queries)}}
{{Parameter|$prev_value|mixed|The old value of the custom field you wish to change. This is to differentiate between several fields with the same key. If omitted, and there are multiple rows for this post and meta key, all meta values will be updated.|optional|''Empty''}}
== Return Values ==
; (mixed) : Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure. NOTE: If the meta_value passed to this function is the same as the value that is already in the database, this function returns false.
==Examples==
===Default Usage===
&lt;?php update_post_meta(76, 'my_key', 'Steve'); ?&gt;
===Other Examples===
Assuming a post has an ID of 76, and the following 4 custom fields:
&lt;div style=&quot;border:1px solid blue; width:50%; margin: 20px; padding:20px&quot;&gt;
[key_1] =&gt; 'Happy'&lt;br/&gt;
[key_1] =&gt; 'Sad'&lt;br/&gt;
[key_2] =&gt; 'Gregory'&lt;br/&gt;
[my_key] =&gt; 'Steve'&lt;br/&gt;
&lt;/div&gt;
To change &lt;tt&gt;key_2&lt;/tt&gt;'s value to ''Hans'':
&lt;?php update_post_meta( 76, 'key_2', 'Hans' ); ?&gt;
To change &lt;tt&gt;key_1&lt;/tt&gt;'s value from ''Sad'' to ''Happy'':
&lt;?php update_post_meta( 76, 'key_1', 'Happy', 'Sad' ); ?&gt;
The fields would now look like this:
&lt;div style=&quot;border:1px solid blue; width:50%; margin: 20px; padding:20px&quot;&gt;
[key_1] =&gt; 'Happy'&lt;br/&gt;
[key_1] =&gt; 'Happy'&lt;br/&gt;
[key_2] =&gt; 'Hans'&lt;br/&gt;
[my_key] =&gt; 'Steve'&lt;br/&gt;
&lt;/div&gt;
'''''Note:''' This function will update only the first field that matches the criteria.''
To change the first &lt;tt&gt;key_1&lt;/tt&gt;'s value from ''Happy'' to ''Excited'':
&lt;pre&gt;&lt;?php
update_post_meta( 76, 'key_1', 'Excited', 'Happy' );
//Or
update_post_meta( 76, 'key_1', 'Excited' );
//To change all fields with the key &quot;key_1&quot;:
$key1_values = get_post_custom_values( 'key_1', 76 );
foreach ( $key1_values as $value )
update_post_meta( 76, 'key_1', 'Excited', $value );
?&gt;&lt;/pre&gt;
Edit Page template
&lt;pre&gt;&lt;?php
update_post_meta( $id, '_wp_page_template', 'new_template.php' );
?&gt;&lt;/pre&gt;
For a more detailed example, go to the [[Function Reference/post meta Function Examples|post_meta Functions Examples]] page.
==Character Escaping==
Post meta values are passed through the &lt;tt&gt;[http://www.php.net/stripslashes stripslashes()]&lt;/tt&gt; function upon being stored, so you will need to be careful when passing in values (such as JSON) that might include &lt;tt&gt;\&lt;/tt&gt; escaped characters.
===Do not store escaped values===
Consider the JSON value &lt;tt&gt;{&quot;key&quot;:&quot;value with \&quot;escaped quotes\&quot;&quot;}&lt;/tt&gt;:
&lt;pre&gt;&lt;?php
$escaped_json = '{&quot;key&quot;:&quot;value with \\&quot;escaped quotes\\&quot;&quot;}';
update_post_meta( $id, 'escaped_json', $escaped_json );
$broken = get_post_meta( $id, 'escaped_json', true );
/*
$broken, after passing through stripslashes() ends up unparsable:
{&quot;key&quot;:&quot;value with &quot;escaped quotes&quot;&quot;}
*/
?&gt;&lt;/pre&gt;
===Workaround===
By adding one more level of &lt;tt&gt;\&lt;/tt&gt; escaping using function &lt;tt&gt;wp_slash&lt;/tt&gt; (introduced in WP 3.6), you can compensate for the call to &lt;tt&gt;stripslashes()&lt;/tt&gt;:
&lt;pre&gt;&lt;?php
$escaped_json = '{&quot;key&quot;:&quot;value with \\&quot;escaped quotes\\&quot;&quot;}';
update_post_meta( $id, 'double_escaped_json', wp_slash($escaped_json) );
$fixed = get_post_meta( $id, 'double_escaped_json', true );
/*
$fixed, after stripslashes(), ends up being stored as desired:
{&quot;key&quot;:&quot;value with \&quot;escaped quotes\&quot;&quot;}
*/
?&gt;&lt;/pre&gt;
== Notes ==
* This function uses &lt;tt&gt;[[Function_Reference/update_metadata | update_metadata()]]&lt;/tt&gt;.
== Source Code ==
&lt;tt&gt;update_post_meta()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}
== Change Log ==
Since [[Version 1.5|1.5.0]]
==Related==
{{Post Meta Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="delete_post_meta" d:title="delete post meta">
<d:index d:value="delete post meta"/>
<h1>delete post meta</h1>
<p>{{Languages|
{{en|Function Reference/delete post meta}}
{{ru|Справочник_по_функциям/delete post meta}}
{{ja|関数リファレンス/delete post meta}}
}}
==Description==
This function deletes all custom fields with the specified key, or key and value, from the specified post. See also [[Function Reference/update post meta|update_post_meta()]], [[Function Reference/get post meta|get_post_meta()]] and [[Function Reference/add post meta|add_post_meta()]].
==Usage==
%%% &lt;?php delete_post_meta($post_id, $meta_key, $meta_value); ?&gt; %%%
==Parameters==
{{Parameter|$post_id|integer|The ID of the post from which you will delete a field.}}
{{Parameter|$meta_key|string|The key of the field you will delete.}}
{{Parameter|$meta_value|mixed|The value of the field you will delete. This is used to differentiate between several fields with the same key. If left blank, all fields with the given key will be deleted.|optional|''Empty''}}
==Return values==
; (boolean) : False for failure. True for success.
==Examples==
===Default Usage===
&lt;?php delete_post_meta(76, 'my_key', 'Steve'); ?&gt;
===Other Examples===
Let's assume we had a plugin that added some meta values to posts, but now when we are uninstalling the plugin, we want to delete all the post meta keys that the plugin added. Assuming the plugin added the keys &lt;tt&gt;related_posts&lt;/tt&gt; and &lt;tt&gt;post_inspiration&lt;/tt&gt;.
To delete all the keys use delete_post_meta_by_key( $post_meta_key ). This would be added to the &quot;uninstall&quot; function:
&lt;pre&gt;&lt;?php delete_post_meta_by_key( 'related_posts' ); ?&gt;&lt;/pre&gt;
Or, if you wanted to delete all the keys except where &lt;tt&gt;post_inspiration&lt;/tt&gt; was &quot;Sherlock Holmes&quot;:
&lt;pre&gt;&lt;?php
$allposts = get_posts( 'numberposts=-1&amp;post_type=post&amp;post_status=any' );
foreach( $allposts as $postinfo ) {
delete_post_meta( $postinfo-&gt;ID, 'related_posts' );
$inspiration = get_post_meta( $postinfo-&gt;ID, 'post_inspiration' );
foreach( $inspiration as $value ) {
if( 'Sherlock Holmes' !== $value )
delete_post_meta( $postinfo-&gt;ID, 'post_inspiration', $value );
}
}
?&gt;&lt;/pre&gt;
Or maybe post number 185 was just deleted, and you want to remove all &lt;tt&gt;related_posts&lt;/tt&gt; keys that reference it:
&lt;pre&gt;&lt;?php
$allposts = get_posts( 'numberposts=-1&amp;post_type=post&amp;post_status=any' );
foreach( $allposts as $postinfo ) {
delete_post_meta( $postinfo-&gt;ID, 'related_posts', '185' );
}
?&gt;&lt;/pre&gt;
For a more detailed example, go to the [[Function Reference/post meta Function Examples|post_meta Functions Examples]] page.
'''''Note:''' Unlike [[Function Reference/update post meta|update_post_meta()]], This function will delete '''all''' fields that match the criteria.''
== Source File ==
&lt;tt&gt;delete_post_meta()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}
== Change Log ==
Since [[Version 1.5|1.5.0]]
==Related==
{{Post Meta Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_post_meta" d:title="get post meta">
<d:index d:value="get post meta"/>
<h1>get post meta</h1>
<p>{{Languages|
{{en| Function Reference/get post meta}}
{{ja|関数リファレンス/get post meta}}
{{fr|Fonction get post meta}}
}}
==Description==
This function returns the values of the custom fields with the specified key from the specified post. It is a wrapper for &lt;tt&gt;[[Function_Reference/get_metadata | get_metadata]]('post')&lt;/tt&gt;. To return all of the custom fields, see [[Function Reference/get_post_custom|get_post_custom()]]. See also [[Function Reference/update post meta|update_post_meta()]], [[Function Reference/delete post meta|delete_post_meta()]] and [[Function Reference/add post meta|add_post_meta()]].
==Usage==
%%%&lt;?php $meta_values = get_post_meta( $post_id, $key, $single ); ?&gt;%%%
==Parameters==
{{Parameter|$post_id|integer|The ID of the post from which you want the data. Use &lt;code&gt;get_the_ID()&lt;/code&gt; or the global &lt;code&gt;$post&lt;/code&gt; object's ID property (eg &lt;code&gt;$post-&gt;ID&lt;/code&gt;) while in &lt;tt&gt;The Loop&lt;/tt&gt; to get the post's ID, or use your sub-loop's post object ID property (eg &lt;code&gt;$my_post_object-&gt;ID&lt;/code&gt;). (Note: When using a Page to display your posts (set in Settings -&gt; Reading), &lt;code&gt;get_the_ID()&lt;/code&gt; and &lt;code&gt;$post-&gt;ID&lt;/code&gt; will grab the latest Post's ID. To get the containing Page's ID, you will need to use &lt;code&gt;get_queried_object_id()&lt;/code&gt;.) }}
{{Parameter|$key|string|A string containing the name of the meta value you want.|optional}}
{{Parameter|$single|boolean|If set to true then the function will return a single result, as a '''string'''. If false, or not set, then the function returns an '''array''' of the custom fields. This may not be intuitive in the context of serialized arrays. If you fetch a serialized array with this method you want $single to be true to actually get an unserialized array back. If you pass in false, or leave it out, you will have an array of one, and the value at index 0 will be the serialized string.|optional|false}}
==Return Value==
* If only &lt;tt&gt;$id&lt;/tt&gt; is set it will return all meta values in an associative array.
* If &lt;tt&gt;$single&lt;/tt&gt; is set to &lt;tt&gt;false&lt;/tt&gt;, or left blank, the function returns an array containing all values of the specified key.
* If &lt;tt&gt;$single&lt;/tt&gt; is set to &lt;tt&gt;true&lt;/tt&gt;, the function returns the first value of the specified key (not in an array)
If there is nothing to return the function will return an empty &lt;tt&gt;array&lt;/tt&gt; unless &lt;tt&gt;$single&lt;/tt&gt; has been set to &lt;tt&gt;true&lt;/tt&gt;, in which case an empty string is returned.
==Examples==
===Default Usage===
Get the meta for all keys:
&lt;?php $meta = get_post_meta( get_the_ID() ); ?&gt;
Get the meta for a single key:
&lt;?php $key_1_values = get_post_meta( 76, 'key_1' ); ?&gt;
===show the first value of the specified key inside a loop===
&lt;pre&gt;&lt;?php
$key_1_value = get_post_meta( get_the_ID(), 'key_1', true );
// check if the custom field has a value
if( ! empty( $key_1_value ) ) {
echo $key_1_value;
}
?&gt;&lt;/pre&gt;
For a more detailed example, go to the [[Function Reference/post meta Function Examples|post_meta Functions Examples]] page.
===Retrieve a Custom Field Thumbnail Url===
While you are in the [http://codex.wordpress.org/The_Loop WordPress Loop], you can use this code to retrieve a custom field. In this example, the thumbnail image url is in a custom field named &quot;thumb&quot;.
&lt;?php if ( get_post_meta( get_the_ID(), 'thumb', true ) ) : ?&gt;
&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot;&gt;
&lt;img class=&quot;thumb&quot; src=&quot;&lt;?php echo get_post_meta( get_the_ID(), 'thumb', true ); ?&gt;&quot; alt=&quot;&lt;?php the_title(); ?&gt;&quot; /&gt;
&lt;/a&gt;
&lt;?php endif; ?&gt;
== Notes ==
* Please note that if a db collation is case insensitive (has with suffix &lt;tt&gt;_ci&lt;/tt&gt;) then &lt;tt&gt;update_post_meta&lt;/tt&gt; and &lt;tt&gt;delete_post_meta&lt;/tt&gt; and &lt;tt&gt;[[Function_Reference/get_posts | get_posts()]]&lt;/tt&gt; will update/delete/query the meta records with keys that are upper or lower case. However &lt;tt&gt;get_post_meta&lt;/tt&gt; will apparently be case sensitive due to WordPress caching. See https://core.trac.wordpress.org/ticket/18210 for more info. Be careful not to mix upper and lowercase.
* Uses: &lt;tt&gt;[[Function_Reference/get_metadata | get_metadata()]]&lt;/tt&gt; to retrieve the metadata.
== Change Log ==
* Since: 1.5.0
== Source Code ==
&lt;code&gt;get_post_meta()&lt;/code&gt; is located in {{Trac|wp-includes/post.php}}
==Related==
{{Post Meta Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_delete_attachment" d:title="wp delete attachment">
<d:index d:value="wp delete attachment"/>
<h1>wp delete attachment</h1>
<p>==Description==
This function deletes an attachment and all of its derivatives.
==Usage==
%%% &lt;?php wp_delete_attachment( $attachmentid, $force_delete ); ?&gt; %%%
==Parameters==
{{Parameter|$attachmentid|integer|The ID of the attachment you would like to delete.}}
{{Parameter|$force_delete|bool|Whether to bypass trash and force deletion (added in WordPress 2.9).|optional|false}}
==Return Values==
Returns &lt;tt&gt;false&lt;/tt&gt; on failure, post data on success. This should be checked using the identity operator ( === ) instead of the normal equality operator because of the possibility of a returned 0 or empty array:
&lt;?php if ( false === wp_delete_attachment( $attachmentid ) ) do something; ?&gt;
==Hooks==
This function fires the [[Plugin_API/Action_Reference/delete_attachment|delete_attachment]] action hook, passing the attachment's ID (&lt;tt&gt;$postid&lt;/tt&gt;).
==Example==
To delete an attachment with an ID of '76':
&lt;?php wp_delete_attachment( 76 ); ?&gt;
== Source File ==
&lt;tt&gt; wp_delete_attachment()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
==Related==
[[Function Reference/wp get attachment url|wp_get_attachment_url()]]
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_count_posts" d:title="wp count posts">
<d:index d:value="wp count posts"/>
<h1>wp count posts</h1>
<p>{{Languages|
{{en|Function Reference/wp_count_posts}}
{{it|Riferimento funzioni/wp_count_posts}}
}}
== Description ==
This function was introduced in WordPress [[Version 2.5]], and returns an object, whose properties are the count of each post status of a post type. You can also use &lt;code&gt;wp_count_posts()&lt;/code&gt; as a template_tag with the second parameter and include the private post status. By default, or if the user isn't logged in or is a guest of your site, then private post status post count will not be included.
This function will return an object with the post statuses as the properties. You should check for the property using &lt;code&gt;isset()&lt;/code&gt; PHP function, if you are wanting the value for the private post status. Not all post statuses will be part of the object.
== Usage ==
%%% &lt;?php wp_count_posts( $type, $perm ); ?&gt; %%%
== Parameters ==
{{Parameter|$type|string|Post type to count|optional|'post'}}
{{Parameter|$perm|string|To include private posts readable by the current user, set to 'readable'|optional|''empty string''}}
== Examples ==
===Default Usage===
The default usage returns a count of the posts that are published. This will be an object, you can var_dump() the contents to debug the output.
&lt;pre&gt;&lt;?php
$count_posts = wp_count_posts();
?&gt;&lt;/pre&gt;
===Get the Publish Status Post Count===
To get the published status type, you would call the &lt;code&gt;wp_count_posts()&lt;/code&gt; function and then access the ''''publish'''' property.
&lt;pre&gt;&lt;?php
$count_posts = wp_count_posts();
$published_posts = $count_posts-&gt;publish;
?&gt;&lt;/pre&gt;
If you are developing for PHP5 only, then you can use shorthand, if you only want to get one status. This will not work in PHP4 and if you want to maintain backwards compatibility, then you must use the above code.
&lt;pre&gt;&lt;?php
$published_posts = wp_count_posts()-&gt;publish;
?&gt;&lt;/pre&gt;
===Count Drafts===
Counting drafts is handled the same way as the publish status.
&lt;pre&gt;&lt;?php
$count_posts = wp_count_posts();
$draft_posts = $count_posts-&gt;draft;
?&gt;&lt;/pre&gt;
===Count Pages===
Counting pages status types are done in the same way as posts and make use of the first parameter. Finding the number of posts for the post status is done the same way as for posts.
&lt;pre&gt;&lt;?php
$count_pages = wp_count_posts('page');
?&gt;&lt;/pre&gt;
===Other Uses===
The &lt;code&gt;wp_count_posts()&lt;/code&gt; can be used to find the number for post statuses of any post type. This includes attachments or any post type added in the future, either by a plugin or part of the WordPress Core.
== Source File ==
&lt;tt&gt;wp_count_posts()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
==Related==
{{Count Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="check_admin_referer" d:title="check admin referer">
<d:index d:value="check admin referer"/>
<h1>check admin referer</h1>
<p>== Description ==
Tests either if the current request carries a valid [[Glossary#Nonce|nonce]], or if the current request was referred from an [[Administration Screens|administration screen]]; depending on whether the &lt;tt&gt;$action&lt;/tt&gt; argument is given (which is prefered), or not, respectively. On failure, the function [http://php.net/manual/en/function.die.php dies] after calling the &lt;tt&gt;[[Function Reference/wp_nonce_ays|wp_nonce_ays()]]&lt;/tt&gt; function.
Used to avoid security exploits.
''The now improper name of the function is kept for backward compatibility and has origin in previous WordPress versions where the function only checked the referer. For details, see the [[#Notes|Notes]] section below.''
== Usage ==
=== Obsolete Usage ===
%%%&lt;?php check_admin_referer(); ?&gt;%%%
=== Prefered Usage ===
%%%&lt;?php check_admin_referer( $action, $query_arg ); ?&gt;%%%
== Parameters ==
{{Parameter|$action|string|Action name. Should give the context to what is taking place. (Since [[Version 2.0.1|2.0.1]]).|optional|-1}}
{{Parameter|$query_arg|string|Where to look for nonce in the &lt;tt&gt;[http://php.net/manual/en/reserved.variables.request.php $_REQUEST]&lt;/tt&gt; PHP variable. (Since [[Version 2.5|2.5]]).|optional|'_wpnonce'}}
== Return ==
To return boolean ''true'', in the case of the [[#Obsolete Usage|obsolete usage]], the current request must be referred from an [[Administration Screens|administration screen]]; in the case of the [[#Prefered Usage|prefered usage]], the nonce must be sent and valid. Otherwise the function [http://php.net/manual/en/function.die.php dies] with an appropriate message (''&quot;Are you sure you want to do this?&quot;'' by default).
== Examples ==
Obsolete usage here (script dies if the admin referer is not validated).
&lt;pre&gt;
&lt;?php check_admin_referer(); ?&gt;
&lt;/pre&gt;
Here is an example of how you might use this in a plugin's option page. You add a nonce to a form using the &lt;tt&gt;[[Function Reference/wp_nonce_field|wp_nonce_field()]]&lt;/tt&gt; function:
&lt;pre&gt;
&lt;form method=&quot;post&quot;&gt;
&lt;!-- some inputs here ... --&gt;
&lt;?php wp_nonce_field( 'name_of_my_action','name_of_nonce_field' ); ?&gt;
&lt;/form&gt;
&lt;/pre&gt;
Then in the page where the form submits to, you can verify whether or not the form was submitted and update values if it was successfully submitted:
&lt;pre&gt;
&lt;?php
// if this fails, check_admin_referer() will automatically print a &quot;failed&quot; page and die.
if ( ! empty( $_POST ) &amp;&amp; check_admin_referer( 'name_of_my_action', 'name_of_nonce_field' ) ) {
// process form data, e.g. update fields
}
// Display the form
&lt;/pre&gt;
== Notes ==
* Using the function without the &lt;tt&gt;$action&lt;/tt&gt; argument is obsolete and, as of [[Version 3.2]], if [[WP_DEBUG]] is set to ''true'' will die with an appropriate message (''&quot;You should specify a nonce action to be verified by using the first parameter.&quot;'' is the default).
* As of [[Version 2.0.1|2.0.1]], the referer is checked ''only'' if the &lt;tt&gt;$action&lt;/tt&gt; argument is not specified (or set to the default ''-1'') as a backward compatibility fallback for not using a nonce. A nonce is prefered to unreliable referers and with &lt;tt&gt;$action&lt;/tt&gt; specified the function behaves the same way as &lt;tt&gt;[[Function Reference/wp_verify_nonce|wp_verify_nonce()]]&lt;/tt&gt; except that it dies after calling &lt;tt&gt;[[Function Reference/wp_nonce_ays|wp_nonce_ays()]]&lt;/tt&gt; if the nonce is not valid or was not sent.
== Change Log ==
Since: 1.2.0
== Source File ==
&lt;tt&gt;check_admin_referer()&lt;/tt&gt; is located in {{Trac|wp-includes/pluggable.php}}.
== Related ==
{{Nonces}}
* [[Wordpress Nonce Implementation]]
== Resources ==
* [http://php.net/manual/en/function.die.php PHP: die - Manual]
* [http://php.net/manual/en/reserved.variables.request.php PHP: $_REQUEST - Manual]
* [http://markjaquith.wordpress.com/2006/06/02/wordpress-203-nonces/ Mark Jaquith - WordPress Nonces]
* [http://www.prelovac.com/vladimir/improving-security-in-wordpress-plugins-using-nonces Vladimir Prelovac - Using Nonces in WordPress Plugins]
* [[wikipedia:Cryptographic_nonce|Cryptographic nonce - Wikipedia, the free encyclopedia]]
* [http://wordpress.stackexchange.com/questions/48110/wp-verify-nonce-vs-check-admin-referer wp_verify_nonce vs check_admin_referer - WordPress Answers]
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_verify_nonce" d:title="wp verify nonce">
<d:index d:value="wp verify nonce"/>
<h1>wp verify nonce</h1>
<p>== Description ==
Verify that a [[Glossary#Nonce|nonce]] is correct and unexpired with the respect to a specified action. The function is used to verify the nonce sent in the current request usually accessed by the &lt;tt&gt;[http://php.net/manual/en/reserved.variables.request.php $_REQUEST]&lt;/tt&gt; PHP variable.
== Usage ==
%%%&lt;?php wp_verify_nonce( $nonce, $action ); ?&gt;%%%
== Parameters ==
{{Parameter|$nonce|string|Nonce to verify.}}
{{Parameter|$action|string/int|Action name. Should give the context to what is taking place and be the same when the nonce was created.|optional|-1}}
== Return Values ==
{{Return||boolean/integer|Boolean ''false'' if the nonce is invalid. Otherwise, returns an integer with the value of:
* ''1'' &ndash; if the nonce has been generated in the past 12 hours or less.
* ''2'' &ndash; if the nonce was generated between 12 and 24 hours ago.}}
== Example ==
Verify an nonce created with &lt;tt&gt;[[Function_Reference/wp_create_nonce | wp_create_nonce()]]&lt;/tt&gt;:
&lt;pre&gt;
&lt;?php
// Create an nonce, and add it as a query var in a link to perform an action.
$nonce = wp_create_nonce( 'my-nonce' );
echo &quot;&lt;a href='myplugin.php?_wpnonce={$nonce}'&gt;Save Something&lt;/a&gt;&quot;;
?&gt;
.....
&lt;?php
// In our file that handles the request, verify the nonce.
$nonce = $_REQUEST['_wpnonce'];
if ( ! wp_verify_nonce( $nonce, 'my-nonce' ) ) {
die( 'Security check' );
} else {
// Do stuff here.
}
?&gt;
&lt;/pre&gt;
You may also decide to take different actions based on the age of the nonce:
&lt;pre&gt;
&lt;?php
$nonce = wp_verify_nonce( $nonce, 'my-nonce' );
switch ( $nonce ) {
case 1:
echo 'Nonce is less than 12 hours old';
break;
case 2:
echo 'Nonce is between 12 and 24 hours old';
break;
default:
exit( 'Nonce is invalid' );
}
?&gt;
&lt;/pre&gt;
== Change Log ==
Since: [[Version 2.0.3|2.0.3]]
== Source File ==
&lt;tt&gt;wp_verify_nonce()&lt;/tt&gt; is defined in {{Trac|wp-includes/pluggable.php}}
== Related ==
{{Nonces}}
* [[Wordpress Nonce Implementation]]
== External Resources ==
* [http://php.net/manual/en/reserved.variables.request.php PHP: $_REQUEST - Manual]
* [http://markjaquith.wordpress.com/2006/06/02/wordpress-203-nonces/ Mark Jaquith - WordPress Nonces]
* [http://www.prelovac.com/vladimir/improving-security-in-wordpress-plugins-using-nonces Vladimir Prelovac - Using Nonces in WordPress Plugins]
* [[wikipedia:Cryptographic_nonce|Cryptographic nonce - Wikipedia, the free encyclopedia]]
* [http://wordpress.stackexchange.com/questions/48110/wp-verify-nonce-vs-check-admin-referer wp_verify_nonce vs check_admin_referer - WordPress Answers]
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_create_nonce" d:title="wp create nonce">
<d:index d:value="wp create nonce"/>
<h1>wp create nonce</h1>
<p>== Description ==
Generates and returns a [[Glossary#Nonce|nonce]]. The nonce is generated based on the current time, the &lt;tt&gt;$action&lt;/tt&gt; argument, and the current user ID.
== Usage ==
%%%&lt;?php wp_create_nonce( $action ); ?&gt;%%%
== Parameters ==
{{Parameter|$action|string/int|Action name. Should give the context to what is taking place. Optional but ''recommended''.|optional|-1}}
== Return Values ==
{{Return||string|The one use form token.}}
== Example ==
In this simple example, we create an nonce and use it as one of the &lt;tt&gt;GET&lt;/tt&gt; query parameters in a URL for a link. When the user clicks the link they are directed to a page where a certain action will be performed (for example, a post might be deleted). On the target page the nonce is verified to insure that the request was valid (this user really clicked the link and really wants to perform this action).
&lt;pre&gt;&lt;?php
// Create an nonce for a link.
// We pass it as a GET parameter.
// The target page will perform some action based on the 'do_something' parameter.
$nonce = wp_create_nonce( 'my-nonce' );
?&gt;
&lt;a href='myplugin.php?do_something=some_action&amp;_wpnonce=&lt;?php echo $nonce; ?&gt;'&gt;Do some action&lt;/a&gt;
&lt;?php
// This code would go in the target page.
// We need to verify the nonce.
$nonce = $_REQUEST['_wpnonce'];
if ( ! wp_verify_nonce( $nonce, 'my-nonce' ) ) {
// This nonce is not valid.
die( 'Security check' );
} else {
// The nonce was valid.
// Do stuff here.
}
?&gt;
&lt;/pre&gt;
In the above example we simply called our nonce &lt;tt&gt;'my-nonce'&lt;/tt&gt;. It is best to choose a name for the nonce that is specific to the action. For example, if we were to create an nonce that would be part of a request to delete a post, we might call it &lt;tt&gt;'delete_post'&lt;/tt&gt;. Then to make it more specific, we could append the ID of the particular post that the nonce was for. For example &lt;tt&gt;'delete_post-5'&lt;/tt&gt; for the post with ID 5.
&lt;pre&gt;wp_create_nonce( 'delete_post-' . $post_id );&lt;/pre&gt;
Then we would verify the nonce like this:
&lt;pre&gt;wp_verify_nonce( $nonce, 'delete_post-' . $_REQUEST['post_id'] );&lt;/pre&gt;
In general, it is best to make the name for the action as specific as possible.
== Notes ==
* The function should be called using the [[Plugin API/Action Reference/init|init]] or any subsequent action [[Glossary#Hook|hook]]. Calling it outside of an action hook can lead to problems, see the [http://core.trac.wordpress.org/ticket/14024 ticket #14024] for details.
* Uses: [[Function Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] to apply the [[Plugin API/Filter Reference/nonce_user_logged_out| nonce_user_logged_out]] filters on the current user ID used to generate a nonce.
* Uses: [[Function Reference/wp_nonce_tick|&lt;tt&gt;wp_nonce_tick()&lt;/tt&gt;]] as a time-dependent factor to generate a nonce.
== Change Log ==
* Since: [[Version 2.0.3|2.0.3]]
== Source File ==
&lt;tt&gt;wp_create_nonce()&lt;/tt&gt; is located in {{Trac|wp-includes/pluggable.php}}.
== Related ==
{{Nonces}}
* [[Wordpress Nonce Implementation]]
== Resources ==
* [http://markjaquith.wordpress.com/2006/06/02/wordpress-203-nonces/ Mark Jaquith - WordPress Nonces]
* [http://www.prelovac.com/vladimir/improving-security-in-wordpress-plugins-using-nonces Vladimir Prelovac - Using Nonces in WordPress Plugins]
* [[wikipedia:Cryptographic_nonce|Cryptographic nonce - Wikipedia, the free encyclopedia]]
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_insert_attachment" d:title="wp insert attachment">
<d:index d:value="wp insert attachment"/>
<h1>wp insert attachment</h1>
<p>==Description==
This function inserts an attachment into the media library. The function should be used in conjunction with &lt;tt&gt;[[Function_Reference/wp_update_attachment_metadata|wp_update_attachment_metadata()]]&lt;/tt&gt; and &lt;tt&gt;[[Function_Reference/wp_generate_attachment_metadata|wp_generate_attachment_metadata()]]&lt;/tt&gt;. It returns the ID of the entry created in the &lt;tt&gt;wp_posts&lt;/tt&gt; table.
This function is part of the low-level API used by WordPress for handling attachments. To perform the entire attachment upload and insertion process at once, you will want to use &lt;tt&gt;[[Function_Reference/media_handle_upload | media_handle_upload()]]&lt;/tt&gt; instead in most cases.
==Usage==
%%% &lt;?php wp_insert_attachment( $attachment, $filename, $parent_post_id ); ?&gt; %%%
==Parameters==
{{Parameter|$attachment|array|Array of data about the attachment that will be written into the wp_posts table of the database. Must contain at a minimum the keys post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type.}}
{{Parameter|$filename|string|Location of the file on the server. Use absolute path and not the URI of the file. The file MUST be on the uploads directory. See [[Function_Reference/wp_upload_dir|wp_upload_dir()]] |optional|false}}
{{Parameter|$parent_post_id|int|Attachments are associated with parent posts. This is the ID of the parent's post ID.|optional|0}}
==Return Values==
Returns the resulting post ID (int) on success - likely returns 0 on failure.
==Example==
To insert an attachment to a parent with a post ID of 37:
&lt;pre&gt;
&lt;?php
// $filename should be the path to a file in the upload directory.
$filename = '/path/to/uploads/2013/03/filname.jpg';
// The ID of the post this attachment is for.
$parent_post_id = 37;
// Check the type of tile. We'll use this as the 'post_mime_type'.
$filetype = wp_check_filetype( basename( $filename ), null );
// Get the path to the upload directory.
$wp_upload_dir = wp_upload_dir();
// Prepare an array of post data for the attachment.
$attachment = array(
'guid' =&gt; $wp_upload_dir['url'] . '/' . basename( $filename ),
'post_mime_type' =&gt; $filetype['type'],
'post_title' =&gt; preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
'post_content' =&gt; '',
'post_status' =&gt; 'inherit'
);
// Insert the attachment.
$attach_id = wp_insert_attachment( $attachment, $filename, $parent_post_id );
// Make sure that this file is included, as wp_generate_attachment_metadata() depends on it.
require_once( ABSPATH . 'wp-admin/includes/image.php' );
// Generate the metadata for the attachment, and update the database record.
$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
wp_update_attachment_metadata( $attach_id, $attach_data );
&lt;/pre&gt;
==Note==
Using the &lt;code&gt;_wp_relative_upload_path()&lt;/code&gt; to build the guid may not be reliable on some servers.
== Source File ==
&lt;tt&gt;wp_insert_attachment()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php|tags/3.8.1|3976}}.
==Related==
[[Function Reference/wp get attachment url|wp_get_attachment_url()]], [[Function Reference/wp delete attachment|wp_delete_attachment()]], [[Function Reference/wp insert post|wp_insert_post()]]
{{Tag Footer}}
{{Copyedit}}
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="Category:Conditional_Tags" d:title="Category:Conditional Tags">
<d:index d:value="Category:Conditional Tags"/>
<h1>Category:Conditional Tags</h1>
<p>[[Category:Advanced Topics]]
[[Category:Design and Layout]]
[[Category:WordPress Development]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_front_page" d:title="is front page">
<d:index d:value="is front page"/>
<h1>is front page</h1>
<p>{{Languages|
{{en|Function_Reference/is_front_page}}
{{zh-cn|Function_Reference/is_front_page}}
{{ar|Function_Reference/is_front_page}}
{{he|סימוכין פונקציות/is_front_page}}
{{ja|関数リファレンス/is_front_page}}
}}
==Description==
This [[Conditional Tags|Conditional Tag]] checks if the main page is a posts or a [[Pages|Page]]. This is a boolean function, meaning it returns either TRUE or FALSE. It returns TRUE when the main blog page is being displayed and the '''Settings-&gt;Reading-&gt;Front page displays''' is set to &quot;Your latest posts&quot;, '''or''' when is set to &quot;A static page&quot; and the &quot;Front Page&quot; value is the current [[Pages|Page]] being displayed.
==Usage==
%%%&lt;?php is_front_page(); ?&gt;%%%
==Parameters==
This tag does not accept any parameters.
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
&lt;!-- Need creative examples. Feel free add one. --&gt;
If you are using a static page as your front page, this is useful:
%%%
&lt;title&gt;
&lt;?php bloginfo('name'); ?&gt; &amp;raquo; &lt;?php is_front_page() ? bloginfo('description') : wp_title(''); ?&gt;
&lt;/title&gt;
%%%
==Notes==
* See Also: [[Function Reference/is home|is_home()]]
==Change Log==
Since: 2.5.0
==Source File==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_front_page()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_single" d:title="is single">
<d:index d:value="is single"/>
<h1>is single</h1>
<p>{{Languages|
{{en|Function_Reference/is_single}}
{{ru|Справочник_по_функциям/is single}}
{{es|Function_Reference/is_single}}
{{ja|関数リファレンス/is single}}
{{ko|Function_Reference/is_single}}
{{tr|Fonksiyon_Listesi/is_single}}
}}
==Description==
This [[Conditional Tags|conditional tag]] checks if a single post of any [[Post Types|post type]] except [[Using Image and File Attachments|attachment]] and [[Pages|page]] post types is being displayed. If the &lt;tt&gt;$post&lt;/tt&gt; parameter is specified, the function will additionally check if the [[Glossary#Query|query]] is for one of the posts specified. To check for all the post types, use the &lt;tt&gt;[[Function Reference/is singular|is_singular()]]&lt;/tt&gt; function.
==Usage==
%%%&lt;?php is_single($post); ?&gt;%%%
==Parameters==
{{Parameter|$post|mixed|Post ID, Post Title or Post Slug|optional}}
==Return Values==
{{Return||boolean|''True'' on success, ''false'' on failure}}.
==Examples==
is_single();
// When any single Post page is being displayed.
is_single('17');
// When Post 17 (ID) is being displayed.
is_single(17);
// When Post 17 (ID) is being displayed. Integer parameter also works
is_single('Irish Stew');
// When the Post with ''post_title'' of &quot;Irish Stew&quot; is being displayed.
is_single('beef-stew');
// When the Post with ''post_name'' (slug) of &quot;beef-stew&quot; is being displayed.
is_single(array(17,'beef-stew','Irish Stew'));
// Returns true when the single post being displayed is either post ID 17, or the ''post_name'' is &quot;beef-stew&quot;, or the ''post_title'' is &quot;Irish Stew&quot;. Note: the array ability was added at [[Version 2.5]].
==Notes==
* See Also: [[Function Reference/is singular|is_singular()]]
==Change Log==
Since: 1.5.0
==Source File==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_single()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_home" d:title="is home">
<d:index d:value="is home"/>
<h1>is home</h1>
<p>{{Languages|
{{en|Function_Reference/is_home}}
{{zh-cn|Function_Reference/is_home}}
{{he|סימוכין פונקציות/is_home}}
{{ja|関数リファレンス/is_home}}
{{tr|Fonksiyon_Listesi/is_home}}
}}
==Description==
This [[Conditional Tags|Conditional Tag]] checks if the [[Template_Hierarchy#Home_Page_display|blog posts index page]] is being displayed. This is a Boolean function, meaning it returns either TRUE or FALSE.
==Usage==
%%%&lt;?php is_home(); ?&gt;%%%
==Parameters==
This tag does not accept any parameters.
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Blog Posts Index vs. Site Front Page==
Since WordPress 2.1, when the static front page functionality was introduced, the blog posts index and site front page have been treated as two different query contexts, with &lt;code&gt;is_home()&lt;/code&gt; applying to the blog posts index, and &lt;code&gt;is_front_page()&lt;/code&gt; applying to the site front page.
Be careful not to confuse the two query conditionals:
* On the site front page, &lt;code&gt;is_front_page()&lt;/code&gt; will always return &lt;code&gt;TRUE&lt;/code&gt;, regardless of whether the site front page displays the blog posts index or a static page.
* On the blog posts index, &lt;code&gt;is_home()&lt;/code&gt; will always return &lt;code&gt;TRUE&lt;/code&gt;, regardless of whether the blog posts index is displayed on the site front page or a separate page.
Whether &lt;code&gt;is_home()&lt;/code&gt; or &lt;code&gt;is_front_page()&lt;/code&gt; return &lt;code&gt;TRUE&lt;/code&gt; or &lt;code&gt;FALSE&lt;/code&gt; depends on the values of certain option values:
* &lt;code&gt;get_option( 'show_on_front' )&lt;/code&gt;: returns either &lt;code&gt;'posts'&lt;/code&gt; or &lt;code&gt;'page'&lt;/code&gt;
* &lt;code&gt;get_option( 'page_on_front' )&lt;/code&gt;: returns the &lt;code&gt;ID&lt;/code&gt; of the static page assigned to the front page
* &lt;code&gt;get_option( 'page_for_posts' )&lt;/code&gt;: returns the &lt;code&gt;ID&lt;/code&gt; of the static page assigned to the blog posts index (posts page)
When using these query conditionals:
* If &lt;code&gt;'posts' == get_option( 'show_on_front' )&lt;/code&gt;:
** On the site front page:
*** &lt;code&gt;is_front_page()&lt;/code&gt; will return &lt;code&gt;TRUE&lt;/code&gt;
*** &lt;code&gt;is_home()&lt;/code&gt; will return &lt;code&gt;TRUE&lt;/code&gt;
** If assigned, WordPress ignores the pages assigned to display the site front page or the blog posts index
*If &lt;code&gt;'page' == get_option( 'show_on_front' )&lt;/code&gt;:
** On the page assigned to display the site front page:
*** &lt;code&gt;is_front_page()&lt;/code&gt; will return &lt;code&gt;TRUE&lt;/code&gt;
*** &lt;code&gt;is_home()&lt;/code&gt; will return &lt;code&gt;FALSE&lt;/code&gt;
** On the page assigned to display the blog posts index:
*** &lt;code&gt;is_front_page()&lt;/code&gt; will return &lt;code&gt;FALSE&lt;/code&gt;
*** &lt;code&gt;is_home()&lt;/code&gt; will return &lt;code&gt;TRUE&lt;/code&gt;
==Examples==
The following example can be used in your sidebar to display different content when displaying the blog posts index.
%%%
&lt;?php
if ( is_home() ) {
// This is the blog posts index
get_sidebar( 'blog' );
} else {
// This is not the blog posts index
get_sidebar();
}
?&gt;
%%%
==Notes==
&lt;code&gt;is_home&lt;/code&gt; uses the global &lt;var&gt;$wp_query&lt;/var&gt; WP_Query object. &lt;code&gt;is_home&lt;/code&gt; isn't usable before the [[Plugin API\Action Reference\parse_query|parse_query]] action.
* See Also: [[Function Reference/is front page|is_front_page()]]
==Obsolete Usage==
Prior to WordPress 2.1, WordPress did not have static front page functionality, which meant that the site front page and the blog posts index were always the same. Thus, &lt;code&gt;is_home()&lt;/code&gt; always returned &lt;code&gt;TRUE&lt;/code&gt; on the site front page.
==Change Log==
Since: 1.5.0
==Source File==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_home()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_paged" d:title="is paged">
<d:index d:value="is paged"/>
<h1>is paged</h1>
<p>==Description==
This [[Conditional Tags|Conditional Tag]] checks if page being displayed is &quot;paged&quot; and the current page number is greater than one. This is a boolean function, meaning it returns either TRUE or FALSE.
'''Note''': This refers to an archive or the main page being split up over several pages, this does '''not''' refer to a Post or [[Pages|Page]] whose content has been divided into pages using the &lt;tt&gt;&lt;!&lt;nowiki&gt;&lt;/nowiki&gt;--nextpage--&gt;&lt;/tt&gt; [[Write Post SubPanel#Quicktags|QuickTag]].
==Usage==
%%%&lt;?php is_paged(); ?&gt;%%%
==Parameters==
This tag does not accept any parameters.
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : &lt;tt&gt;true&lt;/tt&gt; on success, &lt;tt&gt;false&lt;/tt&gt; on failure.
==Examples==
If you need to check which page of the blog you are on, you can look in $wp_query-&gt;query_vars['paged']. Remember that inside functions you might have to global $wp_query first.
==Notes==
==Change Log==
* Since: [[Version 1.5|1.5.0]]
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_paged()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_page" d:title="is page">
<d:index d:value="is page"/>
<h1>is page</h1>
<p>==Description==
This [[Conditional Tags|Conditional Tag]] checks if [[Pages]] are being displayed. This is a boolean function, meaning it returns either TRUE or FALSE. This tag must be used BEFORE [[The Loop]] and does not work inside The Loop (see [[#Notes|Notes]] below).
==Usage==
%%%&lt;?php is_page($page); ?&gt;%%%
==Parameters==
{{Parameter|$page|mixed|Page ID, Page Title or Page Slug|optional}}
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : &lt;tt&gt;true&lt;/tt&gt; on success, &lt;tt&gt;false&lt;/tt&gt; on failure.
==Examples==
is_page();
// When any single Page is being displayed.
is_page( 42 );
// When Page 42 (ID) is being displayed.
is_page( 'Contact' );
// When the Page with a ''post_title'' of &quot;Contact&quot; is being displayed.
is_page( 'about-me' );
// When the Page with a ''post_name'' (slug) of &quot;about-me&quot; is being displayed.
is_page( array( 42, 'about-me', 'Contact' ) );
// Returns true when the Pages displayed is either post ID 42, or ''post_name'' &quot;about-me&quot;, or ''post_title'' &quot;Contact&quot;. Note: the array ability was added at [[Version 2.5]].
==== Testing for paginated Pages ====
You can use this code to check whether you're on the nth page in a Post or PAGE Page that has been divided into pages using the &lt;tt&gt;&lt;!&lt;nowiki&gt;&lt;/nowiki&gt;--nextpage--&gt;&lt;/tt&gt; QuickTag. This can be useful, for example, if you wish to display meta-data only on the first page of a post divided into several pages.
'''Example 1'''
&lt;pre&gt;&lt;?php
$paged = $wp_query-&gt;get( 'paged' );
if ( ! $paged || $paged &lt; 2 )
{
// This is not a paginated page (or it's simply the first page of a paginated page/post)
}
else
{
// This is a paginated page.
}
?&gt;
&lt;/pre&gt;
'''Example 2'''
&lt;!-- Could someone please take a look at the difference between 'paged' &amp; 'page'? I ran into some support requests, where people said it's 'page', not 'paged' --&gt;
&lt;pre&gt;&lt;?php
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : false;
if ( $paged === false )
{
// This is not a paginated page (or it's simply the first page of a paginated page/post)
}
else
{
// This is a paginated page.
}
?&gt;&lt;/pre&gt;
==== Testing for sub-Pages ====
There is no &lt;tt&gt;is_subpage()&lt;/tt&gt; function yet, but you can test this with a little code:
'''Snippet 1'''
&lt;pre&gt;&lt;?php
global $post; // if outside the loop
if ( is_page() &amp;&amp; $post-&gt;post_parent ) {
// This is a subpage
} else {
// This is not a subpage
}
?&gt;&lt;/pre&gt;
You can create your own is_subpage() function using the code in Snippet 2. Add it to your [http://codex.wordpress.org/Theme_Development#Theme_Functions_File functions.php] file. It tests for a parent page in the same way as Snippet 1, but will return the ID of the page parent if there is one, or &lt;tt&gt;false&lt;/tt&gt; if there isn't.
'''Snippet 2'''
&lt;pre&gt;
function is_subpage() {
global $post; // load details about this page
if ( is_page() &amp;&amp; $post-&gt;post_parent ) { // test to see if the page has a parent
return $post-&gt;post_parent; // return the ID of the parent post
} else { // there is no parent so ...
return false; // ... the answer to the question is false
}
}
&lt;/pre&gt;
It is advisable to use a function like that in Snippet 2, rather than using the simple test like Snippet 1, if you plan to test for sub pages frequently.
To test if the parent of a page is a specific page, for instance &quot;About&quot; (page id ''pid'' 2 by default), we can use the tests in Snippet 3. These tests check to see if we are looking at the page in question, as well as if we are looking at any child pages. This is useful for setting variables specific to different sections of a web site, so a different banner image, or a different heading.
'''Snippet 3'''
&lt;pre&gt;
&lt;?php
if ( is_page( 'about' ) || '2' == $post-&gt;post_parent ) {
// the page is &quot;About&quot;, or the parent of the page is &quot;About&quot;
$bannerimg = 'about.jpg';
} elseif ( is_page( 'learning' ) || '56' == $post-&gt;post_parent ) {
$bannerimg = 'teaching.jpg';
} elseif ( is_page( 'admissions' ) || '15' == $post-&gt;post_parent ) {
$bannerimg = 'admissions.jpg';
} else {
$bannerimg = 'home.jpg'; // just in case we are at an unclassified page, perhaps the home page
}
?&gt;
&lt;/pre&gt;
Snippet 4 is a function that allows you to carry out the tests above more easily. This function will return true if we are looking at the page in question (so &quot;About&quot;) or one of its sub pages (so a page with a parent with ID &quot;2&quot;).
'''Snippet 4'''
&lt;pre&gt;
function is_tree( $pid ) { // $pid = The ID of the page we're looking for pages underneath
global $post; // load details about this page
if ( is_page($pid) )
return true; // we're at the page or at a sub page
$anc = get_post_ancestors( $post-&gt;ID );
foreach ( $anc as $ancestor ) {
if( is_page() &amp;&amp; $ancestor == $pid ) {
return true;
}
}
return false; // we arn't at the page, and the page is not an ancestor
}
&lt;/pre&gt;
Add Snippet 4 to your [http://codex.wordpress.org/Theme_Development#Theme_Functions_File functions.php] file, and call &lt;tt&gt;is_tree( 'id' )&lt;/tt&gt; to see if the current page is the page, or is a sub page of the page. In Snippet 3, &lt;tt&gt;is_tree( '2' )&lt;/tt&gt; would replace &quot;&lt;tt&gt;is_page( 'about' ) || '2' == $post-&gt;post_parent&lt;/tt&gt;&quot; inside the first &lt;tt&gt;if&lt;/tt&gt; tag.
Note that if you have more than one level of pages the parent page is the one directly above and not the one at the very top of the hierarchy.
====Is a Page Template====
Allows you to determine whether or not you are in a page template or if a specific page template is being used.
; &lt;tt&gt;[http://codex.wordpress.org/Function_Reference/is_page_template is_page_template()]&lt;/tt&gt; : Is a [[Page_Templates|Page Template]] being used?
; &lt;tt&gt;is_page_template( 'about.php' )&lt;/tt&gt; : Is [[Page_Templates|Page Template]] 'about' being used? Note that unlike with other conditionals, if you want to specify a particular Page Template, you need to use the filename, such as about.php or my_page_template.php. Note: if the file is in a subdirectory you must include this as well. Meaning that this should be the filepath in relation to your theme as well as the filename, for example 'page-templates/about.php'.
==Notes==
===Passing Empty Value Returns TRUE===
Be very careful if there's a possibility of passing an empty value as a parameter to check for a specific page, since the following lines will return &lt;tt&gt;true&lt;/tt&gt;:
&lt;pre&gt;is_page( '' )
is_page( 0 )
is_page( '0' )
is_page( null )
is_page( false )
is_page( array() )&lt;/pre&gt;
* See also: [[Function Reference/is singular|is_singular()]]
===Cannot Be Used Inside The Loop===
Due to certain global variables being overwritten during The Loop &lt;code&gt;is_page()&lt;/code&gt; will not work. In order to use it after The Loop you must call [[Function_Reference/wp_reset_query| wp_reset_query()]] after The Loop.
* See also [[Function_Reference/is_page_template|is_page_template()]]
==Change Log==
Since: 1.5.0
==Source File==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_page()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_page_template" d:title="is page template">
<d:index d:value="is page template"/>
<h1>is page template</h1>
<p>==Description==
This [[Conditional Tags|Conditional Tag]] allows you to determine if you are in any page template. Optionally checks if a specific [[Page_Templates|Page Template]] is being used in a [[Pages|Page]]. This is a boolean function, meaning it returns either TRUE or FALSE. This tag must be used BEFORE [[The Loop]] and does not work inside The Loop (see [[#Notes|Notes]] below).
==Usage==
%%%&lt;?php is_page_template( $template ); ?&gt;%%%
==Parameters==
{{Parameter|$template|string|Full template filename with ext|optional}}
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
Is [[Page_Templates|Page Template]] 'about' being used? Note that unlike with other conditionals, if you want to specify a particular Page Template, you need to use the filename, such as about.php or my_page_template.php.
&lt;pre&gt;
if ( is_page_template( 'about.php' ) ) {
// Returns true when 'about.php' is being used.
} else {
// Returns false when 'about.php' is not being used.
}
&lt;/pre&gt;
==Notes==
===Page template in subdirectory ===
If the page template is located in a subdirectory of the theme (since WP 3.4), prepend the folder name and a slash to the template filename, e.g.:
&lt;pre&gt;
is_page_template( 'templates/about.php' );
&lt;/pre&gt;
===Cannot Be Used Inside The Loop===
Due to certain global variables being overwritten during The Loop &lt;code&gt;is_page_template()&lt;/code&gt; will not work. In order to use it after The Loop you must call [[Function_Reference/wp_reset_query|wp_reset_query()]] after The Loop.
====Alternative====
Since the page template slug is stored inside the &lt;tt&gt;post_meta&lt;/tt&gt; for any post that has been assigned to a page template, it is possible to directly query the &lt;tt&gt;post_meta&lt;/tt&gt; to see whether any given page has been assigned a page template. This is the method that &lt;tt&gt;is_page_template()&lt;/tt&gt; uses internally.
The function [[Function_Reference/get_page_template_slug|get_page_template_slug( $post_id )]] will return the slug of the currently assigned page template (or an empty string if no template has been assigned - or &lt;tt&gt;false&lt;/tt&gt; if the &lt;tt&gt;$post_id&lt;/tt&gt; does not correspond to an actual &lt;tt&gt;page&lt;/tt&gt;). You can easily use this anywhere (in The Loop, or outside) to determine whether any page has been assigned a page template.
&lt;pre&gt;
&lt;?php
// in the loop:
if ( get_page_template_slug( get_the_ID() ) ){
// Yep, this page has a page template
}
// anywhere:
if ( get_page_template_slug( $some_post_ID ) ){
// Uh-huh.
}
?&gt;
&lt;/pre&gt;
* See also [[Function_Reference/is_page|is_page()]]
==Change Log==
Since: 2.5.0
==Source File==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_page_template()&lt;/tt&gt; is located in {{Trac|wp-includes/post-template.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_search" d:title="is search">
<d:index d:value="is search"/>
<h1>is search</h1>
<p>{{Languages|
{{en|Function_Reference/is_search}}
{{ja|関数リファレンス/is_search}}
{{he|סימוכין פונקציות/is_search}}
}}
==Description==
This [[Conditional Tags|Conditional Tag]] checks if search result page archive is being displayed. This is a boolean function, meaning it returns either TRUE or FALSE.
==Usage==
%%%&lt;?php is_search(); ?&gt;%%%
==Parameters==
This tag does not accept any parameters.
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
%%%
&lt;?php
if ( is_search() ) {
// add external search form (Google, Yahoo, Bing...)
}
?&gt;
%%%
==Notes==
==Change Log==
Since: 1.5.0
==Source File==
&lt;tt&gt;is_search()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_404" d:title="is 404">
<d:index d:value="is 404"/>
<h1>is 404</h1>
<p>{{Languages|
{{en|Function_Reference/is_404}}
{{he|סימוכין פונקציות/is_404}}
{{ja|関数リファレンス/is_404}}
{{pt-br|Fun&ccedil;&otilde;es e Refer&ecirc;ncias/is_404}}
{{tr|Fonksiyon_Listesi/is_404}}
}}
==Description==
This [[Conditional Tags|Conditional Tag]] checks if 404 error is being displayed (after an &quot;HTTP 404: Not Found&quot; error occurs). This is a boolean function, meaning it returns either TRUE or FALSE.
==Usage==
%%%&lt;?php is_404(); ?&gt;%%%
==Parameters==
This tag does not accept any parameters.
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
%%%
&lt;?php
if ( is_404() ) {
// add search form so that users can search other posts
}
?&gt;
%%%
==Notes==
==Change Log==
Since: 1.5.0
==Source File==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_404()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_archive" d:title="is archive">
<d:index d:value="is archive"/>
<h1>is archive</h1>
<p>{{Languages|
{{en|Function Reference/is_archive}}
{{ja|関数リファレンス/is_archive}}
}}
==Description==
This [[Conditional Tags|Conditional Tag]] checks if any type of Archive page is being displayed. An Archive is a [[Function Reference/is category|Category]], [[Function Reference/is tag|Tag]], [[Function Reference/is author|Author]] or a [[Function Reference/is date|Date]] based pages. This is a boolean function, meaning it returns either TRUE or FALSE.
==Usage==
%%%&lt;?php is_archive(); ?&gt;%%%
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
%%%&lt;?php
if(is_archive())
// write your code here ...
?&gt;%%%
==Notes==
===Custom Post Types===
is_archive() does not accept any parameters. If you want to check if this is the archive of a custom post type, use [http://codex.wordpress.org/Function_Reference/is_post_type_archive is_post_type_archive( $post_type )]
==Change Log==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_archive()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_category" d:title="is category">
<d:index d:value="is category"/>
<h1>is category</h1>
<p>{{Languages|
{{en|Function Reference/is_category}}
{{ja|関数リファレンス/is_category}}
{{ru|Справочник_по_функциям/is_category}}
}}
==Description==
This [[Conditional Tags|Conditional Tag]] checks if a Category archive page is being displayed. This is a boolean function, meaning it returns either TRUE or FALSE.
To test if a post &lt;i&gt;is in&lt;/i&gt; a category use [[Function Reference/in_category| in_category()]].
==Usage==
%%%&lt;?php is_category( $category ); ?&gt;%%%
==Parameters==
{{Parameter|$category|mixed|Category ID, Category Title, Category Slug or Array of IDs, names, and slugs.|optional}}
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
is_category();
// When any Category archive page is being displayed.
is_category( '9' );
// When the archive page for Category 9 is being displayed.
is_category( 'Stinky Cheeses' );
// When the archive page for the Category with Name &quot;Stinky Cheeses&quot; is being displayed.
is_category( 'blue-cheese' );
// When the archive page for the Category with Category Slug &quot;blue-cheese&quot; is being displayed.
is_category( array( 9, 'blue-cheese', 'Stinky Cheeses' ) );
// Returns true when the category of posts being displayed is either term_ID 9, or ''slug'' &quot;blue-cheese&quot;, or ''name'' &quot;Stinky Cheeses&quot;. Note: the array ability was added at [[Version 2.5]].
==Notes==
* See also &lt;tt&gt;[[Function Reference/is_archive|is_archive()]]&lt;/tt&gt; and [[Category Templates]].
* For [[Taxonomies#Custom_Taxonomies|Custom Taxonomies]] use [[Function Reference/is_tax|is_tax()]]
==Change Log==
* Since: [[Version 1.5|1.5.0]]
== Source File ==
&lt;tt&gt;is_category()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_tag" d:title="is tag">
<d:index d:value="is tag"/>
<h1>is tag</h1>
<p>{{Languages|
{{en|Function Reference/is tag}}
{{ja|関数リファレンス/is tag}}
}}
==Description==
This [[Conditional Tags|Conditional Tag]] checks if a Tag archive page is being displayed. This is a boolean function, meaning it returns either TRUE or FALSE.
==Usage==
%%%&lt;?php is_tag( $tag ); ?&gt;%%%
==Parameters==
{{Parameter|$tag|mixed|Tag ID, name, slug, or array of id's, names, and slugs.|optional}}
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
is_tag();
// When any Tag archive page is being displayed.
is_tag( '30' );
// When the archive page for Tag 30 is being displayed.
is_tag( 'extreme' );
// When the archive page for tag with the Slug of 'extreme' is being displayed.
is_tag( 'mild' );
// When the archive page for tag with the Name of 'mild' is being displayed.
is_tag( array( 30, 'mild', 'extreme' ) );
// Returns true when the tag of posts being displayed is either term_ID 30, or ''slug'' &quot;extreme&quot;, or ''name'' &quot;mild&quot;. Note: the array ability was added at [[Version 3.7]].
==Notes==
* See also &lt;tt&gt;[[Function Reference/is_archive|is_archive()]]&lt;/tt&gt; and [[Tag Templates]].
==Change Log==
* Since: [[Version 2.3|2.3.0]]
* [[Version 3.7|3.7.0]]: Make &lt;tt&gt;$tag&lt;/tt&gt; parameter recieve tag ID, name, slug, or array of tag IDs, names, and slugs.
==Source File==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_tag()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Tag Tags}}
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_author" d:title="is author">
<d:index d:value="is author"/>
<h1>is author</h1>
<p>{{Languages|
{{en|is_author}}
{{ja|関数リファレンス/is_author}}
}}
==Description==
This [[Conditional Tags|Conditional Tag]] checks if an Author archive page is being displayed. This is a boolean function, meaning it returns either TRUE or FALSE.
==Usage==
%%%&lt;?php is_author($author); ?&gt;%%%
==Parameters==
{{Parameter|$author|mixed|Author ID or Author Nickname|optional}}
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
is_author();
// When any Author page is being displayed.
is_author('4');
// When the archive page for Author number (ID) 4 is being displayed.
is_author('Vivian');
// When the archive page for the Author with Nickname &quot;Vivian&quot; is being displayed.
is_author('john-jones');
// When the archive page for the Author with Nicename &quot;john-jones&quot; is being displayed.
is_author(array(4,'john-jones','Vivian'));
// When the archive page for the author is either user ID 4, or ''user_nicename'' &quot;john-jones&quot;, or ''nickname'' &quot;Vivian&quot;. Note: the array ability was added at [[Version 2.5]].
==Notes==
* See also &lt;tt&gt;[[Function Reference/is_archive|is_archive()]]&lt;/tt&gt; and [[Category Templates]].
==Change Log==
Since: [[Version 1.5]]
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_author()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_date" d:title="is date">
<d:index d:value="is date"/>
<h1>is date</h1>
<p>{{Languages|
{{en|Function Reference/is_date}}
{{ja|関数リファレンス/is_date}}
}}
==Description==
Test to see if the page is a date based archive page. Similar to [[Function_Reference/is_category|is_category()]]
==Usage==
%%%&lt;?php is_date(); ?&gt;%%%
==Parameters==
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
==Notes==
* See also &lt;tt&gt;[[Function Reference/is_archive|is_archive()]]&lt;/tt&gt; and [[Category Templates]].
==Change Log==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_date()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_year" d:title="is year">
<d:index d:value="is year"/>
<h1>is year</h1>
<p>==Description==
Test to see if the page is a year based archive page.
==Usage==
%%%&lt;?php is_year(); ?&gt;%%%
==Parameters==
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
==Notes==
* See also &lt;tt&gt;[[Function Reference/is_archive|is_archive()]]&lt;/tt&gt; and [[Category Templates]].
==Change Log==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_year()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_month" d:title="is month">
<d:index d:value="is month"/>
<h1>is month</h1>
<p>==Description==
Test to see if the page is a month based archive page.
==Usage==
%%%&lt;?php is_month(); ?&gt;%%%
==Parameters==
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
==Notes==
* See also &lt;tt&gt;[[Function Reference/is_archive|is_archive()]]&lt;/tt&gt; and [[Category Templates]].
==Change Log==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_month()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_day" d:title="is day">
<d:index d:value="is day"/>
<h1>is day</h1>
<p>==Description==
Test to see if the page is a date based archive page.
==Usage==
%%%&lt;?php is_day(); ?&gt;%%%
==Parameters==
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
==Notes==
* See also &lt;tt&gt;[[Function Reference/is_archive|is_archive()]]&lt;/tt&gt; and [[Category Templates]].
==Change Log==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_day()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_time" d:title="is time">
<d:index d:value="is time"/>
<h1>is time</h1>
<p>==Description==
Test to see if the page is a time based archive page.
==Usage==
%%%&lt;?php is_time(); ?&gt;%%%
==Parameters==
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
==Notes==
* See also &lt;tt&gt;[[Function Reference/is_archive|is_archive()]]&lt;/tt&gt; and [[Category Templates]].
==Change Log==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_time()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_attachment" d:title="is attachment">
<d:index d:value="is attachment"/>
<h1>is attachment</h1>
<p>{{Languages|
{{en|Function_Reference/is_ attachment}}
{{it|Riferimento funzioni/is_ attachment}}
{{ja|関数リファレンス/is_ attachment}}
}}
==Description==
This [[Conditional Tags|Conditional Tag]] checks if an attachment is being displayed. An attachment is an image or other file uploaded through the post editor's upload utility. Attachments can be displayed on their own 'page' or template. For more information, see [[Using Image and File Attachments]].
This is a boolean function, meaning it returns either TRUE or FALSE.
==Usage==
%%%&lt;?php is_attachment(); ?&gt;%%%
==Parameters==
==Return Values==
{{Return||boolean|True on success, false on failure.}}
==Examples==
&lt;pre&gt;
&lt;?php
if ( is_attachment() ) {
// show adv. #1
} else {
// show adv. #2
}
?&gt;
&lt;/pre&gt;
==Notes==
* See Also: [[Function Reference/is singular|is_singular()]]
* For more specific checking of the attachment see: [[Function Reference/wp attachment is image]]
==Change Log==
Since: 2.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_attachment()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_admin" d:title="is admin">
<d:index d:value="is admin"/>
<h1>is admin</h1>
<p>==Description==
This [[Conditional Tags|Conditional Tag]] checks if the Dashboard or the administration panel is attempting to be displayed. It ''should not'' be used as a means to verify whether the current user has permission to view the Dashboard or the administration panel (try [[Function_Reference/current_user_can|current_user_can()]] instead). This is a boolean function that will return &lt;tt&gt;true&lt;/tt&gt; if the URL being accessed is in the admin section, or &lt;tt&gt;false&lt;/tt&gt; for a front-end page.
==Usage==
%%%&lt;?php is_admin(); ?&gt;%%%
==Parameters==
This tag does not accept any parameters.
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
&lt;pre&gt;
if ( ! is_admin() ) {
echo &quot;You are viewing the theme&quot;;
} else {
echo &quot;You are viewing the WordPress Administration Panels&quot;;
}
&lt;/pre&gt;
==Notes==
* &lt;tt&gt;is_admin()&lt;/tt&gt; will return &lt;tt&gt;false&lt;/tt&gt; when trying to access wp-login.php.
* &lt;tt&gt;is_admin()&lt;/tt&gt; will return &lt;tt&gt;true&lt;/tt&gt; when trying to make an ajax request.
* &lt;tt&gt;is_admin()&lt;/tt&gt; will return &lt;tt&gt;true&lt;/tt&gt; for calls to load-scripts.php and load-styles.php.
* &lt;tt&gt;is_admin()&lt;/tt&gt; is ''not'' intended to be used for security checks. It will return true whenever the current URL is for a page on the admin side of WordPress. It does not check if the user is logged in, nor if the user even has access to the page being requested. It is a convenience function for plugins and themes to use for various purposes, but it is not suitable for validating secured requests.
==Change Log==
Since: 1.5.1
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_admin()&lt;/tt&gt; is located in {{Trac|wp-includes/load.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_preview" d:title="is preview">
<d:index d:value="is preview"/>
<h1>is preview</h1>
<p>==Description==
This [[Conditional Tags|Conditional Tag]] checks if the currently displayed post, page or post type is a preview. This is a boolean function that will return the value of the &lt;tt&gt;preview&lt;/tt&gt; query value, which is either &lt;tt&gt;true&lt;/tt&gt; or &lt;tt&gt;false&lt;/tt&gt; for a front-end page.
==Usage==
%%%&lt;?php is_preview(); ?&gt;%%%
==Parameters==
This tag does not accept any parameters.
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
&lt;pre&gt;if ( ! is_preview() ) {
// Include analytics code
}&lt;/pre&gt;
==Notes==
==Change Log==
Since: 2.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_preview()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_feed" d:title="is feed">
<d:index d:value="is feed"/>
<h1>is feed</h1>
<p>==Description==
Can be used to determine if the current query is for a [[WordPress_Feeds|feed]] (e.g. RSS).
==Usage==
%%%&lt;?php
if ( is_feed( $feeds ) ) {
//Do stuff
}
?&gt;%%%
==Parameters==
{{Parameter|$feeds|array/string|Feed type(s) to check.|optional}}
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
==Notes==
==Change Log==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_feed()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_trackback" d:title="is trackback">
<d:index d:value="is trackback"/>
<h1>is trackback</h1>
<p>==Description==
==Usage==
%%%&lt;?php is_trackback(); ?&gt;%%%
==Parameters==
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
==Notes==
==Change Log==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_trackback()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="comments_open" d:title="comments open">
<d:index d:value="comments open"/>
<h1>comments open</h1>
<p>==Description==
This [[Conditional Tags|Conditional Tag]] checks if comments are allowed for the current Post or a given Post ID. This is a boolean function, meaning it returns either TRUE or FALSE.
==Usage==
%%%&lt;?php comments_open( $post_id ); ?&gt;%%%
==Parameters==
{{Parameter|$post_id|integer|The post ID|optional|0}}
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
With this code you can always disable comments on pages, assuming your theme uses comments_open() to check if the comments are open.
&lt;pre&gt;
add_filter( 'comments_open', 'my_comments_open', 10, 2 );
function my_comments_open( $open, $post_id ) {
$post = get_post( $post_id );
if ( 'page' == $post-&gt;post_type )
$open = false;
return $open;
}
&lt;/pre&gt;
With this code you can enable comments on a post that has custom field &quot;Allow Comments&quot; set
to 1. This is helpful when you have told WordPress to disable comments for posts that are older than X days but wish to enable comments for a handful of old posts.
&lt;pre&gt;
add_filter( 'comments_open', 'my_comments_open', 10, 2 );
function my_comments_open( $open, $post_id ) {
$post = get_post( $post_id );
if (get_post_meta($post-&gt;ID, 'Allow Comments', true)) {$open = true;}
return $open;
}
&lt;/pre&gt;
'''Enqueuing a script only if we're seeing a single post and comments are open for the current post'''
&lt;pre&gt;
add_action( 'wp_print_scripts', 'myplugin_scripts' );
function myplugin_scripts(){
if ( is_single() &amp;&amp; comments_open() ) {
// myplugin_script must have been previously registered via wp_register_script()
wp_enqueue_script( 'myplugin_script' );
}
}
&lt;/pre&gt;
==Notes==
==Change Log==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;comments_open()&lt;/tt&gt; is located in {{Trac|wp-includes/comment-template.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="pings_open" d:title="pings open">
<d:index d:value="pings open"/>
<h1>pings open</h1>
<p>==Description==
This [[Conditional Tags|Conditional Tag]] checks if trackbacks are allowed for the current Post or a given Post ID. This is a boolean function, meaning it returns either TRUE or FALSE.
==Usage==
%%%&lt;?php pings_open( $post_id ); ?&gt;%%%
==Parameters==
{{Parameter|$post_id|integer|The post ID|optional|0}}
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
==Notes==
==Change Log==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;pings_open()&lt;/tt&gt; is located in {{Trac|wp-includes/comment-template.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="Function_Reference" d:title="Function Reference">
<d:index d:value="Function Reference"/>
<h1>Function Reference</h1>
<p>{{Languages|
{{en|Function Reference}}
{{es|Referencia de Funciones}}
{{fax|Function_Reference}}
{{fr|Fonctions de r&eacute;f&eacute;rence}}
{{it|Riferimento funzioni}}
{{ja|関数リファレンス}}
{{ka|ფუნქციების ცნობარი}}
{{ko|Function_Reference}}
{{pt-br|Refer&ecirc;ncia_de_Fun&ccedil;&otilde;es}}
{{ru|Справочник по функциям}}
{{tr|Fonksiyon Listesi}}
{{he|Function Reference}}
{{zh-hans|函数参考}}
{{zh-tw|函數參考}}
}}
__TOC__
The files of WordPress define many useful PHP functions. Some of the functions, known as [[Template Tags]], are defined especially for use in WordPress Themes. There are also some functions related to actions and filters (the [[Plugin API]]), which are therefore used primarily for developing Plugins. The rest are used to create the core WordPress functionality.
Many of the core WordPress functions are useful to Plugin and Theme developers. So, this article lists most of the core functions, excluding Template Tags. At the bottom of the page, there is a section listing other resources for finding information about WordPress functions. In addition to this information, the [http://phpdoc.wordpress.org/ WordPress phpdoc site] details all the WordPress functions by version since 2.6.1.
&lt;!-- remove the DIV below after there's enough example content --&gt;
&lt;div style=&quot;border:#CCCCCC 1px solid; padding:10px; background:#FAEBD7;&quot;&gt;
'''You can help make this page more complete!'''
Here are some things you can do to help:
* Add documentation to un-documented functions, by creating sub-pages or at least by adding short comments in the lists below. If you create a subpage for a function, please include information and examples of usage of that function, if possible, per the examples found in [[Template Tags]].
* List more functions here, following the category structure.
* Correct errors by moving functions to better categories where appropriate, and of course fixing typos. Note: that it is OK for a function to appear in more than one category.
Read [[Contributing to WordPress]] to find out more about how you can contribute to the effort!
&lt;/div&gt;
==Functions by category==
{| cellspacing=&quot;10&quot; width=&quot;100%&quot;
|- valign=&quot;top&quot;
| width=&quot;50%&quot; |
{| class=&quot;widefat&quot;
|- style=&quot;background:#464646;&quot;
!
=== &lt;span style=&quot;color:#d7d7d7;&quot;&gt;Post, Custom Post Type, Page, Attachment and Bookmarks Functions&lt;/span&gt; ===
|-
|
'''Posts'''
* &lt;tt&gt;[[Function Reference/get_adjacent_post|get_adjacent_post]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_boundary_post|get_boundary_post]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_children|get_children]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_extended|get_extended]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_next_post|get_next_post]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_next_posts_link|get_next_posts_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/next_posts_link|next_posts_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_permalink|get_permalink]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_permalink|the_permalink]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_excerpt|get_the_excerpt]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_excerpt|the_excerpt]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_post_thumbnail|get_the_post_thumbnail]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post|get_post]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_field|get_post_field]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_ancestors|get_post_ancestors]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_mime_type|get_post_mime_type]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_status|get_post_status]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_format|get_post_format]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/set_post_format|set_post_format]]&lt;/tt&gt;
* &lt;tt&gt;[[Template_Tags/get_edit_post_link|get_edit_post_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_delete_post_link|get_delete_post_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_previous_post|get_previous_post]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_previous_posts_link|get_previous_posts_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/previous_posts_link|previous_posts_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Template Tags/get_posts|get_posts]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/have_posts|have_posts]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_post|is_post]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/is_single|is_single]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_sticky|is_sticky]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_ID|get_the_ID]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_ID|the_ID]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_post|the_post]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_recent_posts|wp_get_recent_posts]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_single_post|wp_get_single_post]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/has_post_thumbnail|has_post_thumbnail]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/has_excerpt|has_excerpt]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/has_post_format|has_post_format]]&lt;/tt&gt;
'''Custom Post Type'''
* &lt;tt&gt;[[Function Reference/register_post_type|register_post_type]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_post_type_archive|is_post_type_archive]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/post_type_archive_title|post_type_archive_title]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_post_type_support|add_post_type_support]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_post_type_support|remove_post_type_support]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/post_type_supports|post_type_supports]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/set_post_type|set_post_type]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/post_type_exists|post_type_exists]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_type|get_post_type]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_types|get_post_types]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_type_archive_link|get_post_type_archive_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_type_object|get_post_type_object]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_type_capabilities|get_post_type_capabilities]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_type_labels|get_post_type_labels]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_post_type_hierarchical|is_post_type_hierarchical]]&lt;/tt&gt;
'''Post insertion/removal'''
* &lt;tt&gt;[[Function Reference/wp_delete_post|wp_delete_post]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_insert_post|wp_insert_post]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_publish_post|wp_publish_post]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_trash_post|wp_trash_post]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_update_post|wp_update_post]]&lt;/tt&gt;
'''Pages'''
* &lt;tt&gt;[[Function Reference/get_all_page_ids|get_all_page_ids]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_ancestors|get_ancestors]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_page|get_page]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/get_page_link|get_page_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_page_by_path|get_page_by_path]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_page_by_title|get_page_by_title]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_page_children|get_page_children]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_page_hierarchy|get_page_hierarchy]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_page_uri|get_page_uri]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_pages|get_pages]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_page|is_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/page_uri_index|page_uri_index]]&lt;/tt&gt; (method of class WP_Rewrite)
* &lt;tt&gt;[[Function Reference/wp_link_pages|wp_link_pages]]&lt;/tt&gt;
* &lt;tt&gt;[[Template Tags/wp_list_pages|wp_list_pages]]&lt;/tt&gt;
* &lt;tt&gt;[[Template Tags/wp_page_menu|wp_page_menu]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_dropdown_pages|wp_dropdown_pages]]&lt;/tt&gt;
'''Custom Fields (postmeta)'''
* &lt;tt&gt;[[Function Reference/add_post_meta|add_post_meta]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/delete_post_meta|delete_post_meta]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_custom|get_post_custom]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_custom_keys|get_post_custom_keys]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_custom_values|get_post_custom_values]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_meta|get_post_meta]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_post_meta|update_post_meta]]&lt;/tt&gt;
'''Attachments'''
* &lt;tt&gt;[[Function Reference/get_attached_file|get_attached_file]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/image_resize|image_resize]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function reference/image_edit_before_change|image_edit_before_change]]&lt;/tt&gt; (ported to [[Class Reference/WP_Image_Editor|WP_Image_Editor]] object)
* &lt;tt&gt;[[Function Reference/is_attachment|is_attachment]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_local_attachment|is_local_attachment]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/set_post_thumbnail|set_post_thumbnail]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_attached_file|update_attached_file]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_attachment_is_image|wp_attachment_is_image]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_create_thumbnail|wp_create_thumbnail]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/wp_insert_attachment|wp_insert_attachment]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_delete_attachment|wp_delete_attachment]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_attachment_image|wp_get_attachment_image]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_attachment_link|wp_get_attachment_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_attachment_image_src|wp_get_attachment_image_src]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_attachment_metadata|wp_get_attachment_metadata]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_attachment_thumb_file|wp_get_attachment_thumb_file]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_attachment_thumb_url|wp_get_attachment_thumb_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_attachment_url|wp_get_attachment_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_check_for_changed_slugs|wp_check_for_changed_slugs]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_count_posts|wp_count_posts]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_mime_types|wp_get_mime_types]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_mime_type_icon|wp_mime_type_icon]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_generate_attachment_metadata|wp_generate_attachment_metadata]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_prepare_attachment_for_js|wp_prepare_attachment_for_js]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_update_attachment_metadata|wp_update_attachment_metadata]]&lt;/tt&gt;
'''Bookmarks'''
* &lt;tt&gt;[[Function Reference/get_bookmark|get_bookmark]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/get_bookmarks|get_bookmarks]]&lt;/tt&gt;
* &lt;tt&gt;[[Template_Tags/wp_list_bookmarks|wp_list_bookmarks]]&lt;/tt&gt;
'''Terms'''
* &lt;tt&gt;[[Function Reference/wp_get_post_categories|wp_get_post_categories]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_set_post_categories|wp_set_post_categories]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_post_tags|wp_get_post_tags]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_set_post_tags|wp_set_post_tags]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_post_terms|wp_get_post_terms]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_set_post_terms|wp_set_post_terms]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_count_terms|wp_count_terms]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/has_term|has_term]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_object_in_term|is_object_in_term]]&lt;/tt&gt;
'''Others'''
* &lt;tt&gt;[[Function Reference/add_meta_box|add_meta_box]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_meta_box|remove_meta_box]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_ID|get_the_ID]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_ID|the_ID]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_author|get_the_author]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_author|the_author]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_author_posts|get_the_author_posts]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_content|get_the_content]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_content|the_content]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_title|get_the_title]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_title|the_title]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_title_attribute|the_title_attribute]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/register_post_status|register_post_status]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_trim_excerpt|wp_trim_excerpt]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_post_revision|wp_get_post_revision]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_post_revisions|wp_get_post_revisions]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_is_post_revision|wp_is_post_revision]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/paginate_links|paginate_links]]&lt;/tt&gt;
|}
| width=&quot;50%&quot; |
{| class=&quot;widefat&quot;
|- style=&quot;background:#464646;&quot;
!
=== &lt;span style=&quot;color:#d7d7d7;&quot;&gt;Category, Tag and Taxonomy Functions&lt;/span&gt; ===
|-
|
'''Categories'''
* &lt;tt&gt;[[Function Reference/cat_is_ancestor_of|cat_is_ancestor_of]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_all_category_ids|get_all_category_ids]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_ancestors|get_ancestors]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_cat_ID|get_cat_ID]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_cat_name|get_cat_name]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_categories|get_categories]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_category|get_category]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_category_by_path|get_category_by_path]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_category_by_slug|get_category_by_slug]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_category_by_ID|get_the_category_by_ID]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_category_list|get_the_category_list]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_category_link| get_category_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_category_parents|get_category_parents]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_category|get_the_category]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/single_cat_title|single_cat_title]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/in_category|in_category]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_category|is_category]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_category|the_category]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_category_checklist|wp_category_checklist]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_dropdown_categories|wp_dropdown_categories]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_list_categories|wp_list_categories]]&lt;/tt&gt;
'''Category Creation'''
* &lt;tt&gt;[[Function Reference/wp_create_category|wp_create_category]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_delete_category|wp_delete_category]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_insert_category|wp_insert_category]]&lt;/tt&gt;
'''Tags'''
* &lt;tt&gt;[[Function Reference/get_tag|get_tag]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_tag_link|get_tag_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_tags|get_tags]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_tag_list|get_the_tag_list]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_tags|get_the_tags]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/has_tag|has_tag]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_tag|is_tag]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_tags|the_tags]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/single_tag_title|single_tag_title]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/tag_description|tag_description]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_generate_tag_cloud|wp_generate_tag_cloud]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_tag_cloud|wp_tag_cloud]]&lt;/tt&gt;
'''Taxonomy'''
* &lt;tt&gt;[[Function Reference/get_edit_term_link|get_edit_term_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_taxonomy|get_taxonomy]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_taxonomies|get_taxonomies]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_term|get_term]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_term_list|get_the_term_list]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_term_by|get_term_by]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_terms|the_terms]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_terms|get_the_terms]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_term_children|get_term_children]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_term_link|get_term_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_terms|get_terms]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_taxonomy|is_taxonomy]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/is_taxonomy_hierarchical|is_taxonomy_hierarchical]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_term|is_term]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/taxonomy_exists|taxonomy_exists]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/term_exists|term_exists]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/register_taxonomy|register_taxonomy]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/register_taxonomy_for_object_type|register_taxonomy_for_object_type]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_object_terms|wp_get_object_terms]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_remove_object_terms|wp_remove_object_terms]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_set_object_terms|wp_set_object_terms]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_insert_term|wp_insert_term]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_update_term|wp_update_term]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_delete_term|wp_delete_term]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_terms_checklist|wp_terms_checklist]]&lt;/tt&gt;
|}
|- valign=&quot;top&quot;
| width=&quot;50%&quot; |
{| class=&quot;widefat&quot;
|- style=&quot;background:#464646;&quot;
!
=== &lt;span style=&quot;color:#d7d7d7;&quot;&gt;User and Author Functions&lt;/span&gt; ===
|-
|
'''Admins, Roles and Capabilities'''
* &lt;tt&gt;[[Function Reference/add_cap|add_cap]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_role|add_role]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/author_can|author_can]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/current_user_can|current_user_can]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/current_user_can_for_blog|current_user_can_for_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_role|get_role]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_super_admins|get_super_admins]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_super_admin|is_super_admin]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/map_meta_cap|map_meta_cap]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_cap|remove_cap]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_role|remove_role]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/user_can|user_can]]&lt;/tt&gt;
'''Users and Authors'''
* &lt;tt&gt;[[Function Reference/auth_redirect|auth_redirect]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/count_users|count_users]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/count_user_posts|count_user_posts]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/count_many_users_posts|count_many_users_posts]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/email_exists|email_exists]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_currentuserinfo|get_currentuserinfo]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_current_user_id|get_current_user_id]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_profile|get_profile]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/get_user_by|get_user_by]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_userdata|get_userdata]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_usernumposts|get_usernumposts]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/get_users|get_users]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/set_current_user|set_current_user]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/user_pass_ok|user_pass_ok]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/wp_authenticate|wp_authenticate]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/username_exists|username_exists]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/validate_username|validate_username]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_dropdown_users|wp_dropdown_users]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_current_user|wp_get_current_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_set_current_user|wp_set_current_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_set_password|wp_set_password]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_author_posts_url | get_author_posts_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_modified_author|get_the_modified_author]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_multi_author|is_multi_author]]&lt;/tt&gt;
'''User meta'''
* &lt;tt&gt;[[Function Reference/add_user_meta|add_user_meta]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/delete_user_meta|delete_user_meta]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_user_meta|get_user_meta]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_user_meta|update_user_meta]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_author_meta|get_the_author_meta]]&lt;/tt&gt;
'''User insertion/removal'''
* &lt;tt&gt;[[Function Reference/wp_create_user|wp_create_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_delete_user|wp_delete_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_insert_user|wp_insert_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_update_user|wp_update_user]]&lt;/tt&gt;
'''Login / Logout'''
* &lt;tt&gt;[[Function Reference/is_user_logged_in|is_user_logged_in]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_login_form|wp_login_form]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_signon|wp_signon]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_logout|wp_logout]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_loginout|wp_loginout]]&lt;/tt&gt;
|}
| width=&quot;50%&quot; |
{| class=&quot;widefat&quot;
|- style=&quot;background:#464646;&quot;
!
=== &lt;span style=&quot;color:#d7d7d7;&quot;&gt;Feed Functions&lt;/span&gt; ===
|-
|
* &lt;tt&gt;[[Function Reference/bloginfo_rss|bloginfo_rss]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/comment_author_rss|comment_author_rss]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/comment_link|comment_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/comment_text_rss|comment_text_rss]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_feed|do_feed]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_feed_atom|do_feed_atom]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_feed_rdf|do_feed_rdf]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_feed_rss|do_feed_rss]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_feed_rss2|do_feed_rss2]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/fetch_feed|fetch_feed]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/fetch_rss|fetch_rss]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/get_author_feed_link|get_author_feed_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_bloginfo_rss|get_bloginfo_rss]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_category_feed_link|get_category_feed_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_comment_link|get_comment_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_comment_author_rss|get_comment_author_rss]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_comments_feed_link|get_post_comments_feed_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_rss|get_rss]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/get_search_comments_feed_link|get_search_comments_feed_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_search_feed_link|get_search_feed_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_category_rss|get_the_category_rss]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_title_rss|get_the_title_rss]]&lt;/tt&gt;
* &lt;tt&gt;[[Template_Tags/permalink_single_rss|permalink_single_rss]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/post_comments_feed_link|post_comments_feed_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/rss_enclosure|rss_enclosure]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_title_rss|the_title_rss]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_category_rss|the_category_rss]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_content_rss|the_content_rss]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/the_excerpt_rss|the_excerpt_rss]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_rss|wp_rss]]&lt;/tt&gt; (deprecated)
|}
|- valign=&quot;top&quot;
| width=&quot;50%&quot; |
{| class=&quot;widefat&quot;
|- style=&quot;background:#464646;&quot;
!
=== &lt;span style=&quot;color:#d7d7d7;&quot;&gt;HTTP API Functions&lt;/span&gt; ===
|-
|
* &lt;tt&gt;[[Function Reference/wp_remote_get|wp_remote_get]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_remote_retrieve_body|wp_remote_retrieve_body]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_http_headers|wp_get_http_headers]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_remote_fopen|wp_remote_fopen]]&lt;/tt&gt;
|}
|- valign=&quot;top&quot;
| width=&quot;50%&quot; |
{| class=&quot;widefat&quot;
|- style=&quot;background:#464646;&quot;
!
=== &lt;span style=&quot;color:#d7d7d7;&quot;&gt;Comment, Ping, and Trackback Functions&lt;/span&gt; ===
|-
|
* &lt;tt&gt;[[Function Reference/add_ping|add_ping]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_comment_meta|add_comment_meta]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/check_comment|check_comment]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/comment_text|comment_text]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/comment_form|comment_form]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/comments_number|comments_number]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/discover_pingback_server_uri|discover_pingback_server_uri]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/delete_comment_meta|delete_comment_meta]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_all_pings|do_all_pings]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_enclose|do_enclose]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_trackbacks|do_trackbacks]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/generic_ping|generic_ping]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_approved_comments|get_approved_comments]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_avatar|get_avatar]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_comment|get_comment]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_comment_text|get_comment_text]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_comment_meta|get_comment_meta]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_comments|get_comments]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_list_comments|wp_list_comments]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_enclosed|get_enclosed]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_lastcommentmodified|get_lastcommentmodified]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_pung|get_pung]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_to_ping|get_to_ping]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/have_comments|have_comments]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_comment_author|get_comment_author]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_trackback|is_trackback]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/pingback|pingback]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/privacy_ping_filter|privacy_ping_filter]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_comment_cookies|sanitize_comment_cookies]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/trackback|trackback]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/trackback_url|trackback_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/trackback_url_list|trackback_url_list]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_comment_meta|update_comment_meta]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/weblog_ping|weblog_ping]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_allow_comment|wp_allow_comment]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_count_comments|wp_count_comments]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_delete_comment|wp_delete_comment]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_filter_comment|wp_filter_comment]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_comment_status|wp_get_comment_status]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_current_commenter|wp_get_current_commenter]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_insert_comment|wp_insert_comment]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_new_comment|wp_new_comment]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_set_comment_status|wp_set_comment_status]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_throttle_comment_flood|wp_throttle_comment_flood]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_update_comment|wp_update_comment]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_update_comment_count|wp_update_comment_count]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_update_comment_count_now|wp_update_comment_count_now]]&lt;/tt&gt;
'''Comments Loop'''
* &lt;tt&gt;[[Function Reference/comment_class|comment_class]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/comment_ID|comment_ID]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/comment_author|comment_author]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/comment_date|comment_date]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/comment_time|comment_time]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_comment_date|get_comment_date]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_comment_time|get_comment_time]]&lt;/tt&gt;
'''Comments Pagination'''
* &lt;tt&gt;[[Function Reference/paginate_comments_links|paginate_comments_links]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/previous_comments_link|previous_comments_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/next_comments_link|next_comments_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_comment_pages_count|get_comment_pages_count]]&lt;/tt&gt;
|}
| width=&quot;50%&quot; |
{| class=&quot;widefat&quot;
|- style=&quot;background:#464646;&quot;
!
=== &lt;span style=&quot;color:#d7d7d7;&quot;&gt;Action, Filter, and Plugin Functions&lt;/span&gt; ===
|-
|
'''Filters''' ([[Plugin API/Filter Reference|Reference]])
* &lt;tt&gt;[[Function Reference/has_filter|has_filter]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_filter|add_filter]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/apply_filters|apply_filters]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/apply_filters_ref_array|apply_filters_ref_array]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/current_filter|current_filter]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/merge_filters|merge_filters]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_filter|remove_filter]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_all_filters|remove_all_filters]]&lt;/tt&gt;
'''Actions''' ([[Plugin API/Action Reference|Reference]])
* &lt;tt&gt;[[Function Reference/has_action|has_action]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_action|add_action]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_action|do_action]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_action_ref_array|do_action_ref_array]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/did_action|did_action]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_action|remove_action]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_all_actions|remove_all_actions]]&lt;/tt&gt;
'''Plugins''' ([[Plugin API|Reference]])
* &lt;tt&gt;[[Function Reference/plugin_basename|plugin_basename]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/plugins_url|plugins_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_plugin_data|get_plugin_data]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_admin_page_title|get_admin_page_title]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/plugin_dir_path|plugin_dir_path]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/register_activation_hook|register_activation_hook]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/register_deactivation_hook|register_deactivation_hook]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/menu_page_url|menu_page_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_plugin_active|is_plugin_active]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_plugin_active_for_network|is_plugin_active_for_network]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_plugin_inactive|is_plugin_inactive]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_plugin_page|is_plugin_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_contextual_help|add_contextual_help]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/get_plugins|get_plugins]]&lt;/tt&gt;
'''Widgets''' ([[Widgets API|Reference]])
* &lt;tt&gt;[[Function Reference/is_active_widget|is_active_widget]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/register_widget|register_widget]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_widget|the_widget]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/unregister_widget|unregister_widget]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_add_dashboard_widget|wp_add_dashboard_widget]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_convert_widget_settings|wp_convert_widget_settings]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_sidebars_widgets|wp_get_sidebars_widgets]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_widget_defaults|wp_get_widget_defaults]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_register_sidebar_widget|wp_register_sidebar_widget]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_register_widget_control|wp_register_widget_control]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_set_sidebars_widgets|wp_set_sidebars_widgets]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_unregister_sidebar_widget|wp_unregister_sidebar_widget]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_unregister_widget_control|wp_unregister_widget_control]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_widget_description|wp_widget_description]]&lt;/tt&gt;
'''Settings''' ([[Settings API|Reference]])
* &lt;tt&gt;[[Function Reference/register_setting|register_setting]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/unregister_setting|unregister_setting]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/settings_fields|settings_fields]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_settings_fields|do_settings_fields]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/do_settings_sections|do_settings_sections]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/add_settings_field|add_settings_field]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/add_settings_section|add_settings_section]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/add_settings_error|add_settings_error]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/get_settings_errors|get_settings_errors]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/settings_errors|settings_errors]]&lt;/tt&gt;
'''Shortcodes''' ([[Shortcode API|Reference]])
* &lt;tt&gt;[[Function Reference/add_shortcode|add_shortcode]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_shortcode|do_shortcode]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_shortcode_tag|do_shortcode_tag]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_shortcode_regex|get_shortcode_regex]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_shortcode|remove_shortcode]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_all_shortcodes|remove_all_shortcodes]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/shortcode_atts|shortcode_atts]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/shortcode_parse_atts|shortcode_parse_atts]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/strip_shortcodes|strip_shortcodes]]&lt;/tt&gt;
|}
|- valign=&quot;top&quot;
| width=&quot;50%&quot; |
{| class=&quot;widefat&quot;
|- style=&quot;background:#464646;&quot;
!
=== &lt;span style=&quot;color:#d7d7d7;&quot;&gt;Theme-Related Functions&lt;/span&gt; ===
|-
|
'''Include functions'''
* &lt;tt&gt;[[Function Reference/comments_template|comments_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_footer|get_footer]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_header|get_header]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_sidebar|get_sidebar]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_search_form|get_search_form]]&lt;/tt&gt;
'''Other functions'''
* &lt;tt&gt;[[Function Reference/add_custom_background|add_custom_background]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/add_custom_image_header|add_custom_image_header]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/add_image_size|add_image_size]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_theme_support|add_theme_support]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/body_class|body_class]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/current_theme_supports|current_theme_supports]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/dynamic_sidebar|dynamic_sidebar]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_404_template|get_404_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_archive_template|get_archive_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_attachment_template|get_attachment_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_author_template|get_author_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_body_class|get_body_class]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_category_template|get_category_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_comments_popup_template|get_comments_popup_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_current_theme|get_current_theme]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_date_template|get_date_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_header_image|get_header_image]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_header_textcolor|get_header_textcolor]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_home_template|get_home_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_locale_stylesheet_uri|get_locale_stylesheet_uri]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_page_template|get_page_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_paged_template|get_paged_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_class|get_post_class]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_query_template|get_query_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_search_template|get_search_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_single_template|get_single_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_stylesheet|get_stylesheet]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_stylesheet_directory|get_stylesheet_directory]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_stylesheet_directory_uri|get_stylesheet_directory_uri]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_stylesheet_uri|get_stylesheet_uri]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_tag_template|get_tag_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_taxonomy_template|get_taxonomy_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_template|get_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_template_directory|get_template_directory]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_template_directory_uri|get_template_directory_uri]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_template_part|get_template_part]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_theme|get_theme]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/wp_get_themes|wp_get_themes]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_theme_data|get_theme_data]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/get_theme_support|get_theme_support]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_theme_mod|get_theme_mod]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_theme_mods|get_theme_mods]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_theme_root|get_theme_root]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_theme_roots|get_theme_roots]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_theme_root_uri|get_theme_root_uri]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_themes|get_themes]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/header_image|header_image]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/header_textcolor|header_textcolor]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/in_the_loop|in_the_loop]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_child_theme|is_child_theme]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_active_sidebar|is_active_sidebar]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_admin_bar_showing|is_admin_bar_showing]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_dynamic_sidebar|is_dynamic_sidebar]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/language_attributes|language_attributes]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/load_template|load_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/locale_stylesheet|locale_stylesheet]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/locate_template|locate_template]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/post_class|post_class]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/preview_theme|preview_theme]]&lt;/tt&gt;
&lt;!-- * &lt;tt&gt;[[Function Reference/_preview_theme_template_filter|_preview_theme_template_filter]]&lt;/tt&gt; --&gt;
* &lt;tt&gt;[[Function Reference/preview_theme_ob_filter|preview_theme_ob_filter]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/preview_theme_ob_filter_callback|preview_theme_ob_filter_callback]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/register_nav_menu|register_nav_menu]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/register_nav_menus|register_nav_menus]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_registered_nav_menus|get_registered_nav_menus]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/register_sidebar|register_sidebar]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/register_sidebars|register_sidebars]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/register_theme_directory|register_theme_directory]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_theme_mod|remove_theme_mod]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_theme_mods|remove_theme_mods]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_theme_support|remove_theme_support]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/require_if_theme_supports|require_if_theme_supports]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/search_theme_directories|search_theme_directories]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/set_theme_mod|set_theme_mod]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/switch_theme|switch_theme]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/validate_current_theme|validate_current_theme]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/unregister_nav_menu|unregister_nav_menu]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/unregister_sidebar|unregister_sidebar]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_add_inline_style|wp_add_inline_style]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_clean_themes_cache|wp_clean_themes_cache]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_archives|wp_get_archives]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_nav_menu_items|wp_get_nav_menu_items]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_theme|wp_get_theme]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_nav_menu|wp_nav_menu]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_oembed_remove_provider|wp_oembed_remove_provider]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_page_menu|wp_page_menu]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_title|wp_title]]&lt;/tt&gt;
|}
| width=&quot;50%&quot; |
{| class=&quot;widefat&quot;
|- style=&quot;background:#464646;&quot;
!
=== &lt;span style=&quot;color:#d7d7d7;&quot;&gt;Formatting Functions&lt;/span&gt; ===
|-
|
* &lt;tt&gt;[[Function Reference/absint|absint]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_magic_quotes|add_magic_quotes]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/addslashes_gpc|addslashes_gpc]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/antispambot|antispambot]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/attribute_escape|attribute_escape]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/backslashit|backslashit]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/balanceTags|balanceTags]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/clean_pre|clean_pre]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/clean_url|clean_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/convert_chars|convert_chars]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/convert_smilies|convert_smilies]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/ent2ncr|ent2ncr]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/esc_attr|esc_attr]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/esc_html|esc_html]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/esc_js|esc_js]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/esc_textarea|esc_textarea]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/esc_sql|esc_sql]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/esc_url|esc_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/esc_url_raw|esc_url_raw]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/force_balance_tags|force_balance_tags]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/format_to_edit|format_to_edit]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/format_to_post|format_to_post]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/funky_javascript_fix|funky_javascript_fix]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/htmlentities2|htmlentities2]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_email|is_email]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/js_escape|js_escape]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/make_clickable|make_clickable]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/popuplinks|popuplinks]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_accents|remove_accents]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_email|sanitize_email]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_file_name|sanitize_file_name]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_html_class|sanitize_html_class]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_key|sanitize_key]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_mime_type|sanitize_mime_type]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_option|sanitize_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_sql_orderby|sanitize_sql_orderby]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_text_field|sanitize_text_field]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_title|sanitize_title]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_title_for_query|sanitize_title_for_query]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_title_with_dashes|sanitize_title_with_dashes]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sanitize_user|sanitize_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/seems_utf8|seems_utf8]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/stripslashes_deep|stripslashes_deep]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/trailingslashit|trailingslashit]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/untrailingslashit|untrailingslashit]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/urlencode_deep|urlencode_deep]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/url_shorten|url_shorten]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/utf8_uri_encode|utf8_uri_encode]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpautop|wpautop]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wptexturize|wptexturize]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_filter_kses|wp_filter_kses]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_filter_post_kses|wp_filter_post_kses]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_filter_nohtml_kses|wp_filter_nohtml_kses]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_iso_descrambler|wp_iso_descrambler]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses|wp_kses]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_array_lc|wp_kses_array_lc]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_attr|wp_kses_attr]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_bad_protocol|wp_kses_bad_protocol]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_bad_protocol_once|wp_kses_bad_protocol_once]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_bad_protocol_once2|wp_kses_bad_protocol_once2]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_check_attr_val|wp_kses_check_attr_val]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_decode_entities|wp_kses_decode_entities]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_hair|wp_kses_hair]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_hook|wp_kses_hook]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_html_error|wp_kses_html_error]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_js_entities|wp_kses_js_entities]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_no_null|wp_kses_no_null]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_normalize_entities|wp_kses_normalize_entities]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_normalize_entities2|wp_kses_normalize_entities2]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_split|wp_kses_split]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_split2|wp_kses_split2]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_strip_slashes|wp_kses_stripslashes]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_kses_version|wp_kses_version]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_make_link_relative|wp_make_link_relative]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_normalize_path|wp_normalize_path]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_rel_nofollow|wp_rel_nofollow]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_richedit_pre|wp_richedit_pre]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_specialchars|wp_specialchars]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_trim_words|wp_trim_words]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/zeroise|zeroise]]&lt;/tt&gt;
|}
|- valign=&quot;top&quot;
| width=&quot;50%&quot; |
{| class=&quot;widefat&quot;
|- style=&quot;background:#464646;&quot;
!
=== &lt;span style=&quot;color:#d7d7d7;&quot;&gt;Miscellaneous Functions&lt;/span&gt; ===
|-
|
'''Time/Date Functions'''
* &lt;tt&gt;[[Function Reference/current_time|current_time]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/date_i18n|date_i18n]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/get_calendar|get_calendar]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_date_from_gmt|get_date_from_gmt]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_lastpostdate|get_lastpostdate]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_lastpostmodified|get_lastpostmodified]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/get_day_link|get_day_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_gmt_from_date|get_gmt_from_date]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/get_month_link|get_month_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/the_date|the_date]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_the_date|get_the_date]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/the_time|the_time]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/get_the_time|get_the_time]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/the_modified_time|the_modified_time]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/get_the_modified_time|get_the_modified_time]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_weekstartend|get_weekstartend]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/get_year_link|get_year_link]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/human_time_diff|human_time_diff]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_new_day|is_new_day]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/iso8601_timezone_to_offset|iso8601_timezone_to_offset]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/iso8601_to_datetime|iso8601_to_datetime]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/mysql2date|mysql2date]]&lt;/tt&gt;
'''Serialization'''
* &lt;tt&gt;[[Function Reference/is_serialized|is_serialized]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_serialized_string|is_serialized_string]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/maybe_serialize|maybe_serialize]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/maybe_unserialize|maybe_unserialize]]&lt;/tt&gt;
'''Options'''
* &lt;tt&gt;[[Function Reference/add_option|add_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_site_option|add_site_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/delete_option|delete_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/delete_site_option|delete_site_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/form_option|form_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_alloptions|get_alloptions]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/get_site_option|get_site_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_site_url|get_site_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_admin_url|get_admin_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_user_option|get_user_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_option|get_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_option|update_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_site_option|update_site_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_user_option|update_user_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_load_alloptions|wp_load_alloptions]]&lt;/tt&gt;
'''Transients'''
* &lt;tt&gt;[[Function_Reference/set_transient | set_transient()]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/get_transient | get_transient()]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/delete_transient | delete_transient()]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/set_site_transient | set_site_transient()]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/get_site_transient | get_site_transient()]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/delete_site_transient | delete_site_transient()]]&lt;/tt&gt;
'''Admin Menu Functions'''
* &lt;tt&gt;[[Function Reference/add_menu_page|add_menu_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_menu_page|remove_menu_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_submenu_page|add_submenu_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_submenu_page|remove_submenu_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_object_page|add_object_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_utility_page|add_utility_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_comments_page|add_comments_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_dashboard_page|add_dashboard_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_links_page|add_links_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_management_page|add_management_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_media_page|add_media_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_options_page|add_options_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_pages_page|add_pages_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_plugins_page|add_plugins_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_posts_page|add_posts_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_theme_page|add_theme_page]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_users_page|add_users_page]]&lt;/tt&gt;
'''Toolbar Functions'''
* &lt;tt&gt;[[Function Reference/add_node|add_node]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_node|remove_node]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_group|add_group]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_node|get_node]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_nodes|get_nodes]]&lt;/tt&gt;
'''Form Helpers'''
* &lt;tt&gt;[[Function Reference/checked|checked]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/disabled|disabled]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/selected|selected]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/submit_button|submit_button]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_submit_button|get_submit_button]]&lt;/tt&gt;
'''Nonces and Referers (Security)'''
* &lt;tt&gt;[[Function Reference/check_admin_referer|check_admin_referer]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/check_ajax_referer|check_ajax_referer]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_create_nonce|wp_create_nonce]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_explain_nonce|wp_explain_nonce]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/wp_get_original_referer|wp_get_original_referer]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_referer|wp_get_referer]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_nonce_ays|wp_nonce_ays]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_nonce_field|wp_nonce_field]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_nonce_url|wp_nonce_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_original_referer_field|wp_original_referer_field]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_referer_field|wp_referer_field]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_send_json|wp_send_json]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_send_json_error|wp_send_json_error]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_send_json_success|wp_send_json_success]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_verify_nonce|wp_verify_nonce]]&lt;/tt&gt;
'''XMLRPC'''
* &lt;tt&gt;[[Function Reference/xmlrpc_getpostcategory|xmlrpc_getpostcategory]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/xmlrpc_getposttitle|xmlrpc_getposttitle]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/xmlrpc_removepostdata|xmlrpc_removepostdata]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/user_pass_ok|user_pass_ok]]&lt;/tt&gt; (deprecated)
'''Localization'''
* &lt;tt&gt;[[Function Reference/_2|__]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/_x|_x]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/_n|_n]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/_nx|_nx]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/_e|_e]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/_ex|_ex]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/_2ngettext|_ngettext]] (deprecated)&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/esc_attr_2|esc_attr__]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/esc_attr_e|esc_attr_e]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_locale|get_locale]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/load_default_textdomain|load_default_textdomain]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/load_plugin_textdomain|load_plugin_textdomain]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/load_textdomain|load_textdomain]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/load_theme_textdomain|load_theme_textdomain]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_rtl|is_rtl]]&lt;/tt&gt;
'''Cron (Scheduling)'''
* &lt;tt&gt;[[Function Reference/spawn_cron|spawn_cron]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_clear_scheduled_hook|wp_clear_scheduled_hook]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_cron|wp_cron]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_schedule|wp_get_schedule]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_schedules|wp_get_schedules]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_next_scheduled|wp_next_scheduled]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_reschedule_event|wp_reschedule_event]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_schedule_event|wp_schedule_event]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_schedule_single_event|wp_schedule_single_event]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_unschedule_event|wp_unschedule_event]]&lt;/tt&gt;
'''Conditional Tags Index '''
* &lt;tt&gt; [[Conditional Tags#Any_Page_Containing_Posts|comments_open]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional_Tags#Has_A_Nav_Menu_Assigned|has_nav_menu]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Tag_Page|has_tag]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Category_Page|in_category]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_404_Not_Found_Page|is_404]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#The_Administration_Panels|is_admin]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#Any_Archive_Page|is_archive]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#An_Attachment|is_attachment]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#An_Author_Page|is_author]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Category_Page|is_category]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Comments_Popup|is_comments_popup]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Date_Page|is_date]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Date_Page|is_day]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Syndication|is_feed]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#The_Front_Page|is_front_page]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#The_Main_Page|is_home]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Date_Page|is_month]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_PAGE_Page|is_page]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#Is_a_Page_Template|is_page_template]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Paged_Page|is_paged]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Preview|is_preview]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Search_Result_Page|is_search]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Single_Post_Page|is_single]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Single_Page,_Single_Post_or_Attachment|is_singular]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Sticky_Post|is_sticky]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Tag_Page|is_tag]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Tax_Page|is_tax]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Date_Page|is_time]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Trackback|is_trackback]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#A_Date_Page|is_year]]&lt;/tt&gt;
* &lt;tt&gt; [[Conditional Tags#Any_Page_Containing_Posts|pings_open]]&lt;/tt&gt;
'''Script and Style Registration'''
* &lt;tt&gt;[[Function Reference/wp_dequeue_script|wp_dequeue_script]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_dequeue_style|wp_dequeue_style]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_deregister_script|wp_deregister_script]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_deregister_style|wp_deregister_style]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_enqueue_script|wp_enqueue_script]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_enqueue_style|wp_enqueue_style]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_localize_script|wp_localize_script]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_register_script|wp_register_script]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_register_style|wp_register_style]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_script_is|wp_script_is]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_style_is|wp_style_is]]&lt;/tt&gt;
'''sql'''
* &lt;tt&gt;[[Function Reference/get_tax_sql|get_tax_sql]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_meta_sql|get_meta_sql]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_posts_by_author_sql|get_posts_by_author_sql]]&lt;/tt&gt;
'''Miscellaneous'''
* &lt;tt&gt;[[Function Reference/add_editor_style|add_editor_style]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_query_arg|add_query_arg]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_rewrite_rule|add_rewrite_rule]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/admin_url|admin_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/bool_from_yn|bool_from_yn]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/cache_javascript_headers|cache_javascript_headers]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/capital_P_dangit|capital_P_dangit]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/clean_blog_cache|clean_blog_cache]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/content_url|content_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/do_robots|do_robots]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/flush_rewrite_rules|flush_rewrite_rules]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_bloginfo|get_bloginfo]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_num_queries|get_num_queries]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_stati|get_post_stati]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_post_statuses|get_post_statuses]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_query_var|get_query_var]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/home_url|home_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/includes_url|includes_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_blog_installed|is_blog_installed]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_main_site|is_main_site]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_main_query|is_main_query]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_multisite|is_multisite]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_ssl|is_ssl]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_wp_error|is_wp_error]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/log_app|log_app]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/make_url_footnote|make_url_footnote]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/network_admin_url|network_admin_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/network_home_url|network_home_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/network_site_url|network_site_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/nocache_headers|nocache_headers]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/plugin_dir_url|plugin_dir_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/query_posts|query_posts]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_query_arg|remove_query_arg]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/rewind_posts|rewind_posts]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/setup_postdata|setup_postdata]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/site_url|site_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/status_header|status_header]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/unzip_file|unzip_file]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/validate_file|validate_file]]&lt;/tt&gt;
* &lt;tt&gt;[[Function_Reference/validate_file_to_edit|validate_file_to_edit]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp|wp]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_cache_set|wp_cache_set]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_cache_get|wp_cache_get]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_cache_reset|wp_cache_reset]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/wp_check_filetype|wp_check_filetype]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_clearcookie|wp_clearcookie]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/wp_die|wp_die]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_editor|wp_editor]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_footer|wp_footer]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_cookie_login|wp_get_cookie_login]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/wp_get_image_editor|wp_get_image_editor]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_get_installed_translations|wp_get_installed_translations]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_hash|wp_hash]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_handle_sideload|wp_handle_sideload]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_head|wp_head]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_install_defaults|wp_install_defaults]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_is_mobile|wp_is_mobile]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_mail|wp_mail]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_mkdir_p|wp_mkdir_p]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_new_user_notification|wp_new_user_notification]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_password_change_notification|wp_password_change_notification]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_notify_moderator|wp_notify_moderator]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_notify_postauthor|wp_notify_postauthor]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_parse_args|wp_parse_args]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_redirect|wp_redirect]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_reset_postdata|wp_reset_postdata]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_reset_query|wp_reset_query]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_salt|wp_salt]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_set_auth_cookie|wp_set_auth_cookie]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_safe_redirect|wp_safe_redirect]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_upload_bits|wp_upload_bits]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_upload_dir|wp_upload_dir]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_list_pluck|wp_list_pluck]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_text_diff|wp_text_diff]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/post_submit_meta_box|post_submit_meta_box]]&lt;/tt&gt;
|}
| width=&quot;50%&quot; |
{| class=&quot;widefat&quot;
|- style=&quot;background:#464646;&quot;
!
=== &lt;span style=&quot;color:#d7d7d7;&quot;&gt;Multisite functions&lt;/span&gt; ===
|-
|
As of v3.0, WordPress includes WPMU functionality. Old WPMU functions reference can be found at http://codex.wordpress.org/WPMU_Functions (deprecated page).
'''Multisite administration Functions '''
* &lt;tt&gt;[[Function Reference/confirm_delete_users|confirm_delete_users]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_user_member_of_blog|is_user_member_of_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wp_dashboard_quota|wp_dashboard_quota]]&lt;/tt&gt;
These functions are found in file wp-admin/includes/ms.php (since 3.0.0).
* &lt;tt&gt;[[Function Reference/admin_notice_feed|admin_notice_feed]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/avoid_blog_page_permalink_collision|avoid_blog_page_permalink_collision]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/check_import_new_users|check_import_new_users]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/check_upload_size|check_upload_size]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/choose_primary_blog|choose_primary_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/display_space_usage|display_space_usage]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/fix_import_form_size|fix_import_form_size]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/format_code_lang|format_code_lang]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_site_allowed_themes|get_site_allowed_themes]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/grant_super_admin|grant_super_admin]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/ms_deprecated_blogs_file|ms_deprecated_blogs_file]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/mu_dropdown_languages|mu_dropdown_languages]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/new_user_email_admin_notice|new_user_email_admin_notice]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/redirect_user_to_blog|redirect_user_to_blog]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/refresh_user_details|refresh_user_details]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/revoke_super_admin|revoke_super_admin]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/secret_salt_warning|secret_salt_warning]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/send_confirmation_on_profile_email|send_confirmation_on_profile_email]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/show_post_thumbnail_warning|show_post_thumbnail_warning]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/site_admin_notice|site_admin_notice]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/sync_category_tag_slugs|sync_category_tag_slugs]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_option_new_admin_email|update_option_new_admin_email]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_user_status|update_user_status]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/upload_is_user_over_quota|upload_is_user_over_quote]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/upload_space_setting|upload_space_setting]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_delete_blog|wpmu_delete_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_delete_user|wpmu_delete_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_get_blog_allowedthemes|wpmu_get_blog_allowedthemes]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/_admin_notice_multisite_activate_plugins_page|_admin_notice_multisite_activate_plugins_page]]&lt;/tt&gt; (deprecated)
'''Multisite Functions '''
Site/blog functions that work with the blogs table and related data, found in file wp-includes/ms-blogs.php (since 3.0.0).
* &lt;tt&gt;[[Function Reference/add_blog_option|add_blog_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/delete_blog_option|delete_blog_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_blogaddress_by_domain|get_blogaddress_by_domain]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_blogaddress_by_id|get_blogaddress_by_id]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_blogaddress_by_name|get_blogaddress_by_name]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_blog_details|get_blog_details]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_blog_option|get_blog_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_blog_status|get_blog_status]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_id_from_blogname|get_id_from_blogname]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_last_updated|get_last_updated]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_archived|is_archived]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/refresh_blog_details|refresh_blog_details]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/restore_current_blog|restore_current_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/switch_to_blog|switch_to_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_archived|update_archived]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_blog_details|update_blog_details]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_blog_option|update_blog_option]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_blog_status|update_blog_status]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_update_blogs_date|wpmu_update_blogs_date]]&lt;/tt&gt;
Defines constants and global variables that can be overridden, generally in wp-config.php, found in file wp-includes/ms-default-constants.php (since 3.0.0).
* &lt;tt&gt;[[Function Reference/ms_cookie_constants|ms_cookie_constants]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/ms_file_constants|ms_file_constants]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/ms_subdomain_constants|ms_subdomain_constants]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/ms_upload_constants|ms_upload_constants]]&lt;/tt&gt;
Multisite WordPress API, found in file wp-includes/ms-functions.php (since 3.0.0).
* &lt;tt&gt;[[Function Reference/add_existing_user_to_blog|add_existing_user_to_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_new_user_to_blog|add_new_user_to_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/add_user_to_blog|add_user_to_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/check_upload_mimes|check_upload_mimes]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/create_empty_blog|create_empty_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/domain_exists|domain_exists]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/filter_SSL|filter_SSL]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/fix_phpmailer_messageid|fix_phpmailer_messageid]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/force_ssl_content|force_ssl_content]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_active_blog_for_user|get_active_blog_for_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_admin_users_for_domain|get_admin_users_for_domain]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_blogs_of_user|get_blogs_of_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_blog_count|get_blog_count]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_blog_id_from_url|get_blog_id_from_url]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_blog_permalink|get_blog_permalink]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_blog_post|get_blog_post]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_current_site|get_current_site]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_dashboard_blog|get_dashboard_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_dirsize|get_dirsize]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_most_recent_post_of_user|get_most_recent_post_of_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_sitestats|get_sitestats]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_space_allowed|get_space_allowed]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_space_used|get_space_used]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_upload_space_available|get_upload_space_available]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_user_count|get_user_count]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/get_user_id_from_string|get_user_id_from_string]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/global_terms|global_terms]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/insert_blog|insert_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/install_blog|install_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/install_blog_defaults|install_blog_defaults]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_blog_user|is_blog_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_email_address_unsafe|is_email_address_unsafe]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_upload_space_available|is_upload_space_available]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_user_option_local|is_user_option_local]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_user_spammy|is_user_spammy]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/maybe_add_existing_user_to_blog|maybe_add_existing_user_to_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/maybe_redirect_404|maybe_redirect_404]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/newblog_notify_siteadmin|newblog_notify_siteadmin]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/newuser_notify_siteadmin|newuser_notify_siteadmin]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/recurse_dirsize|recurse_dirsize]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/redirect_mu_dashboard|redirect_mu_dashboard]]&lt;/tt&gt; (not a function??)
* &lt;tt&gt;[[Function Reference/redirect_this_site|redirect_this_site]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/remove_user_from_blog|remove_user_from_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/signup_nonce_check|signup_nonce_check]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/signup_nonce_fields|signup_nonce_fields]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_blog_public|update_blog_public]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/update_posts_count|update_posts_count]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/upload_is_file_too_big|upload_is_file_too_big]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/upload_is_user_over_quota|upload_is_user_over_quota]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/upload_size_limit_filter|upload_size_limit_filter]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/users_can_register_signup_filter|users_can_register_signup_filter]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/welcome_user_msg_filter|welcome_user_msg_filter]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wordpressmu_wp_mail_from|wordpressmu_wp_mail_from]]&lt;/tt&gt; (not a function??)
* &lt;tt&gt;[[Function Reference/wp_get_sites|wp_get_sites]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_activate_signup|wpmu_activate_signup]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_admin_redirect_add_updated_param|wpmu_admin_redirect_add_updated_param]]&lt;/tt&gt; (deprecated)
* &lt;tt&gt;[[Function Reference/wpmu_create_blog|wpmu_create_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_create_user|wpmu_create_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_log_new_registrations|wpmu_log_new_registrations]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_signup_blog|wpmu_signup_blog]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_signup_blog_notification|wpmu_signup_blog_notification]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_signup_user|wpmu_signup_user]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_signup_user_notification|wpmu_signup_user_notification]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_validate_blog_signup|wpmu_validate_blog_signup]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_validate_user_signup|wpmu_validate_user_signup]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_welcome_notification|wpmu_welcome_notification]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_welcome_user_notification|wpmu_welcome_user_notification]]&lt;/tt&gt;
These functions are needed to load Multisite, found in file wp-includes/ms-load.php (since 3.0.0).
* &lt;tt&gt;[[Function Reference/get_current_site_name|get_current_site_name]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/is_subdomain_install|is_subdomain_install]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/ms_not_installed|ms_not_installed]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/ms_site_check|ms_site_check]]&lt;/tt&gt;
* &lt;tt&gt;[[Function Reference/wpmu_current_site|wpmu_current_site]]&lt;/tt&gt;
|}
|}
== Official and Unofficial References ==
* [http://core.trac.wordpress.org/browser Trac Browser] - WordPress source code. Choose 'Tags' to find a specific version source code, or 'Trunk' to see the latest version source code.
* [http://phpxref.com/xref/wordpress/ PHPXref for WordPress] - Cross reference of WordPress files, functions, and variables, which seems to point to the latest released version.
* [http://planetozh.com/projects/wordpress-functions-history/table_light.html WordPress Function History Table] - List each WordPress function with including the version it was introduced in or dropped in. PlanetOzh [http://planetozh.com/blog/my-projects/wordpress-functions-implementation-history-tool/ recommends]: &quot;''see related [http://planetozh.com/blog/go.php?http://planetozh.com/projects/wordpress-functions-history/ WordPress Functions Implementation History Tool] for more information (and for a more usable tool)''&quot;
* [http://dd32.id.au/wp-2.4-variable-report.html WordPress Variable Report] - A list of WordPress functions, listing what version of PHP every function requires (and if there's a compatible function available), what varables/arguments in functions are unused, and what functions/variables each class contains (and their default values).
* [http://adambrown.info/p/wp_hooks WordPress Hooks Table] - A list of WordPress actions and filters, cross-referenced to the files they are in
[[Category:Advanced Topics]]
[[Category:Functions|*]]
[[Category:WordPress Development]]</p>
</d:entry>
<d:entry id="wp_update_post" d:title="wp update post">
<d:index d:value="wp update post"/>
<h1>wp update post</h1>
<p>{{Languages|
{{en|Function_Reference/wp_update_post}}
{{ja|関数リファレンス/wp update post}}
{{tr|Fonksiyon Listesi/wp update post}}
}}
==Description==
This function updates posts (and pages) in the database. To work as expected, it is necessary to pass the ID of the post to be updated.
Note that when the post is &quot;updated&quot;, the existing Post record is duplicated for audit/revision purposes. The primary record is then updated with the new values. Category associations, custom fields, post meta, and other related entries continue to be linked to the primary Post record.
==Usage==
%%% &lt;?php wp_update_post( $post ); ?&gt; %%%
==Parameters==
{{Parameter|$post|array/object|An array or object representing the elements that make up a post. There is a one-to-one relationship between these elements and the names of columns in the &lt;tt&gt;[[Database_Description#Table:_wp_posts | wp_posts]]&lt;/tt&gt; table in the database. Filling out the ID field is not strictly necessary but without it there is little point to using the function.|optional|An empty array}}
{{Parameter|$wp_error|Boolean|A Boolean that can be passed to control what is returned on failure. The default setting (&lt;tt&gt;false&lt;/tt&gt;) will return a &lt;tt&gt;0&lt;/tt&gt; if the post fails to update. However, if this is set to &lt;tt&gt;true&lt;/tt&gt;, it will return with a &lt;tt&gt;[[Class_Reference/WP_Error | WP_Error]]&lt;/tt&gt; object.|optional|&lt;tt&gt;false&lt;/tt&gt;}}
==Example==
Before calling &lt;tt&gt;wp_update_post()&lt;/tt&gt; it is necessary to create an array to pass the necessary elements. Unlike &lt;tt&gt;[[Function Reference/wp insert post|wp_insert_post()]]&lt;/tt&gt;, it is only necessary to pass the ID of the post to be updated and the elements to be updated. The names of the elements should match those in the database.
&lt;pre&gt;
// Update post 37
$my_post = array(
'ID' =&gt; 37,
'post_content' =&gt; 'This is the updated content.'
);
// Update the post into the database
wp_update_post( $my_post );
&lt;/pre&gt;
===Categories===
Categories need to be passed as an array of integers that match the category IDs in the database. This is the case even where only one category is assigned to the post.
===Caution!===
When executed by an action hooked into &lt;tt&gt;save_post&lt;/tt&gt; (e.g. a custom metabox), &lt;tt&gt;wp_update_post()&lt;/tt&gt; has the potential to create an infinite loop. This happens because (1) &lt;tt&gt;wp_update_post()&lt;/tt&gt; results in &lt;tt&gt;save_post&lt;/tt&gt; being fired and (2) &lt;tt&gt;save_post&lt;/tt&gt; is called twice when revisions are enabled (first when creating the revision, then when updating the original post&amp;mdash;resulting in the creation of endless revisions).
If you must update a post from code called by &lt;tt&gt;save_post&lt;/tt&gt;, make sure to verify the &lt;tt&gt;post_type&lt;/tt&gt; is not set to &lt;tt&gt;'revision'&lt;/tt&gt; and that the &lt;tt&gt;$post&lt;/tt&gt; object does indeed need to be updated.
Likewise, an action hooked into &lt;tt&gt;edit_attachment&lt;/tt&gt; can cause an infinite loop if it contains a function call to &lt;tt&gt;wp_update_post&lt;/tt&gt; passing an array parameter with a key value of &lt;tt&gt;&quot;ID&quot;&lt;/tt&gt; and an associated value that corresponds to an Attachment.
Note you will need to remove then add the hook, code sample modified from the API/Action reference: &lt;tt&gt;[[Plugin_API/Action_Reference/save_post | save_post]]&lt;/tt&gt;
&lt;pre&gt;
&lt;?php
function my_function( $post_id ){
if ( ! wp_is_post_revision( $post_id ) ){
// unhook this function so it doesn't loop infinitely
remove_action('save_post', 'my_function');
// update the post, which calls save_post again
wp_update_post( $my_args );
// re-hook this function
add_action('save_post', 'my_function');
}
}
add_action('save_post', 'my_function');
?&gt;
&lt;/pre&gt;
===Scheduling posts===
If you are trying to use &lt;tt&gt;wp_update_post()&lt;/tt&gt; to schedule an existing draft, it will not work unless you pass &lt;tt&gt;$my_post-&gt;edit_date = true&lt;/tt&gt;. WordPress will ignore the &lt;tt&gt;post_date&lt;/tt&gt; when updating drafts unless &lt;tt&gt;edit_date&lt;/tt&gt; is true.
==Return==
{{Return||integer|The ID of the post if the post is successfully updated in the database. Otherwise returns &lt;tt&gt;0&lt;/tt&gt;}}.
==Change Log==
* Since: [[Version 1.0|1.0.0]]
== Source File ==
&lt;tt&gt;wp_update_post()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
==Related==
[[Function Reference/wp insert post|wp_insert_post()]]
{{Tag Footer}}
{{Copyedit}}
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="get_bookmark" d:title="get bookmark">
<d:index d:value="get bookmark"/>
<h1>get bookmark</h1>
<p>{{Languages|
{{en|Function Reference/get bookmark}}
{{ja|Function Reference/get bookmark}}
}}
== Description ==
Retrieve Bookmark data based on bookmark link ID.
== Usage ==
%%%&lt;?php get_bookmark( $bookmark, $output, $filter ) ?&gt;%%%
== Parameters ==
{{Parameter|$bookmark|integer&amp;#124;object|Bookmark link ID or Bookmark object.}}
{{Parameter|$output|string|Either OBJECT, ARRAY_N, or ARRAY_A constant|optional|OBJECT}}
{{Parameter|$filter|string|default is '&lt;tt&gt;raw&lt;/tt&gt;'.|optional|'raw'}}
== Return Values ==
; (array&amp;#124;object) : Type returned depends on &lt;tt&gt;$output&lt;/tt&gt; value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
=== Display Bookmark Name ===
&lt;pre&gt;&lt;?php
$bookmark = get_bookmark(5);
echo $bookmark-&gt;link_name;
?&gt;
&lt;/pre&gt;
or:
&lt;?php echo get_bookmark(5)-&gt;link_name; ?&gt;
=== Display Bookmark as a Link ===
&lt;pre&gt;&lt;?php
$bookmark = get_bookmark(5);
echo '&lt;a href=&quot;'.$bookmark-&gt;link_url.'&quot;&gt;'.$bookmark-&gt;link_name.'&lt;/a&gt;';
?&gt;&lt;/pre&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] Database Object
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_bookmark()&lt;/tt&gt; is located in {{Trac|wp-includes/bookmark.php}}.
== Related ==
{{Bookmark Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_children" d:title="get children">
<d:index d:value="get children"/>
<h1>get children</h1>
<p>{{Languages|
{{en|Function Reference/get children}}
{{it|Riferimento funzioni/get children}}
{{ja|関数リファレンス/get children}}
{{pt-br|Refer&ecirc;ncia de Fun&ccedil;&atilde;o/get children}}
{{ru|Справочник по функциям/get children}}
}}
== Description ==
get_children() retrieves attachments, revisions, or sub-pages, possibly by post parent. It works similar to [[Function Reference/get posts|get_posts()]].
== Usage ==
%%% &lt;?php $children_array = get_children( $args, $output ); ?&gt; %%%
===Default Usage===
&lt;pre&gt;
&lt;?php $args = array(
'post_parent' =&gt; 0,
'post_type' =&gt; 'any',
'posts_per_page' =&gt; -1,
'post_status' =&gt; 'any' ); ?&gt;
&lt;/pre&gt;
== Parameters ==
As of [[Version 2.6]], you must pass a non-empty &lt;tt&gt;post_type&lt;/tt&gt; parameter (either &lt;tt&gt;attachment&lt;/tt&gt; or &lt;tt&gt;page&lt;/tt&gt;).
The following options are available in the &lt;tt&gt;$args&lt;/tt&gt; array:
{{Parameter|'numberposts'|integer|Number of child posts to retrieve.|optional|'-1'}}
{{Parameter|'post_parent'|integer|Pass the ID of a post or Page to get its children. Pass 0 to get attachments without parent. Pass &lt;tt&gt;null&lt;/tt&gt; to get any child regardless of parent.|optional|'0'}}
{{Parameter|'post_type'|string|Any value from post_type column of the posts table, such as &lt;tt&gt;attachment&lt;/tt&gt;, &lt;tt&gt;page&lt;/tt&gt;, or &lt;tt&gt;revision&lt;/tt&gt;; or the keyword &lt;tt&gt;any&lt;/tt&gt;.|optional|'0'}}
{{Parameter|'post_status'|string|Any value from the &lt;tt&gt;post_status&lt;/tt&gt; column of the wp_posts table, such as &lt;tt&gt;publish&lt;/tt&gt;, &lt;tt&gt;draft&lt;/tt&gt;, or &lt;tt&gt;inherit&lt;/tt&gt;; or the keyword &lt;tt&gt;any&lt;/tt&gt;.|optional|'any'}}
{{Parameter|'post_mime_type'|string|A full or partial mime-type, e.g. &lt;tt&gt;image&lt;/tt&gt;, &lt;tt&gt;video&lt;/tt&gt;, &lt;tt&gt;video/mp4&lt;/tt&gt;, which is matched against a post's &lt;tt&gt;post_mime_type&lt;/tt&gt; field.|optional}}
'''Note: ''' See [[Template Tags/get posts|get_posts()]] for a full list of $args parameters.
{{Parameter|'output'|constant|Variable type of the array items returned by the function: one of &lt;tt&gt;OBJECT&lt;/tt&gt;, &lt;tt&gt;ARRAY_A&lt;/tt&gt;, &lt;tt&gt;ARRAY_N&lt;/tt&gt;.|optional|OBJECT}}
== Return Values ==
; (array) : Associative array of posts (of variable type set by &lt;tt&gt;$output&lt;/tt&gt; parameter) with post IDs as array keys, or an empty array if no posts are found.
'''Note: ''' Prior to [[Version 2.9]], the return value would be &lt;tt&gt;false&lt;/tt&gt; when no children found.
== Examples ==
If you just want to get or display attachments, it's probably a little easier to use &lt;code&gt;[[Template_Tags/get_posts#Show_attachments_for_the_current_post|get_posts()]]&lt;/code&gt; instead.
&lt;pre&gt;$images =&amp; get_children( 'post_type=attachment&amp;post_mime_type=image' );
$videos =&amp; get_children( 'post_type=attachment&amp;post_mime_type=video/mp4' );
if ( empty($images) ) {
// no attachments here
} else {
foreach ( $images as $attachment_id =&gt; $attachment ) {
echo wp_get_attachment_image( $attachment_id, 'full' );
}
}
// If you don't need to handle an empty result:
foreach ( (array) $videos as $attachment_id =&gt; $attachment ) {
echo wp_get_attachment_link( $attachment_id );
}&lt;/pre&gt;
=== Show the first image associated with the post ===
This function retrieves the first image associated with a post
&lt;pre&gt;
&lt;?php
function echo_first_image( $postID ) {
$args = array(
'numberposts' =&gt; 1,
'order' =&gt; 'ASC',
'post_mime_type' =&gt; 'image',
'post_parent' =&gt; $postID,
'post_status' =&gt; null,
'post_type' =&gt; 'attachment',
);
$attachments = get_children( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
$image_attributes = wp_get_attachment_image_src( $attachment-&gt;ID, 'thumbnail' ) ? wp_get_attachment_image_src( $attachment-&gt;ID, 'thumbnail' ) : wp_get_attachment_image_src( $attachment-&gt;ID, 'full' );
echo '&lt;img src=&quot;' . wp_get_attachment_thumb_url( $attachment-&gt;ID ) . '&quot; class=&quot;current&quot;&gt;';
}
}
}
&lt;/pre&gt;
=== Show the first image associated with the post and re-key the array ===
In the example above, a primary array is keyed with the image ID (the exact thing which is being sought - since we don't know it how are we supposed to access it?). The code below provides an easier handle for the image information: the array $child_image. Should be used in the loop.
&lt;pre&gt;
$args = array(
'numberposts' =&gt; 1,
'order'=&gt; 'DESC',
'post_mime_type' =&gt; 'image',
'post_parent' =&gt; $post-&gt;ID,
'post_type' =&gt; 'attachment'
);
$get_children_array = get_children($args,ARRAY_A); //returns Array ( [$image_ID]...
$rekeyed_array = array_values($get_children_array);
$child_image = $rekeyed_array[0];
print_r($child_image); //Show the contents of the $child_image array.
echo $child_image['ID']; //Show the $child_image ID.
&lt;/pre&gt;
== Change Log ==
Since: 2.0.0
==Source File==
&lt;tt&gt;get_children()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
get_children() calls [[Template Tags/get posts|get_posts()]], which calls [[Class Reference/WP Query#Methods|$WP_Query-&gt;get_posts()]].
[[Template Tags/wp get attachment link|wp_get_attachment_link()]],
[[Function_Reference/get_page_children|get_page_children()]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:Attachments]]</p>
</d:entry>
<d:entry id="wp_remote_fopen" d:title="wp remote fopen">
<d:index d:value="wp remote fopen"/>
<h1>wp remote fopen</h1>
<p>== Description ==
Returns the contents of a remote URI. Tries to retrieve the HTTP content with fopen first and then using cURL, if fopen can't be used.
== Usage ==
%%% &lt;?php $contents = wp_remote_fopen($uri); ?&gt; %%%
== Parameters ==
{{Parameter|$uri|string|The URI of the remote page to be retrieved.}}
== Return Values ==
{{Return||bool&amp;#124;string|HTTP content. False on failure.}}
== Examples ==
== Notes ==
See http://codex.wordpress.org/HTTP_API
== Change Log ==
Since: [[Version 1.5.1|1.5.1]]
== Source File ==
wp_remote_fopen() is located in {{Trac|wp-includes/functions.php}}
== Related ==
&amp;nbsp;
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_delete_post" d:title="wp delete post">
<d:index d:value="wp delete post"/>
<h1>wp delete post</h1>
<p>{{Languages|
{{en|Function_Reference/wp_delete_post}}
{{ru|Справочник по функциям/wp delete post}}
{{ja|関数リファレンス/wp delete post}}
{{tr|wp_delete_post}}
}}
== Description ==
Removes or trashes a post, attachment, or page.
When the post and page goes, everything that is tied to it is deleted also. This includes comments, post meta fields, and relationships between the post and taxonomy terms.
== Usage ==
%%% &lt;?php wp_delete_post( $postid, $force_delete ); ?&gt;%%%
== Parameters ==
{{Parameter|$postid|integer|Post ID.|optional|0}}
{{Parameter|$force_delete|bool|Whether to bypass trash and force deletion (added in WordPress 2.9).|optional|false}}
== Return Values ==
; (mixed) : The post object (if it was deleted or moved to the trash successfully) or false (failure). If the post was moved to to the trash, $post represents its new state; if it was deleted, $post represents its state before deletion.
== Examples ==
=== Delete Post ===
Deleting WP default post &quot;Hello World&quot; which ID is '1'.
%%% &lt;?php wp_delete_post(1); ?&gt; %%%
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* wp_delete_post() automatically reverts to [[Function_Reference/wp_trash_post|&lt;tt&gt;wp_trash_post()&lt;/tt&gt;]] if &lt;tt&gt;$force_delete&lt;/tt&gt; is ''false'', the &lt;tt&gt;post_type&lt;/tt&gt; of &lt;tt&gt;$postid&lt;/tt&gt; is ''page'' or ''post'', &lt;tt&gt;$postid&lt;/tt&gt; is not already in the trash '''and''' if [[Editing_wp-config.php#Empty_Trash|that trash feature]] enabled (which it it is by default).
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] on '&lt;tt&gt;delete_post&lt;/tt&gt;' before deletion unless post type is '&lt;tt&gt;attachment&lt;/tt&gt;'.
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] on '&lt;tt&gt;deleted_post&lt;/tt&gt;' after deletion unless &lt;tt&gt;post type&lt;/tt&gt; is ''attachment''.
* Uses: [[Function_Reference/wp_delete_attachment|&lt;tt&gt;wp_delete_attachment()&lt;/tt&gt;]] if &lt;tt&gt;post type&lt;/tt&gt; is ''attachment''.
* Uses global &lt;tt&gt;$wpdb&lt;/tt&gt;: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|wpdb]]
* Uses global &lt;tt&gt;$wp_rewrite&lt;/tt&gt;: (&lt;tt&gt;object&lt;/tt&gt;) [[Function_Reference/WP_Rewrite|WP_Rewrite]]
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_delete_post()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
[[Function_Reference/#Post.2C_Page.2C_Attachment_and_Bookmarks_Functions|'''Post, Page, Attachment and Bookmarks Functions''']]: [[Function_Reference/wp_trash_post|wp_trash_post()]], [[Function Reference/wp update post|wp_update_post()]], [[Function Reference/wp delete attachment|wp_delete_attachment()]], [[Function Reference/wp insert attachment|wp_insert_attachment()]], [[Function Reference/wp insert post|wp_insert_post()]]
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_pages" d:title="get pages">
<d:index d:value="get pages"/>
<h1>get pages</h1>
<p>{{Languages|
{{en|Function Reference/get pages}}
{{ja| 関数リファレンス/get pages}}
}}
==Description==
This function returns an array of pages that are in the blog, optionally constrained by parameters. This array is not tree-like (hierarchical). See the [[Template_Tags/wp_list_pages|wp_list_pages()]] [[Template_Tags|template tag]] for the output of page titles in a tree-like fashion.
This function can also retrieve other post types using the 'post_type' parameter, but the type must be hierarchical like pages, or the function will return false.
Note that, although similar to [[Function_Reference/get_posts|get_posts()]], several of the parameter names and values differ. (It is implemented quite differently, see get_posts().)
==Usage==
%%% &lt;?php get_pages( $args ); ?&gt; %%%
===Default Usage===
&lt;pre&gt;
&lt;?php $args = array(
'sort_order' =&gt; 'ASC',
'sort_column' =&gt; 'post_title',
'hierarchical' =&gt; 1,
'exclude' =&gt; '',
'include' =&gt; '',
'meta_key' =&gt; '',
'meta_value' =&gt; '',
'authors' =&gt; '',
'child_of' =&gt; 0,
'parent' =&gt; -1,
'exclude_tree' =&gt; '',
'number' =&gt; '',
'offset' =&gt; 0,
'post_type' =&gt; 'page',
'post_status' =&gt; 'publish'
);
$pages = get_pages($args);
?&gt;
&lt;/pre&gt;
==Parameters==
; sort_column : (''string'') Sorts the list of Pages in a number of different ways. The default setting is ''sort alphabetically by Page title''.
:* &lt;tt&gt;'post_title'&lt;/tt&gt; - Sort Pages alphabetically (by title) - default
:* &lt;tt&gt;'menu_order'&lt;/tt&gt; - Sort Pages by Page Order. ''N.B.'' Note the difference between ''Page Order'' and ''Page ID''. The Page ID is a unique number assigned by WordPress to every post or page. The Page Order can be set by the user in the [[Write_Page_SubPanel|Write&gt;Pages]] administrative panel.
:* &lt;tt&gt;'post_date'&lt;/tt&gt; - Sort by creation time.
:* &lt;tt&gt;'post_modified'&lt;/tt&gt; - Sort by time last modified.
:* &lt;tt&gt;'ID'&lt;/tt&gt; - Sort by numeric Page ID.
:* &lt;tt&gt;'post_author'&lt;/tt&gt; - Sort by the Page author's numeric ID.
:* &lt;tt&gt;'post_name'&lt;/tt&gt; - Sort alphabetically by Post [[Glossary#Slug|slug]]. Not supported yet, as of WP 3.3 (See: http://core.trac.wordpress.org/ticket/14368 )
:'''Note:''' The '''sort_column''' parameter can be used to sort the list of Pages by the descriptor of any field in the [[Database Description#Table:_wp_posts|wp_post table]] of the WordPress database. Some useful examples are listed here.
:'''Note:''' get_posts() uses the parameter &lt;tt&gt;'orderby'&lt;/tt&gt; instead of &lt;tt&gt;'sort_column'&lt;/tt&gt;. Also, get_posts() automatically prepends &lt;tt&gt;'post_'&lt;/tt&gt; to these values: &lt;tt&gt;'author, date, modified, parent, title, excerpt, content'&lt;/tt&gt;.
; sort_order : (''string'') Change the sort order of the list of Pages (either ascending or descending). The default is ''ascending''. Valid values:
:* &lt;tt&gt;'asc'&lt;/tt&gt; - Sort from lowest to highest (Default).
:* &lt;tt&gt;'desc'&lt;/tt&gt; - Sort from highest to lowest.
:'''Note:''' get_posts() uses the parameter &lt;tt&gt;'order'&lt;/tt&gt; instead of &lt;tt&gt;'sort_order'&lt;/tt&gt;.
; exclude : (''string or array'') Define a comma-separated list of Page IDs to be excluded from the list (example: &lt;tt&gt;'exclude=3,7,31'&lt;/tt&gt;). Beginning with [[Version 3.0]], an array of Page ID also can be used. There is no default value.
; include : (''string or array'') Only include certain Pages in the list generated by ''get_pages''. Like '''exclude''', this parameter takes a comma-separated list of Page IDs. Beginning with [[Version 3.0]], an array of Page ID also can be used. There is no default value.
:'''Note:''' If this parameter is provided, child_of, parent, exclude, meta_key, and meta_value params are ignored, and hierarchical is set to false.
; child_of : (''integer'') Lists the sub-pages of a single Page only; uses the ID for a Page as the value. Defaults to ''0'' (list all Pages). Note that the child_of parameter will also fetch &quot;grandchildren&quot; of the given ID, not just direct descendants.
:* &lt;tt&gt;0&lt;/tt&gt; - default, no child_of restriction
:'''Note:''' The &lt;tt&gt;child_of&lt;/tt&gt; parameter is not applied to the SQL query for pages. It is applied to the results of the query. If a number parameter is also provided, the final results may be less than the number specified.
; parent : (''integer'') List those pages that have the provided single page only ID as parent. Defaults to -1 (displays all Pages regardless of parent). Note that the 'hierarchical' parameter must be set to 0 (false) -- which is not default -- or else no results will be returned for any page other than the top level pages with no parent (ID=0) and the default all pages (ID=-1). In contrast to the 'child_of' parameter, this parameter only returns the direct descendants of the parent, no 'grandchildren'. You can obviate the 'hierarchical' set to 0 requirement by passing a 'child_of' parameter set to the same (parent) ID value.
:* &lt;tt&gt;-1&lt;/tt&gt; - default, no parent restriction
:* &lt;tt&gt;0&lt;/tt&gt; - returns all top level pages
; exclude_tree : (''integer'') The opposite of 'child_of', 'exclude_tree' will remove all children of a given ID from the results. Useful for hiding all children of a given page. Can also be used to hide grandchildren in conjunction with a 'child_of' value. This parameter was available at [[Version 2.7]].
; hierarchical : (''boolean'') Lists sub-Pages below their parent or lists the Pages inline. The default is ''true'' (list sub-Pages below the parent list item). NOTE: This default value will prevent meta_key &amp; parent page searches from finding sub-pages. You need to set 'hierarchical' =&gt; 0 for these parameters to work properly. Valid values:
:* &lt;tt&gt;1 (true)&lt;/tt&gt; - default
:* &lt;tt&gt;0 (false)&lt;/tt&gt;
; meta_key : (''string'') Only include the Pages that have this Custom Field Key (use in conjunction with the meta_value field).
; meta_value : (''string'') Only include the Pages that have this Custom Field Value (use in conjunction with the meta_key field).
; authors : (''string'') Only include the Pages written by the given author(s)
:'''Note:''' get_posts() uses the parameter &lt;tt&gt;'author'&lt;/tt&gt; instead of &lt;tt&gt;'authors'&lt;/tt&gt;.
; number : (''integer'') Sets the number of Pages to list. This causes the SQL LIMIT value to be defined. Default to no LIMIT. This parameter was added with [[Version 2.8]].
:'''Note:''' get_posts() uses the parameter &lt;tt&gt;'numberposts'&lt;/tt&gt; instead of &lt;tt&gt;'number'&lt;/tt&gt;.
; post_type : (&quot;string&quot;) Show posts associated with certain [[Post Types|type]]. Valid values include:
:* '&lt;tt&gt;post&lt;/tt&gt;' - a post.
:* '&lt;tt&gt;page&lt;/tt&gt;' - a page.
:* '&lt;tt&gt;revision&lt;/tt&gt;' - a revision.
:* '&lt;tt&gt;attachment&lt;/tt&gt;' - an attachment.
:* Custom Post Types.
; offset : (''integer'') The number of Pages to pass over (or displace) before collecting the set of Pages. Default is no OFFSET. This parameter was added with [[Version 2.8]].
; post_status : (''string'') A comma-separated list of post status types that should be included. For example, &lt;tt&gt;'publish,private'&lt;/tt&gt;.
==Return==
; (Array) : An array containing all the [[Pages]] matching the request, or &lt;tt&gt;false&lt;/tt&gt; on failure. The returned array is an array of &quot;page&quot; objects. Each page object is a map containing 24 keys:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ID&lt;/code&gt;: page/post ID (&lt;i&gt;int&lt;/i&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_author&lt;/code&gt;: author ID (&lt;i&gt;string&lt;/i&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_date&lt;/code&gt;: time-date string (&lt;tt&gt;YYYY-MM-DD HH:MM:SS&lt;/tt&gt;), e.g., &quot;2012-10-15 01:02:59&quot;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_date_gmt&lt;/code&gt;: time-date string&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_content&lt;/code&gt;: HTML (&lt;i&gt;string&lt;/i&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_title&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_excerpt&lt;/code&gt;: HTML (&lt;i&gt;string&lt;/i&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_status&lt;/code&gt;: (&lt;tt&gt;publish|inherit|pending|private|future|draft|trash&lt;/tt&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;comment_status&lt;/code&gt;: closed/open&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ping_status&lt;/code&gt;: (&lt;tt&gt;closed|open&lt;/tt&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_password&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_name&lt;/code&gt;: slug for page/post&lt;/li&gt;
&lt;li&gt;&lt;code&gt;to_ping&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;pinged&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_modified&lt;/code&gt;: time-date string&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_modified_gmt&lt;/code&gt;: time-date string&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_content_filtered&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_parent&lt;/code&gt;: parent ID (&lt;i&gt;int&lt;/i&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;guid&lt;/code&gt;: URL&lt;/li&gt;
&lt;li&gt;&lt;code&gt;menu_order&lt;/code&gt;: (&lt;i&gt;int&lt;/i&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_type&lt;/code&gt;: (&lt;tt&gt;page|post|attachment&lt;/tt&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;post_mime_type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;comment_count&lt;/code&gt;: number of comments (&lt;i&gt;string&lt;/i&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;filter&lt;/code&gt;
&lt;/ul&gt;
All values are strings unless otherwise shown as (&lt;i&gt;int&lt;/i&gt;).
==Example==
=== Displaying pages in dropdown list ===
In this example a dropdown list with all the pages. Note how you can grab the link for the page with a simple call to the function get_page_link passing the ID of the page.
&lt;pre&gt;
&lt;select name=&quot;page-dropdown&quot;
onchange='document.location.href=this.options[this.selectedIndex].value;'&gt;
&lt;option value=&quot;&quot;&gt;
&lt;?php echo esc_attr( __( 'Select page' ) ); ?&gt;&lt;/option&gt;
&lt;?php
$pages = get_pages();
foreach ( $pages as $page ) {
$option = '&lt;option value=&quot;' . get_page_link( $page-&gt;ID ) . '&quot;&gt;';
$option .= $page-&gt;post_title;
$option .= '&lt;/option&gt;';
echo $option;
}
?&gt;
&lt;/select&gt;
&lt;/pre&gt;
=== Displaying Child pages of the current page in post format ===
&lt;pre&gt;
&lt;?php
$mypages = get_pages( array( 'child_of' =&gt; $post-&gt;ID, 'sort_column' =&gt; 'post_date', 'sort_order' =&gt; 'desc' ) );
foreach( $mypages as $page ) {
$content = $page-&gt;post_content;
if ( ! $content ) // Check for empty page
continue;
$content = apply_filters( 'the_content', $content );
?&gt;
&lt;h2&gt;&lt;a href=&quot;&lt;?php echo get_page_link( $page-&gt;ID ); ?&gt;&quot;&gt;&lt;?php echo $page-&gt;post_title; ?&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;entry&quot;&gt;&lt;?php echo $content; ?&gt;&lt;/div&gt;
&lt;?php
}
?&gt;
&lt;/pre&gt;
==Changelog==
* Since: 1.5.0
== Source File ==
&lt;tt&gt;get_pages()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Page Tags}}
{{Tag Footer}}
{{Copyedit}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_login" d:title="wp login">
<d:index d:value="wp login"/>
<h1>wp login</h1>
<p>{{Deprecated}}
==Description==
Checks a user's login information and logs them in if it checks out.
== Replace With ==
* [[Function_Reference/wp_signon|wp_signon()]]
==Usage==
%%% &lt;?php wp_login( $username, $password, $deprecated ); ?&gt; %%%
==Parameters==
; $username : (string) User's username
; $password : (string) User's password
; $deprecated : (string) Not used
==Return==
; (bool) : False on login failure, true on successful check
Use the global $error to get the reason why the login failed. If the username is blank, no error will be set, so assume blank username on that case.
Plugins extending this function should also provide the global $error and set what the error is, so that those checking the global for why there was a failure can utilize it later.
==Examples==
==Notes==
* See Also: [[Function_Reference/wp_logout|wp_logout()]]
==Change Log==
* Since: 1.2.2
* Deprecated: 2.5
* Replaced By: [[Function_Reference/wp_signon|wp_signon()]]
==Related==
{{Login Tags}}
{{Tag Footer}}
[[Category:Functions]]
{{Copyedit}}</p>
</d:entry>
<d:entry id="mysql2date" d:title="mysql2date">
<d:index d:value="mysql2date"/>
<h1>mysql2date</h1>
<p>==Description==
Converts given MySQL date string into a different format.
==Usage==
%%%&lt;?php $date = mysql2date( $format, $date, $translate ); ?&gt;%%%
== Parameters ==
{{Parameter|$format|string|The requested output format, should be either a [[Formatting_Date_and_Time|PHP date format]] string, e.g. 'U' for a Unix timestamp, or 'G' for a Unix timestamp assuming that &lt;tt&gt;$date&lt;/tt&gt; is GMT.|required}}
{{Parameter|$date|string|the input string, this cannot be the raw time-stamp, it has to be converted into the following format first: &lt;tt&gt;'Y-m-d H:i:s'&lt;/tt&gt; . This is the only way &lt;tt&gt;mysql2date()&lt;/tt&gt; will recognize your date.|required}}
{{Parameter|$translate|boolean|If true then the given date and format string will be passed to &lt;tt&gt;[[Function Reference/date_i18n|date_i18n()]]&lt;/tt&gt; for translation.|optional|true}}
== Return Values ==
{{Return||string&amp;#124;integer|Formatted date string, or Unix timestamp.}}
== Examples ==
Convert a MySQL date to a Unix timestamp:
echo mysql2date( 'U', '2012-02-23 06:12:45' ); // 1329977565
Convert a MySQL date to another date format:
echo mysql2date( 'l, F j, Y', '2012-02-23 06:12:45' ) // Thursday, February 23, 2012
== Notes ==
== Change Log ==
Since: [[Version 0.71|0.71]]
== Source File ==
&lt;tt&gt;mysql2date()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}
== Related ==
[[Formatting_Date_and_Time|Formatting Date and Time]]
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="register_sidebars" d:title="register sidebars">
<d:index d:value="register sidebars"/>
<h1>register sidebars</h1>
<p>{{Languages|
{{en|Function Reference/register_sidebars}}
{{ja|関数リファレンス/register_sidebars}}
}}
== Description ==
Creates multiple [[Sidebars]].
Registers one or more sidebars to be used in the current theme. Most themes have only one sidebar. For this reason, the number parameter is optional and defaults to one.
The args array parameter can contain a 'name' which will be prepended to the sidebar number if there is more than one sidebar. If no name is specified, 'Sidebar' is used.
== Usage ==
%%% &lt;?php register_sidebars( $number, $args ); ?&gt; %%%
===Default Usage===
&lt;pre&gt;
&lt;?php $args = array(
'name' =&gt; __('Sidebar %d'),
'id' =&gt; 'sidebar',
'description' =&gt; '',
'class' =&gt; '',
'before_widget' =&gt; '&lt;li id=&quot;%1$s&quot; class=&quot;widget %2$s&quot;&gt;',
'after_widget' =&gt; '&lt;/li&gt;',
'before_title' =&gt; '&lt;h2 class=&quot;widgettitle&quot;&gt;',
'after_title' =&gt; '&lt;/h2&gt;' ); ?&gt;
&lt;/pre&gt;
== Parameters ==
{{Parameter|number|integer|Number of sidebars to create.|optional|1}}
{{Parameter|args|string/array|Builds Sidebar based off of 'name' and 'id' values.|optional}}
:* &lt;tt&gt;name&lt;/tt&gt; - Sidebar name.
:* &lt;tt&gt;id&lt;/tt&gt; - Sidebar id. (Note: &quot;%d&quot; is added automatically to supplied 'id' value after the first; e.g., &quot;Sidebar&quot;, &quot;Sidebar-2&quot;, &quot;Sidebar-3&quot;, etc.)
:* &lt;tt&gt;description&lt;/tt&gt; - Text description of what/where the sidebar is. Shown on widget management screen. (Since 2.9) (default: empty)
:* &lt;tt&gt;class&lt;/tt&gt; - CSS class name to assign to the widget HTML (default: empty).
:* &lt;tt&gt;before_widget&lt;/tt&gt; - HTML to place before every widget.
:* &lt;tt&gt;after_widget&lt;/tt&gt; - HTML to place after every widget.
:* &lt;tt&gt;before_title&lt;/tt&gt; - HTML to place before every title.
:* &lt;tt&gt;after_title&lt;/tt&gt; - HTML to place after every title.
The optional &lt;code&gt;args&lt;/code&gt; parameter is an associative array that will be passed as a first argument to every active widget callback. (If a string is passed instead of an array, it will be passed through [http://php.net/manual/en/function.parse-str.php parse_str()] to generate an associative array.) The basic use for these arguments is to pass theme-specific HTML tags to wrap the widget and its title.
== Return Values ==
None.
== Example ==
This will register 1 sidebar named Sidebar:
&lt;pre&gt;register_sidebars();&lt;/pre&gt;
This will create 2 sidebars named &ldquo;Foobar 1&Prime; and &ldquo;Foobar 2&Prime;:
&lt;pre&gt;register_sidebars(2, array('name'=&gt;'Foobar %d'));&lt;/pre&gt;
This will create 2 sidebars with &amp;lt;h1&amp;gt; and &amp;lt;/h1&amp;gt; before and after the title:
&lt;pre&gt;register_sidebars(2, array('before_title'=&gt;'&lt;h1&gt;','after_title'=&gt;'&lt;/h1&gt;'));&lt;/pre&gt;
== Changelog ==
Since: [[Version 2.2|2.2.0]]
== Source File ==
&lt;tt&gt;register_sidebars()&lt;/tt&gt; is located in {{Trac|wp-includes/widgets.php}}.
== Related ==
{{Sidebar Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:Widgets]]</p>
</d:entry>
<d:entry id="dynamic_sidebar" d:title="dynamic sidebar">
<d:index d:value="dynamic sidebar"/>
<h1>dynamic sidebar</h1>
<p>{{Languages|
{{en|Function Reference/dynamic_sidebar}}
{{ru|Справочник по функциям/dynamic_sidebar}}
{{ja|関数リファレンス/dynamic_sidebar}}
}}
== Description ==
This function calls each of the active widget callbacks in order, which prints the markup for the [[Sidebars|sidebar]]. If you have more than one sidebar, you should give this function the name or number of the sidebar you want to print. This function returns true on success and false on failure.
The return value should be used to determine whether to display a static sidebar. This ensures that your theme will look good even when the Widgets plug-in is not active.
If your sidebars were registered by number, they should be retrieved by number. If they had names when you registered them, use their names to retrieve them.
== Usage ==
%%% &lt;?php dynamic_sidebar( $index ); ?&gt; %%%
== Parameters ==
{{Parameter|index|integer/string|Name or ID of dynamic sidebar.|optional|1}}
== Return Value ==
; (boolean) : True, if widget sidebar was found and called. False if not found or not called.
==Examples==
Here is the recommended use of this function:
&lt;pre&gt;
&lt;ul id=&quot;sidebar&quot;&gt;
&lt;?php if ( ! dynamic_sidebar() ) : ?&gt;
&lt;li&gt;{static sidebar item 1}&lt;/li&gt;
&lt;li&gt;{static sidebar item 2}&lt;/li&gt;
&lt;?php endif; ?&gt;
&lt;/ul&gt;
&lt;/pre&gt;
&lt;pre&gt;
&lt;ul id=&quot;sidebar&quot;&gt;
&lt;?php dynamic_sidebar( 'right-sidebar' ); ?&gt;
&lt;/ul&gt;
&lt;/pre&gt;
&lt;pre&gt;
&lt;?php if ( is_active_sidebar( 'left-sidebar' ) ) : ?&gt;
&lt;ul id=&quot;sidebar&quot;&gt;
&lt;?php dynamic_sidebar( 'left-sidebar' ); ?&gt;
&lt;/ul&gt;
&lt;?php endif; ?&gt;
&lt;/pre&gt;
=== in the &quot;Twenty Ten&quot; theme (3.0+) ===
* {{Trac|wp-content/themes/twentyten/sidebar.php}}
* {{Trac|wp-content/themes/twentyten/sidebar-footer.php}}
==Multiple Sidebars==
You can load a specific sidebar by either their name (if given a string) or ID (if given an integer). For example, &lt;tt&gt;dynamic_sidebar('top_menu')&lt;/tt&gt; will present a sidebar registered with &lt;tt&gt;register_sidebar(array('name'=&gt;'top_menu',))&lt;/tt&gt;.
Using ID's ( &lt;tt&gt;dynamic_sidebar(1)&lt;/tt&gt; ) is easier in that you don't need to name your sidebar, but they are harder to figure out without looking into your &lt;tt&gt;functions.php&lt;/tt&gt; file or in the widgets administration panel and thus make your code less readable. Note that ID's begin at 1.
If you name your own ID values in the &lt;tt&gt;register_sidebar()&lt;/tt&gt; WordPress function, you might increase readability of the code. The ID should be all lowercase alphanumeric characters and not contain white space. You can also use the &lt;tt&gt;-&lt;/tt&gt; and &lt;tt&gt;_&lt;/tt&gt; characters. IDs must be unique and cannot match a sidebar name. Using your own IDs can also make the sidebar name translatable.
&lt;pre&gt;// See the __() WordPress function for valid values for $text_domain.
register_sidebar( array(
'id' =&gt; 'top-menu',
'name' =&gt; __( 'Top Menu', $text_domain ),
'description' =&gt; __( 'This sidebar is located above the age logo.', $text_domain ),
) );
&lt;/pre&gt;
This allows the use of &lt;tt&gt;dynamic_sidebar( 'top-menu' )&lt;/tt&gt; which uses an ID and is readable.
== Changelog ==
Since: [[Version 2.2|2.2.0]]
== Source File ==
&lt;tt&gt;dynamic_sidebar()&lt;/tt&gt; is located in {{Trac|wp-includes/widgets.php}}.
== Further Reading ==
* [http://www.prelovac.com/vladimir/wordpress-theme-flexibility-with-dynamic-sidebars WordPress theme flexibility with dynamic sidebars]
* [http://wordpress.org/support/topic/the-meaning-of-spitting-out-widgets The meaning of &quot;spitting out&quot; widgets]
== Related ==
{{Sidebar Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:Widgets]]</p>
</d:entry>
<d:entry id="register_sidebar_widget" d:title="register sidebar widget">
<d:index d:value="register sidebar widget"/>
<h1>register sidebar widget</h1>
<p>{{Languages|
{{en|Function Reference/register_sidebar_widget}}
{{ja|関数リファレンス/register_sidebar_widget}}
}}
{{Deprecated|wp_register_sidebar_widget()}}
== Description ==
Register widget for sidebar with backwards compatibility.
Provides backwards compatability to [[Function_Reference/wp_register_sidebar_widget|wp_register_sidebar_widget()]]. Registers callback as a widget output function with unique index name. This causes a draggable object containing name to appear in the admin interface.
A basic widget is simply a function that prints some HTML. To get a widget included in the widgets palette, you must register it via this function.
It is possible for theme authors to define replacement widgets within functions.php. Replace an existing widget by registering its name with a new callback. An empty callback will unregister a widget.
Because each widget has a unique name and a non-unique callback, the default markup before a widget looks like this:
&lt;pre&gt;&lt;li id=&quot;{name}&quot; class=&quot;{callback}&quot;&gt;{callback output}&lt;/li&gt;&lt;/pre&gt;
When you register a widget you may pass a custom HTML class to replace &lt;code&gt;callback&lt;/code&gt;. This is most useful for object-oriented widgets whose callbacks are passed as arrays.
== Replace With ==
[[Function_Reference/wp_register_sidebar_widget|wp_register_sidebar_widget()]]
== Usage ==
%%% &lt;?php register_sidebar_widget( $name, $output_callback, $classname ); ?&gt; %%%
== Parameters ==
{{Parameter|$name|string/int|Widget ID.}}
{{Parameter|$output_callback|callback|Run when widget is called.}}
{{Parameter|$classname|string|Classname widget.|optional}}
==Example==
&lt;pre&gt;&lt;?php
function my_widget {
// print some HTML for the widget to display here.
}
register_sidebar_widget(&quot;my_widget&quot;, &quot;my_widget&quot;);
?&gt;&lt;/pre&gt;
Given a class &lt;code&gt;my_widget&lt;/code&gt; whose method that prints the widget HTML is called &lt;code&gt;display&lt;/code&gt;, you would use the following code:
&lt;pre&gt;&lt;?php
class my_widget {
function display() {
// print some HTML for the widget to display here.
}
}
register_sidebar_widget('My Widget', array('my_widget', 'display')); // callback is mywidget::display
?&gt;&lt;/pre&gt;
== Change Log ==
* Deprecated: [[Version 2.8|2.8.0]] Use [[Function_Reference/wp_register_sidebar_widget|wp_register_sidebar_widget()]]
* Since: [[Version 2.2|2.2.0]]
== Source File ==
&lt;tt&gt;register_sidebar_widget()&lt;/tt&gt; is located in {{Trac|wp-includes/deprecated.php}}.
== Related ==
{{Widget Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:Widgets]]</p>
</d:entry>
<d:entry id="unregister_sidebar_widget" d:title="unregister sidebar widget">
<d:index d:value="unregister sidebar widget"/>
<h1>unregister sidebar widget</h1>
<p>{{Deprecated|new_function=wp_unregister_sidebar_widget|version=2.8}}
== Description ==
Makes a previously available widget unavailable. This is most commonly used within a theme's functions.php to disable a widget that does not work well in that theme's sidebar.
== Usage ==
%%% &lt;?php unregister_sidebar_widget( $id ); ?&gt; %%%
== Parameters ==
{{Parameter|$id|string/int|Widget ID.}}
== Example ==
== Notes ==
* Uses [[Function Reference/wp_unregister_sidebar_widget|wp_unregister_sidebar_widget()]]
== Change Log ==
* Deprecated: 2.8.0
* Since: 2.2.0
== Source File ==
&lt;tt&gt;unregister_sidebar_widget()&lt;/tt&gt; was located in {{Trac|wp-includes/widgets.php}}. Upon deprecation it was moved to {{Trac|wp-includes/deprecated.php}}.
== Related ==
{{Widget Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:Widgets]]</p>
</d:entry>
<d:entry id="register_widget_control" d:title="register widget control">
<d:index d:value="register widget control"/>
<h1>register widget control</h1>
<p>{{Deprecated}}
==Synopsis==
&lt;tt&gt;void register_widget_control ( string name, callback [, int width [, int height ] ] )&lt;/tt&gt;
Adds the output of callback to the admin interface as an inline popup. The popup is a child of the main form so it must not include &lt;form&gt; tags or submit buttons. It should include form inputs with very specific names and id&rsquo;s.
The form data should also be handled within callback as its first action, but advanced widgets may have good reasons to differ from this model.
The string name used in register_widget_control() needs to match the string name used in [[Function Reference/register_sidebar_widget|register_sidebar_widget()]].
== Related ==
{{Widget Tags}}
[[Category:Functions]]
[[Category:Widgets]]</p>
</d:entry>
<d:entry id="unregister_widget_control" d:title="unregister widget control">
<d:index d:value="unregister widget control"/>
<h1>unregister widget control</h1>
<p>{{Deprecated}}
==Synopsis==
&lt;tt&gt;void unregister_widget_control ( string name )&lt;/tt&gt;
Removes a widget&rsquo;s admin callback.
== Related ==
{{Widget Tags}}
[[Category:Functions]]
[[Category:Widgets]]</p>
</d:entry>
<d:entry id="unregister_sidebar" d:title="unregister sidebar">
<d:index d:value="unregister sidebar"/>
<h1>unregister sidebar</h1>
<p>== Description ==
De-registers a previously registered [[Sidebars|sidebar]].
== Usage ==
%%% &lt;?php unregister_sidebar( $id ); ?&gt; %%%
== Parameters ==
{{Parameter|$id|string|The ID of the sidebar when it was added.}}
== Example ==
If added to a child theme's functions.php file, this will remove the footer sidebars registered by the TwentyTen theme.
&lt;pre&gt;
function remove_some_widgets(){
// Unregister some of the TwentyTen sidebars
unregister_sidebar( 'first-footer-widget-area' );
unregister_sidebar( 'second-footer-widget-area' );
unregister_sidebar( 'third-footer-widget-area' );
unregister_sidebar( 'fourth-footer-widget-area' );
}
add_action( 'widgets_init', 'remove_some_widgets', 11 );
&lt;/pre&gt;
== Notes ==
In the example, note that we assign a priority of 11 when registering the widgets_init hook. This is because a child theme's functions.php file is called before the parent theme's, which means that our call to unregister_sidebar() would accomplish nothing since the sidebar has not yet been registered.
By lowering the priority of our action, we ensure that it is called after the parent theme's functions.php file is loaded.
== Change Log ==
Since: 2.2.0
== Source File ==
&lt;tt&gt;unregister_sidebar()&lt;/tt&gt; is located in {{Trac|wp-includes/widgets.php}}.
== Related ==
{{Sidebar Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:Widgets]]</p>
</d:entry>
<d:entry id="is_active_widget" d:title="is active widget">
<d:index d:value="is active widget"/>
<h1>is active widget</h1>
<p>{{Languages|
{{en|Function Reference/is active widget}}
{{ja|関数リファレンス/is_active_widget}}
}}
== Description ==
This [[Conditional Tags|Conditional Tag]] checks whether widget is displayed on the front-end.
To be effective this function has to run after widgets have initialized, at action &lt;tt&gt;[[Plugin_API/Action_Reference/init | 'init']]&lt;/tt&gt; or later.
== Usage ==
&lt;pre&gt;&lt;?php
is_active_widget( $callback, $widget_id, $id_base, $skip_inactive );
?&gt;&lt;/pre&gt;
== Parameters ==
{{Parameter|$callback|string|Widget callback to check.|optional|False}}
{{Parameter|$widget_id|int|Widget ID. Needed for checking.|optional}}
{{Parameter|$id_base|string|Base ID of a widget created by extending WP_Widget.|optional}}
{{Parameter|$skip_inactive|boolean|Whether to check in 'wp_inactive_widgets'.|optional|True}}
==Return Values==
; &lt;tt&gt;(mixed)&lt;/tt&gt; : Returns false if the specified widget is not active, or the id of the sidebar in which the widget is active. If the callback is non-unique you can optionally specify the ID of the widget.
== Examples ==
=== Only load a script when the widget is active ===
&lt;pre&gt;&lt;?php
if ( is_active_widget( false, false, $this-&gt;id_base, true ) ) {
wp_enqueue_script( 'jquery' );
}
?&gt;&lt;/pre&gt;
== Change Log ==
Since: 2.2.0
== Source File ==
&lt;tt&gt;is_active_widget()&lt;/tt&gt; is located in {{Trac|wp-includes/widgets.php}}.
== Related ==
{{Widget Tags}}
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]
[[Category:Widgets]]</p>
</d:entry>
<d:entry id="is_dynamic_sidebar" d:title="is dynamic sidebar">
<d:index d:value="is dynamic sidebar"/>
<h1>is dynamic sidebar</h1>
<p>== Description ==
This [[Conditional Tags|Conditional Tag]] checks if any registered [[Sidebars|sidebar]] has active widgets.
== Usage ==
%%% &lt;?php is_dynamic_sidebar(); ?&gt; %%%
== Parameters ==
This tag does not accept any parameters.
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : &lt;tt&gt;true&lt;/tt&gt; if any registered sidebar contains a widget; otherwise &lt;tt&gt;false&lt;/tt&gt;.
== Examples ==
== Change Log ==
Since: 2.2.0
== Source File ==
&lt;tt&gt;is_dynamic_sidebar()&lt;/tt&gt; is located in {{Trac|wp-includes/widgets.php}}.
== Related ==
{{Sidebar Tags}}
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_current_theme" d:title="get current theme">
<d:index d:value="get current theme"/>
<h1>get current theme</h1>
<p>== Description ==
Retrieve the name of the current theme.
get_current_theme() is deprecated since version 3.4! Use [[Function Reference/wp_get_theme | wp_get_theme()]] instead
== Usage ==
%%%&lt;?php get_current_theme() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Template name.
== Examples ==
=== Current Theme Name ===
Get the name of the current theme.
&lt;?php
$theme_name = get_current_theme();
echo $theme_name;
?&gt;
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;template_directory&lt;/tt&gt;' filter on template directory path and template name.
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_current_theme()&lt;/tt&gt; is located in {{Trac|wp-includes/deprecated.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
[[Function Reference/get_stylesheet_directory|get_stylesheet_directory]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_page_by_title" d:title="get page by title">
<d:index d:value="get page by title"/>
<h1>get page by title</h1>
<p>{{Languages|
{{en|Function Reference/get page by title}}
{{ru|Справочник по функциям/get page by title}}
}}
== Description ==
Retrieves a post given its title. If more that one post uses the same title, the post with the smallest ID will be returned.
Because this function uses the MySQL &lt;tt&gt;'='&lt;/tt&gt; comparison the &lt;tt&gt;$page_title&lt;/tt&gt; will ''usually'' be matched as case insensitive with [http://dev.mysql.com/doc/refman/5.5/en/case-sensitivity.html default collating].
== Usage ==
%%%
&lt;?php
get_page_by_title( $page_title, $output, $post_type );
?&gt;
%%%
== Parameters ==
{{Parameter|$page_title|string|Page title}}
{{Parameter|$output|string|Output type. &lt;tt&gt;OBJECT&lt;/tt&gt;, &lt;tt&gt;ARRAY_N&lt;/tt&gt;, or &lt;tt&gt;ARRAY_A&lt;/tt&gt;.|optional|OBJECT}}
{{Parameter|$post_type|string|Post type.|optional|page}}
== Return Values ==
; (mixed) : &lt;tt&gt;OBJECT&lt;/tt&gt;, &lt;tt&gt;ARRAY_N&lt;/tt&gt;, or &lt;tt&gt;ARRAY_A&lt;/tt&gt;.
&lt;tt&gt;NULL&lt;/tt&gt; when no posts found.
== Examples ==
===Find Page ID to use with exclude in wp_list_pages===
This example will return the $page object for the page titled &quot;About&quot;. Then the $page-&gt;ID element is used to exclude the About page when listing pages.
&lt;pre&gt;
&lt;?php
$page = get_page_by_title( 'About' );
wp_list_pages( 'exclude=' . $page-&gt;ID );
?&gt;
&lt;/pre&gt;
===How To Find WordPress Page ID By Title Then Replace the_content()===
In this example, we find the page id of &quot;Sample Page&quot; then replace the page's the_content() with &quot;Hello World!&quot;
&lt;pre&gt;
function my_content($content) {
$page = get_page_by_title( 'Sample Page' );
if ( is_page($page-&gt;ID) )
$content = &quot;Hello World!&quot;;
return $content;
}
add_filter('the_content', 'my_content');
&lt;/pre&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
== Change Log ==
* Since: [[Version 2.1|2.1.0]]
* [[Version 3.0|3.0.0]]: &lt;code&gt;$post_type&lt;/code&gt; Parameter was added.
== Source File ==
&lt;tt&gt;get_page_by_title()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Page Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_terms" d:title="get terms">
<d:index d:value="get terms"/>
<h1>get terms</h1>
<p>{{Languages|
{{en|Function Reference/get terms}}
{{ja|関数リファレンス/get terms}}
}}
==Description==
Retrieve the terms in a taxonomy or list of taxonomies.
Returns an array of term objects, or a WP_Error object if any of the taxonomies to get terms from does not exist.
==Usage==
%%%&lt;?php get_terms( $taxonomies, $args ) ?&gt;%%%
=== Default Usage ===
&lt;pre&gt;&lt;?php
// no default values. using these as examples
$taxonomies = array(
'post_tag',
'my_tax',
);
$args = array(
'orderby' =&gt; 'name',
'order' =&gt; 'ASC',
'hide_empty' =&gt; true,
'exclude' =&gt; array(),
'exclude_tree' =&gt; array(),
'include' =&gt; array(),
'number' =&gt; '',
'fields' =&gt; 'all',
'slug' =&gt; '',
'parent' =&gt; '',
'hierarchical' =&gt; true,
'child_of' =&gt; 0,
'get' =&gt; '',
'name__like' =&gt; '',
'description__like' =&gt; '',
'pad_counts' =&gt; false,
'offset' =&gt; '',
'search' =&gt; '',
'cache_domain' =&gt; 'core'
);
?&gt;&lt;/pre&gt;
== Parameters ==
{{Parameter|$taxonomies|string&amp;#124;array|The taxonomies to retrieve terms from. ([[Taxonomies#Default_Taxonomies|Default Taxonomies]])}}
{{Parameter|$args|string&amp;#124;array|Change what is returned.|optional|array}}
===Possible Arguments===
; orderby : (''string'')
:* &lt;tt&gt;id&lt;/tt&gt;
:* &lt;tt&gt;count&lt;/tt&gt;
:* &lt;tt&gt;name&lt;/tt&gt; - Default
:* &lt;tt&gt;slug&lt;/tt&gt;
:* &lt;tt&gt;term_group&lt;/tt&gt; - Not fully implemented (avoid using)
:* &lt;tt&gt;none&lt;/tt&gt;
; order : (''string'')
:* &lt;tt&gt;ASC&lt;/tt&gt; - Default
:* &lt;tt&gt;DESC&lt;/tt&gt;
; hide_empty : (''boolean'') Whether to &lt;b&gt;not&lt;/b&gt; return empty $terms.
:* &lt;tt&gt;1 (true)&lt;/tt&gt; - Default (i.e. Do not show empty terms)
:* &lt;tt&gt;0 (false)&lt;/tt&gt;
; exclude : (''integer|string|array'') An array of term ids to exclude. Also accepts a string of comma-separated ids.
; exclude_tree : (''integer'') An array of parent term ids to exclude
; include : (''integer'') An array of term ids to include. Empty returns all.
; number : (''integer'') The maximum number of terms to return. Default is to return them all.
; fields : (''string'')
:* all - returns an array of term objects - Default
:* ids - returns an array of integers
:* names - returns an array of strings
:* count - (3.2+) returns the number of terms found
:* id=&gt;parent - returns an associative array where the key is the term id and the value is the parent term id if present or 0
:* id=&gt;slug - returns an associative array where the key is the term id and the value is the slug
:* id=&gt;name - returns an associative array where the key is the term id and the value is the name
; slug : (''string'') Returns terms whose &quot;slug&quot; matches this value. Default is empty string.
; parent : (''integer'') Get direct children of this term (only terms whose explicit parent is this value). If 0 is passed, only top-level terms are returned. Default is an empty string.
; hierarchical : (''boolean'') Whether to include terms that have non-empty descendants (even if 'hide_empty' is set to true).
:* &lt;tt&gt;1 (true)&lt;/tt&gt; - Default
:* &lt;tt&gt;0 (false)&lt;/tt&gt;
; child_of : (''integer'') Get all descendents of this term. Default is 0. '''Note:''' the difference between &lt;tt&gt;child_of&lt;/tt&gt; and &lt;tt&gt;parent&lt;/tt&gt; is that where &lt;tt&gt;parent&lt;/tt&gt; only gets direct children of the parent term (ie: 1 level down), &lt;tt&gt;child_of&lt;/tt&gt; gets ''all'' descendants (as many levels as are available)
; get : (''string'') Default is nothing . Allow for overwriting 'hide_empty' and 'child_of', which can be done by setting the value to 'all'.
; name__like : (''string'') The term name you wish to match. It does a LIKE '%string%' query against the term name only. This matches terms that '''contain''' the 'name__like' string. '''Note:''' This was changed in WordPress 3.7, when previously name__like matched terms that '''begin with''' the string. See [http://core.trac.wordpress.org/ticket/8214 ticket #8214].
; description__like : (''string'') Returned terms' descriptions will contain the value of 'description__like', case-insensitive. Default is empty string. It does a LIKE '%string%' query against the term description only. This matches terms that '''contain''' the 'description__like' string.
; pad_counts : (''boolean'') If true, count all of the children along with the $terms.
:* &lt;tt&gt;1 (true)&lt;/tt&gt;
:* &lt;tt&gt;0 (false)&lt;/tt&gt; - Default
; offset : (''integer'') The number by which to offset the terms query. Must be used in conjunction with 'number' otherwise 'offset' is ignored and the entire result set is returned.
; search : (''string'') The term name you wish to match. It does a LIKE '%search_string%' query against the term name and slug. This matches terms that '''contain''' the 'search_string' string.
; cache_domain : (''string'') Version 3.2 and above. The 'cache_domain' argument enables a unique cache key to be produced when the query produced by get_terms() is stored in object cache. For instance, if you are using one of this function's filters to modify the query (such as 'terms_clauses'), setting 'cache_domain' to a unique value will not overwrite the cache for similar queries. Default value is 'core'.
'''NOTE''': Arguments are passed in the format used by [[Function_Reference/wp_parse_args|wp_parse_args()]]. e.g.
== Return Values ==
; &lt;tt&gt;(array&amp;#124;string&amp;#124;WP_Error)&lt;/tt&gt; : Array of term objects or an empty array if no terms were found. &lt;tt&gt;[[Class_Reference/WP_Error | WP_Error]]&lt;/tt&gt; if any of &lt;tt&gt;$taxonomies&lt;/tt&gt; does not exist. If the &lt;tt&gt;'fields'&lt;/tt&gt; argument was &lt;tt&gt;'count'&lt;/tt&gt;, the number of terms found will be returned as a string.
The fields returned are:
* &lt;tt&gt;term_id&lt;/tt&gt;
* &lt;tt&gt;name&lt;/tt&gt;
* &lt;tt&gt;slug&lt;/tt&gt;
* &lt;tt&gt;term_group&lt;/tt&gt;
* &lt;tt&gt;term_taxonomy_id&lt;/tt&gt;
* &lt;tt&gt;taxonomy&lt;/tt&gt;
* &lt;tt&gt;description&lt;/tt&gt;
* &lt;tt&gt;parent&lt;/tt&gt;
* &lt;tt&gt;count&lt;/tt&gt;
'''Warning: string vs integer confusion!''' Field values, including &lt;tt&gt;term_id&lt;/tt&gt; are returned in string format. Before further use, typecast numeric values to actual integers, otherwise WordPress will mix up term_ids and slugs which happen to have only numeric characters
== Examples ==
Get all post categories ordered by count.
String syntax:
$categories = get_terms( 'category', 'orderby=count&amp;hide_empty=0' );
Array syntax:
&lt;pre&gt;
$categories = get_terms( 'category', array(
'orderby' =&gt; 'count',
'hide_empty' =&gt; 0
) );
&lt;/pre&gt;
Get all the links categories:
$mylinks_categories = get_terms('link_category', 'orderby=count&amp;hide_empty=0');
List all the terms in a custom taxonomy, without a link:
&lt;pre&gt; $terms = get_terms(&quot;my_taxonomy&quot;);
if ( !empty( $terms ) &amp;&amp; !is_wp_error( $terms ) ){
echo &quot;&lt;ul&gt;&quot;;
foreach ( $terms as $term ) {
echo &quot;&lt;li&gt;&quot; . $term-&gt;name . &quot;&lt;/li&gt;&quot;;
}
echo &quot;&lt;/ul&gt;&quot;;
}
&lt;/pre&gt;
List all the terms, with link to term archive, separated by an interpunct ('''&amp;middot;'''):
&lt;pre lang=&quot;php&quot;&gt;$args = array( 'hide_empty=0' );
$terms = get_terms('my_term', $args);
if ( !empty( $terms ) &amp;&amp; !is_wp_error( $terms ) ) {
$count = count($terms);
$i=0;
$term_list = '&lt;p class=&quot;my_term-archive&quot;&gt;';
foreach ($terms as $term) {
$i++;
$term_list .= '&lt;a href=&quot;' . get_term_link( $term ) . '&quot; title=&quot;' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term-&gt;name) . '&quot;&gt;' . $term-&gt;name . '&lt;/a&gt;';
if ($count != $i) {
$term_list .= ' &amp;amp;middot; ';
}
else {
$term_list .= '&lt;/p&gt;';
}
}
echo $term_list;
}&lt;/pre&gt;
==Details==
You can inject any customizations to the query before it is sent or control the output with filters.
The 'get_terms' filter will be called when the cache has the term and will pass the found term along with the array of $taxonomies and array of $args.
This filter is also called before the array of terms is passed and will pass the array of terms, along with the $taxonomies and $args.
The 'list_terms_exclusions' filter passes the compiled exclusions along with the $args.
== Change Log ==
* Since: [[Version 2.3|2.3.0]]
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_terms()&lt;/tt&gt; is located in {{Trac|wp-includes/taxonomy.php}}.
==Related==
{{Term Tags}}
== Resources ==
[[Category:Functions]]
[[Category:Taxonomies]]
{{Tag Footer}}</p>
</d:entry>
<d:entry id="wp_upload_dir" d:title="wp upload dir">
<d:index d:value="wp upload dir"/>
<h1>wp upload dir</h1>
<p>== Description ==
Returns an array of '''key =&gt; value''' pairs containing path information on the currently configured uploads directory.
Checks the 'upload_path' option, which should be from the web root folder, and if it isn't empty it will be used. If it is empty, then the path will be 'WP_CONTENT_DIR/uploads'. If the 'UPLOADS' constant is defined, then it will override the 'upload_path' option and 'WP_CONTENT_DIR/uploads' path.
The upload URL path is set either by the 'upload_url_path' option or by using the 'WP_CONTENT_URL' constant and appending '/uploads' to the path.
If the 'uploads_use_yearmonth_folders' is set to true (checkbox if checked in the administration settings panel), then the time will be used. The format will be year first and then month.
If the path couldn't be created, then an error will be returned with the key &lt;tt&gt;'error'&lt;/tt&gt; containing the error message. The error suggests that the parent directory is not writable by the server.
On success, the returned array will have many indices:
* 'path' - base directory and sub directory or full path to upload directory.
* 'url' - base url and sub directory or absolute URL to upload directory.
* 'subdir' - sub directory if uploads use year/month folders option is on.
* 'basedir' - path without subdir.
* 'baseurl' - URL path without subdir.
* 'error' - set to false.
== Usage ==
&lt;pre&gt;
&lt;?php $upload_dir = wp_upload_dir(); ?&gt;
&lt;/pre&gt;
== Parameters ==
{{Parameter|$time|string|Time formatted in 'yyyy/mm'.|optional|null}}
== Example ==
Basic example to produce the upload directory URL.
%%%&lt;?php $upload_dir = wp_upload_dir(); ?&gt;
&lt;?php echo $upload_dir['baseurl']; ?&gt;%%%
More in-depth break down of the data returned.
%%%&lt;?php
$upload_dir = wp_upload_dir(); // Array of key =&gt; value pairs
/*
$upload_dir now contains something like the following (if successful)
Array (
[path] =&gt; C:\path\to\wordpress\wp-content\uploads\2010\05
[url] =&gt; http://example.com/wp-content/uploads/2010/05
[subdir] =&gt; /2010/05
[basedir] =&gt; C:\path\to\wordpress\wp-content\uploads
[baseurl] =&gt; http://example.com/wp-content/uploads
[error] =&gt;
)
// Descriptions
[path] - base directory and sub directory or full path to upload directory.
[url] - base url and sub directory or absolute URL to upload directory.
[subdir] - sub directory if uploads use year/month folders option is on.
[basedir] - path without subdir.
[baseurl] - URL path without subdir.
[error] - set to false.
*/
echo $upload_dir['path'] . '&lt;br /&gt;';
echo $upload_dir['url'] . '&lt;br /&gt;';
echo $upload_dir['subdir'] . '&lt;br /&gt;';
echo $upload_dir['basedir'] . '&lt;br /&gt;';
echo $upload_dir['baseurl'] . '&lt;br /&gt;';
echo $upload_dir['error'] . '&lt;br /&gt;';
$upload_url = ( $upload_dir['url'] );
$upload_url_alt = ( $upload_dir['baseurl'] . $upload_dir['subdir'] );
// Now echo the final result
echo $upload_url . '&lt;br /&gt;'; // Output - http://example.com/wp-content/uploads/2010/05
// Using year and month based folders, the below will be the same as the line above.
echo $upload_url_alt . '&lt;br /&gt;'; // Output - http://example.com/wp-content/uploads/2010/05
?&gt;%%%
== Important Note ==
Note that using this function &lt;strong&gt;will create a subfolder in your Uploads folder&lt;/strong&gt; corresponding to the queried month (or current month, if no &lt;tt&gt;$time&lt;/tt&gt; argument is provided), if that folder is not already there. You don't have to upload anything in order for this folder to be created.
== Folder Name ==
In case you want to move the &lt;tt&gt;/uploads&lt;/tt&gt; folder, you'll have to use the &lt;tt&gt;UPLOADS&lt;/tt&gt; constant. It normally shouldn't get used, as it only get's defined when &lt;tt&gt;ms_default_constants()&lt;/tt&gt; is run (only multisite), but you can simply set
&lt;pre&gt;
define( 'UPLOADS', trailingslashit( WP_CONTENT_DIR ).'custom_uploads_name' );
&lt;/pre&gt;
in a single site install and it will just work, as the public directory structure function &lt;tt&gt;wp_upload_dir()&lt;/tt&gt; sets it up, when it was defined: &lt;tt&gt;$dir = ABSPATH . UPLOADS;&lt;/tt&gt;.
''Note:'' You can extract the folder name with the following line:
&lt;pre&gt;
// returns `false` if the UPLOADS constant is not defined
$upload_dir_name = false;
if ( defined( 'UPLOADS' ) )
str_replace( trailingslashit( WP_CONTENT_DIR ), '', untrailingslashit( UPLOADS ) );
&lt;/pre&gt;
== Change Log ==
Since: [[Version 2.0|2.0.0]]
== Source File ==
&lt;tt&gt;wp_upload_dir()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
{{Directory URL Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_get_attachment_image" d:title="wp get attachment image">
<d:index d:value="wp get attachment image"/>
<h1>wp get attachment image</h1>
<p>{{Languages|
{{en|Function Reference/wp get attachment image}}
{{it|Riferimento funzioni/wp get attachment image}}
{{ja|Function Reference/wp get attachment image}}
}}
== Description ==
Returns an HTML image element representing an attachment file, if there is any, otherwise an empty string.
== Usage ==
%%%&lt;?php wp_get_attachment_image( $attachment_id, $size, $icon, $attr ); ?&gt;%%%
== Default Usage ==
&lt;?php echo wp_get_attachment_image( 1 ); ?&gt;
If the attachment is an image, the function returns an image at the specified size.
For other attachments, the function returns a media icon if the &lt;var&gt;$icon&lt;/var&gt; parameter is set to &lt;tt&gt;true&lt;/tt&gt;.
To get attachment IDs dynamically in a template, you can use [[Template_Tags/get_posts|get_posts('post_type=attachment')]], etc.
== Parameters ==
{{Parameter|$attachment_id|integer|ID of the desired attachment.}}
{{Parameter|$size|string/array|Image size. Either a string keyword (thumbnail, medium, large or full) or a 2-item array representing width and height in pixels, e.g. array(32,32). As of [[Version 2.5]], this parameter does not affect the size of media icons, which are always shown at their original size.|Optional|'thumbnail'}}
Instead of using an array which requires checking all of the image sizes, you should consider registering a size with &lt;code&gt;add_image_size&lt;/code&gt; so that a cropped version is generated. It's much more efficient than having to find the closest sized image.
{{Parameter|$icon|boolean|Use a media icon to represent the attachment.|Optional|'False'}}
:* &lt;tt&gt;1 (True)&lt;/tt&gt;
:* &lt;tt&gt;0 (False)&lt;/tt&gt; - Default
{{Parameter|$attr|string/array|Query string or array of attributes.|Optional}}
&lt;pre&gt;
$default_attr = array(
'src' =&gt; $src,
'class' =&gt; &quot;attachment-$size&quot;,
'alt' =&gt; trim(strip_tags( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) )),
);
&lt;/pre&gt;
The &lt;tt&gt;$attr&lt;/tt&gt; argument is merged with WordPress's default attributes and passed through the &lt;tt&gt;wp_get_attachment_image_attributes&lt;/tt&gt; filter.
== Examples ==
=== Display all images as a list ===
To display all of the images and titles attached to a certain page and display them as a list of bullets you can use the following:
&lt;pre&gt;&lt;ul&gt;
&lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post();
$args = array(
'post_type' =&gt; 'attachment',
'numberposts' =&gt; -1,
'post_status' =&gt; null,
'post_parent' =&gt; $post-&gt;ID
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo '&lt;li&gt;';
echo wp_get_attachment_image( $attachment-&gt;ID, 'full' );
echo '&lt;p&gt;';
echo apply_filters( 'the_title', $attachment-&gt;post_title );
echo '&lt;/p&gt;&lt;/li&gt;';
}
}
endwhile; endif; ?&gt;
&lt;/ul&gt;&lt;/pre&gt;
== Return Value ==
an HTML img element or empty string on failure.
== Change Log ==
Since: 2.5.0
== Source File ==
&lt;tt&gt;wp_get_attachment_image()&lt;/tt&gt; is located in {{Trac|wp-includes/media.php}}.
== Related ==
{{Attachment Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="wp_get_attachment_image_src" d:title="wp get attachment image src">
<d:index d:value="wp get attachment image src"/>
<h1>wp get attachment image src</h1>
<p>{{Languages|
{{en|Function Reference/wp_get_attachment_image_src}}
{{it|Riferimento funzioni/wp_get_attachment_image_src}}
{{ja| 関数リファレンス/wp_get_attachment_image_src}}
}}
== Description ==
Returns an ordered array with values corresponding to the (0) url, (1) width, (2) height, and (3) scale of an image attachment (or an icon representing any attachment).
It's most often used to get the URL (src) for an image attachment: use the first element in the returned array.
wp_get_attachment_image() uses wp_get_attachment_image_src() to fill the width, height, and src attributes of an &lt;tt&gt;img&lt;/tt&gt;.
== Usage ==
%%% &lt;?php wp_get_attachment_image_src( $attachment_id, $size, $icon ); ?&gt; %%%
== Parameters ==
{{Parameter|$attachment_id|integer|ID of the desired attachment.}}
{{Parameter|$size|string/array|Size of the image shown for an image attachment: either a string keyword (thumbnail, medium, large or full) or a 2-item array representing width and height in pixels, e.g. array(32,32). As of Version 2.5, this parameter does not affect the size of media icons, which are always shown at their original size.|optional|thumbnail}}
{{Parameter|$icon|bool|Use a media icon to represent the attachment.|optional|false}}
== Return Value ==
{{Return||array|An array containing:}}
* [0] =&gt; url
* [1] =&gt; width
* [2] =&gt; height
* [3] =&gt; boolean: true if $url is a resized image, false if it is the original.
or false, if no image is available.
== Examples ==
=== Default Usage ===
&lt;pre&gt;&lt;?php
$attachment_id = 8; // attachment ID
$image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array
if( $image_attributes ) {
?&gt;
&lt;img src=&quot;&lt;?php echo $image_attributes[0]; ?&gt;&quot; width=&quot;&lt;?php echo $image_attributes[1]; ?&gt;&quot; height=&quot;&lt;?php echo $image_attributes[2]; ?&gt;&quot;&gt;
&lt;?php } ?&gt;&lt;/pre&gt;
=== Change Icon Directory ===
WordPress can use media icons to represent [[Using_Image_and_File_Attachments|attachment files]] on your blog and in the Admin interface, if those icons are available. For images it returns the thumbnail. For other media types It looks for image files named by media type (e.g. audio.jpg) in the directory: ''wp-includes/images/crystal/''.
This example shows how you can change this directory to a folder called &quot;images&quot; in your theme: ''wp-content/themes/yourtheme/images''. Create the folder and put the &quot;media type images&quot; in there. To tell WordPress the directory has changed put this in the current theme's [[Theme_Development#Functions_File|functions.php]] file:
&lt;pre&gt;add_filter( 'icon_dir', 'my_theme_icon_directory' );
add_filter( 'icon_dir_uri', 'my_theme_icon_uri' );
function my_theme_icon_directory( $icon_dir ) {
return get_stylesheet_directory() . '/images';
}
function my_theme_icon_uri( $icon_dir ) {
return get_stylesheet_directory_uri() . '/images';
}
&lt;/pre&gt;
=== Show the first image of the post ===
find the full code here [[Function Reference/get_children#Examples|get_children()]].
== Change Log ==
Since: [[Version 2.5|2.5.0]]
== Source File ==
&lt;tt&gt;wp_get_attachment_image_src()&lt;/tt&gt; is located in {{Trac|wp-includes/media.php}}.
== Related ==
{{Attachment Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="is_email" d:title="is email">
<d:index d:value="is email"/>
<h1>is email</h1>
<p>{{Languages|
{{en|Function_Reference/is_email}}
{{ko|Function_Reference/is_email}}
}}
== Description ==
Verifies that an email is valid.
== Usage ==
%%%&lt;?php is_email( $email ) ?&gt;%%%
== Parameters ==
{{Parameter|$email|string|Email address to check.}}
== Return Values ==
; &lt;tt&gt;(string|bool)&lt;/tt&gt; : Either returns false or the valid email address.
== Examples ==
&lt;pre&gt;
if ( is_email( 'email@domain.com' ) ) {
echo 'email address is valid.';
}
&lt;/pre&gt;
== Notes ==
Does not grok i18n domains. Not RFC compliant.
== Change Log ==
* [[Version_3.0 | 3.0.0]]: The second parameter, &lt;tt&gt;$check_dns&lt;/tt&gt; was deprecated. See [http://core.trac.wordpress.org/changeset/14381 changeset 14381].
* Since: 0.71
== Source File ==
&lt;tt&gt;is_email()&lt;/tt&gt; is located in
{{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find any related functions.
Some functions may be related to many groups of functions.
--&gt;
See: [[Data_Validation|Data Validation]] article for an in-depth discussion of input and output sanitization.
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="attribute_escape" d:title="attribute escape">
<d:index d:value="attribute escape"/>
<h1>attribute escape</h1>
<p>[[Function Reference|''&amp;larr; Return to function reference.'']]
{{Deprecated}}
== Description ==
'''This function is deprecated as of WordPress 2.8.0. Please use [[Function Reference/esc_attr|esc_attr]] instead.'''
This function escapes or encodes HTML special characters (including single and double quotes) for use in HTML attributes. It works like the standard PHP &lt;code&gt;[http://php.net/manual/en/function.htmlspecialchars.php htmlspecialchars]&lt;/code&gt; except that it doesn't double-encode HTML entities (i.e. &lt;code&gt;&amp;amp;amp;&lt;/code&gt; will remain unchanged, rather than encoded to &lt;code&gt;&amp;amp;amp;amp;&lt;/code&gt;).
&lt;code&gt;attribute_escape&lt;/code&gt; can be found in &lt;code&gt;/wp-includes/formatting.php&lt;/code&gt;.
== Usage ==
%%%&lt;?php echo attribute_escape($text); ?&gt;%%%
== Parameters ==
;&lt;code&gt;$text&lt;/code&gt;: (''string'') Text to be escaped.
== Related ==
[[Function Reference/esc_attr|esc_attr]], [[Function Reference/esc_attr_e|esc_attr_e]].
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_page" d:title="get page">
<d:index d:value="get page"/>
<h1>get page</h1>
<p>{{Deprecated|new_function=get_post}}
== Description ==
Retrieves page data given a page ID or page object.
Pages provide a way to have static content that will not affect things like articles or archives or any other blog entry features of WordPress. Its simply a way to turn a blog entry into static content.
== Usage ==
%%%&lt;?php get_page( $page_id ) ?&gt;%%%
== Parameters ==
{{Parameter|$page_id|integer|Page ID passed by reference (see example below)|required|Page ID from global variable at time function is called }}
{{Parameter|$output|OBJECT/ARRAY_A/ARRAY_N| What to output. |optional|OBJECT }}
{{Parameter|$filter|string|How the return value should be filtered. Options are 'raw', 'edit', 'db', 'display', 'attribute' and 'js'. The 'attribute' and 'js' contexts are treated like 'display'. |optional|'raw'}}
== Return Values ==
&lt;!-- The possible values need to be verified and inserted where there are question marks --&gt;
; &lt;tt&gt;(object|array)&lt;/tt&gt; : mixed Page data.
[ID] =&gt; (integer)
[post_author] =&gt; (integer)
[post_date] =&gt; (YYYY-MM-DD HH:MM:SS)
[post_date_gmt] =&gt; (YYYY-MM-DD HH:MM:SS)
[post_content] =&gt; (all post content is in here)
[post_title] =&gt; (Post Title Here)
[post_excerpt] =&gt; (Post Excerpt)
[post_status] =&gt; (? | publish)
[comment_status] =&gt; (? | closed)
[ping_status] =&gt; (? | closed)
[post_password] =&gt; (blank if not specified)
[post_name] =&gt; (slug-is-here)
[to_ping] =&gt; (?)
[pinged] =&gt; (?)
[post_modified] =&gt; (YYYY-MM-DD HH:MM:SS)
[post_modified_gmt] =&gt; (YYYY-MM-DD HH:MM:SS)
[post_content_filtered] =&gt; (?)
[post_parent] =&gt; (integer)
[guid] =&gt; (a unique identifier that is not necessarily the URL to the Page)
[menu_order] =&gt; (integer)
[post_type] =&gt; (? | page)
[post_mime_type] =&gt; ()?)
[comment_count] =&gt; (integer)
[ancestors] =&gt; (object|array)
[filter] =&gt; (? | raw)
If you need the URL to the Page, don't try and use the &lt;code&gt;guid&lt;/code&gt; value. Use [[Function_Reference/the_permalink|the_permalink]] or [[Function_Reference/get_permalink|get_permalink]] instead.
If a page is not found, a null value is returned.
{{Stub}}
== Examples ==
This example code can be used when you want to include the text of a specific page in a theme.
&lt;pre&gt;
&lt;?php
$page_id = 123; // 123 should be replaced with a specific Page's id from your site, which you can find by mousing over the link to edit that Page on the Manage Pages admin page. The id will be embedded in the query string of the URL, e.g. page.php?action=edit&amp;post=123.
$page_data = get_page( $page_id ); // You must pass in a variable to the get_page function. If you pass in a value (e.g. get_page ( 123 ); ), WordPress will generate an error. By default, this will return an object.
echo '&lt;h3&gt;'. $page_data-&gt;post_title .'&lt;/h3&gt;';// echo the title
echo apply_filters('the_content', $page_data-&gt;post_content); // echo the content and retain WordPress filters such as paragraph tags.
Origin: http://wordpress.org/support/topic/get_pagepost-and-no-paragraphs-problem
?&gt;
&lt;/pre&gt;
== Notes ==
== Change Log ==
* Deprecated: 3.5.0
* Since: 1.5.1
== Source File ==
&lt;tt&gt;get_page()&lt;/tt&gt; is located in
{{Trac|wp-includes/post.php}}.
== Related ==
{{Page Tags}}
[[Function_Reference/get_post|get_post]]
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="post_meta_Function_Examples" d:title="post meta Function Examples">
<d:index d:value="post meta Function Examples"/>
<h1>post meta Function Examples</h1>
<p>==Description==
The following is a detailed example for the usage of the [[Function Reference/add post meta|add_post_meta]], [[Function Reference/delete post meta|delete_post_meta]], [[Function Reference/update post meta|update_post_meta]], and [[Function Reference/get post meta|get_post_meta]] functions.
==Example==
&lt;div style=&quot;padding: 1em; border: 1px dashed #2f6fab; color: Black; background-color: #fafafa; line-height: 1.1em&quot;&gt;
%%%&lt;?php
/*******************
This function handles the mood and listening_to meta tags.
It can be called with an action of update, delete, and get (default)
When called with an action of update, either $mood or $listening_to must be provided.
i.e. mood_music( $post-&gt;ID, 'update', 'Happy', 'Bon Jovi - It's My Life' );
*******************/
function mood_music( $post_id, $action = 'get', $mood = 0, $listening_to = 0 ) {
//Let's make a switch to handle the three cases of 'Action'
switch ($action) {
case 'update' :
if( ! $mood &amp;&amp; ! $listening_to )
//If nothing is given to update, end here
return false;
//add_post_meta usage:
//add_post_meta( $post_id, $meta_key, $meta_value, $unique = false )
//If the $mood variable is supplied,
//add a new key named 'mood', containing that value.
//If the 'mood' key already exists on this post,
//this command will simply add another one.
if( $mood ) {
add_post_meta( $post_id, 'mood', $mood );
return true;
}
//update_post_meta usage:
//update_post_meta( $post_id, $meta_key, $meta_value )
//If the $listening_to variable is supplied,
//add a new key named 'listening_to', containing that value.
//If the 'listening_to' key already exists on this post,
//this command will update it to the new value
if( $listening_to ) {
add_post_meta( $post_id, 'listening_to', $listening_to, true ) or
update_post_meta( $post_id, 'listening_to', $listening_to );
return true;
}
case 'delete' :
//delete_post_meta usage:
//delete_post_meta( $post_id, $meta_key, $prev_value = ' ' )
//This will delete all instances of the following keys from the given post
delete_post_meta( $post_id, 'mood' );
delete_post_meta( $post_id, 'listening_to' );
//To only delete 'mood' if it's value is 'sad':
//delete_post_meta( $post_id, 'mood', 'sad' );
break;
case 'get' :
//get_post_custom usage:
//get_post_meta( $post_id, $meta_key, $single value = false )
//$stored_moods will be an array containing all values of the meta key 'mood'
$stored_moods = get_post_meta( $post_id, 'mood' );
//$stored_listening_to will be the first value of the key 'listening_to'
$stored_listening_to = get_post_meta( $post_id, 'listening_to', 'true' );
//Now we need a nice ouput format, so that
//the user can implement it how he/she wants:
//ie. echo mood_music( $post-&gt;ID, 'get' );
$return = '&lt;div class='mood-music'&gt;';
if ( ! empty( $stored_moods ) )
$return .= '&lt;strong&gt;Current Mood&lt;/strong&gt;: ';
foreach( $stored_moods as $mood )
$return .= $mood . ', ';
$return .= '&lt;br/&gt;';
if ( ! empty( $stored_listening_to ) ) {
$return .= '&lt;strong&gt;Currently Listening To&lt;/strong&gt;: ';
$return .= $stored_listening_to;
}
$return .= '&lt;/div&gt;';
return $return;
default :
return false;
break;
} //end switch
} //end function
?&gt;%%%&lt;/div&gt;
==Resources==
*
==Related==
{{Post Meta Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_category_by_slug" d:title="get category by slug">
<d:index d:value="get category by slug"/>
<h1>get category by slug</h1>
<p>{{Languages|
{{en|Function Reference/get_category_by_slug}}
{{it|Riferimento funzioni/get_category_by_slug}}
{{ja|関数リファレンス/get_category_by_slug}}
}}
== Description ==
Retrieve category object by category slug. Returns false if not found.
== Usage ==
%%%&lt;?php get_category_by_slug( $slug ) ?&gt;%%%
== Parameters ==
{{Parameter|$slug|string|The category slug.}}
== Return Values ==
; (object) : Category data object.
; (boolean) : false if not found
== Examples ==
&lt;pre&gt;&lt;?php
$idObj = get_category_by_slug('category-slug');
$id = $idObj-&gt;term_id;
?&gt;&lt;/pre&gt;
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_term_by|&lt;tt&gt;get_term_by()&lt;/tt&gt;]] to get the category object
* Uses: [[Function_Reference/_make_cat_compat|&lt;tt&gt;_make_cat_compat()&lt;/tt&gt;]] to make category object compatible with WP 2.3.0 and earlier versions.
== Change Log ==
Since: 2.3.0
== Source File ==
&lt;tt&gt;get_category_by_slug()&lt;/tt&gt; is located in {{Trac|wp-includes/category.php}}.
== Related ==
{{Category Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_attachment_is_image" d:title="wp attachment is image">
<d:index d:value="wp attachment is image"/>
<h1>wp attachment is image</h1>
<p>{{Languages|
{{en|Function Reference/wp_attachment_is_image}}
{{it|Riferimento funzioni/wp_attachment_is_image}}
{{ja|関数リファレンス/wp_attachment_is_image}}
}}
==Description==
This function determines if a post's attachment is an image. It returns TRUE if the attachment is an image, FALSE if not. The accepted file extensions/mime types are: .jpg, .jpeg, .gif, .png.
==Usage==
%%% &lt;?php wp_attachment_is_image( $post_id ); ?&gt; %%%
==Parameters==
{{Parameter|$post_id|int|Integer ID of the post.|optional|0}}
== Return Values ==
; (bool) : TRUE if the attachment is an image, FALSE if not.
==Example==
To check if post ID 37's attachment is an image:
&lt;pre&gt;
&lt;?php
$id = 37;
if ( wp_attachment_is_image( $id ) ) {
echo &quot;Post &quot;.$id.&quot; is an image!&quot;;
} else {
echo &quot;Post &quot;.$id.&quot; is not an image.&quot;;
}
?&gt;
&lt;/pre&gt;
==Notes==
* Uses: [[Function_Reference/get_attached_file|&lt;tt&gt;get_attached_file()&lt;/tt&gt;]]
==Change Log==
Since: 2.1.0
==Source File==
&lt;tt&gt;wp_attachment_is_image()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]
[[Category:New page created]]</p>
</d:entry>
<d:entry id="get_page_by_path" d:title="get page by path">
<d:index d:value="get page by path"/>
<h1>get page by path</h1>
<p>== Description ==
Retrieves a page given its path.
== Usage ==
%%%&lt;?php get_page_by_path( $page_path, $output, $post_type ); ?&gt;%%%
== Parameters ==
{{Parameter|$page_path|string|Page path}}
{{Parameter|$output|string|Output type. &lt;tt&gt;OBJECT&lt;/tt&gt;, &lt;tt&gt;ARRAY_N&lt;/tt&gt;, or &lt;tt&gt;ARRAY_A&lt;/tt&gt;.|optional|OBJECT}}
{{Parameter|$post_type|string|Post Type.|optional|page}}
== Return Values ==
; (mixed) : Null when complete.
== Examples ==
=== Page Path ===
This is the equivalent of the '&lt;tt&gt;pagename&lt;/tt&gt;' query, as in: '&lt;tt&gt;index.php?pagename=parent-page/sub-page&lt;/tt&gt;'.
Code for the above could be written as (assuming '&lt;tt&gt;parent-page/sub-page&lt;/tt&gt;' is actually the path to a page):
get_page_by_path('parent-page/sub-page');
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
For non-heirarchical custom post types, you need to use just the slug in tandem with the post_type parameter.
//Returns nothing, assumes animals is the rewrite slug for the animal CPT
get_page_by_path('animals/cat', OBJECT, 'animal');
//Returns the animal with the slug 'cat'
get_page_by_path('cat', OBJECT, 'animal');
The functions basename() and untrailingslashit() are handy for grabbing the last part of the URL for this:
$page_path = 'animals/cat/';
get_page_by_path( basename( untrailingslashit( $page_path ) ) , OBJECT, 'animal');
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_page_by_path()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Page Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="check_comment" d:title="check comment">
<d:index d:value="check comment"/>
<h1>check comment</h1>
<p>{{Languages|
{{en|Function Reference/check_comment}}
{{it|Riferimento funzioni/check_comment}}
}}
{{Copyedit}}
== Description ==
&lt;tt&gt;check_comment()&lt;/tt&gt; checks whether a comment passes internal checks set by WordPress [[Comment_Moderation]].
== Usage ==
%%%&lt;?php
check_comment( $author, $email, $url, $comment, $user_ip,
$user_agent, $comment_type );
?&gt;%%%
== Parameters ==
{{Parameter|$author|string|Comment author name.}}
{{Parameter|$email|string|Comment author email.}}
{{Parameter|$url|string|Comment author URL.}}
{{Parameter|$comment|string|Comment contents.}}
{{Parameter|$user_ip|string|Comment author [[Glossary#IP Address|IP address]].}}
{{Parameter|$user_agent|string|Comment author user agent.}}
{{Parameter|$comment_type|string|Comment type ([[Glossary#Comments|&lt;tt&gt;comment&lt;/tt&gt;]], [[Glossary#Trackback|&lt;tt&gt;trackback&lt;/tt&gt;]], or [[Glossary#Pingback|&lt;tt&gt;pingback&lt;/tt&gt;]]).}}
== Return Values ==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : This function returns a single [http://us2.php.net/manual/en/language.types.boolean.php boolean] value of either &lt;tt&gt;true&lt;/tt&gt; or &lt;tt&gt;false&lt;/tt&gt;.
Returns &lt;tt&gt;false&lt;/tt&gt; if in [[Comment_Moderation]]:
* The Administrator must approve all messages,
* The number of external links is too high, or
* Any banned word, name, URL, e-mail, or IP is found in any parameter except &lt;tt&gt;$comment_type&lt;/tt&gt;.
Returns &lt;tt&gt;true&lt;/tt&gt; if the Administrator does not have to approve all messages and:
* &lt;tt&gt;$comment_type&lt;/tt&gt; parameter is a [[Glossary#Trackback|&lt;tt&gt;trackback&lt;/tt&gt;]] or [[Glossary#Pingback|&lt;tt&gt;pingback&lt;/tt&gt;]] and part of the [[Glossary#Blogroll|blogroll]], or
* &lt;tt&gt;$author&lt;/tt&gt; and &lt;tt&gt;$email&lt;/tt&gt; parameters have been approved previously.
Returns &lt;tt&gt;true&lt;/tt&gt; in all other cases.
== Examples ==
Simple use case
&lt;pre&gt; &lt;?php
$author = &quot;John Charles Smith&quot;;
$email = &quot;jsmith@example.com&quot;;
$url = &quot;http://example.com&quot;;
$comment = &quot;Excellent...&quot;;
$user_ip = &quot;12.34.56.78&quot;;
$user_agent = &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11&quot;;
$comment_type = &quot;comment&quot;;
if (check_comment( $author, $email, $url, $comment, $user_ip, $user_agent, $comment_type )) {
echo &quot;The Comment robot says: Thank you for your comment.&quot;;
} else {
echo &quot;The Comment robot says: This comment is NOT valid!&quot;;
}
?&gt;&lt;/pre&gt;
== Notes ==
* Uses: [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]]
== Change Log ==
* Since: WordPress Version 1.2
&lt;!-- Need to search change logs --&gt;
== Source File ==
&lt;tt&gt;check_comment()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="WordPress_Nonces" d:title="WordPress Nonces">
<d:index d:value="WordPress Nonces"/>
<h1>WordPress Nonces</h1>
<p>{{Languages|
{{en|WordPress Nonces}}
{{fr|Les Nonces WordPress}}
{{ja|WordPress Nonces}}
}}
A ''[[Glossary#Nonce|nonce]]'' is a &quot;number used once&quot; to protect URLs and forms from being misused.
For example, an admin screen might generate a URL like this that trashes post number 123. You can see that the URL contains a nonce at the end:
&lt;nowiki&gt;http://example.com/wp-admin/post.php?post=123&amp;action=trash&amp;_wpnonce=b192fc4204&lt;/nowiki&gt;
If anyone attempts to modify the URL to trash post number 456, the nonce is not valid and the attempt fails:
&lt;nowiki&gt;http://example.com/wp-admin/post.php?post=456&amp;action=trash&amp;_wpnonce=b192fc4204&lt;/nowiki&gt;
The invalid nonce causes WordPress to send a &quot;403 Forbidden&quot; response to the browser, with the error message: &quot;Are you sure you want to do this?&quot;
== Creating a nonce ==
You can create a nonce and add it to the query string in a URL, you can add it in a hidden field in a form, or you can use it some other way.
For nonces that are to be used in AJAX requests, it is common to add the nonce to a hidden field, from where JavaScript code can fetch it.
=== Adding a nonce to a URL ===
To add a nonce to a URL, call [[Function_Reference/wp_nonce_url|wp_nonce_url()]] specifying the bare URL and a string representing the action. For example:
$complete_url = wp_nonce_url( $bare_url, 'trash-post_'.$post-&gt;ID );
For maximum protection, ensure that the string representing the action is as specific as possible.
By default, wp_nonce_url() adds a field named &lt;code&gt;_wpnonce&lt;/code&gt;. You can specify a different name in the function call. For example:
$complete_url = wp_nonce_url( $bare_url, 'trash-post_'.$post-&gt;ID, 'my_nonce' );
=== Adding a nonce to a form ===
To add a nonce to a form, call [[Function_Reference/wp_nonce_field|wp_nonce_field()]] specifying a string representing the action. By default wp_nonce_field() generates two hidden fields, one whose value is the nonce and one whose value is the current URL (the referrer), and it echoes the result. For example, this call:
wp_nonce_field( 'delete-comment_'.$comment_id );
might echo something like:
&lt;input type=&quot;hidden&quot; id=&quot;_wpnonce&quot; name=&quot;_wpnonce&quot; value=&quot;796c7766b1&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;_wp_http_referer&quot; value=&quot;/wp-admin/edit-comments.php&quot; /&gt;
For maximum protection, ensure that the string representing the action is as specific as possible.
You can specify a different name for the nonce field, you can specify that you do not want a referrer field, and you can specify that you want the result to be returned and not echoed. For details of the syntax, see: [[Function_Reference/wp_nonce_field|wp_nonce_field()]]
=== Creating a nonce for use in some other way ===
To create a nonce for use in some other way, call [[Function_Reference/wp_create_nonce|wp_create_nonce()]] specifying a string representing the action. For example:
$nonce = wp_create_nonce( 'my-action_'.$post-&gt;ID );
This simply returns the nonce itself. For example: &lt;code&gt;295a686963&lt;/code&gt;
For maximum protection, ensure that the string representing the action is as specific as possible.
== Verifying a nonce ==
You can verify a nonce that was passed in a URL, a form in an admin screen, an AJAX request, or in some other context.
=== Verifying a nonce passed from an admin screen ===
To verify a nonce that was passed in a URL or a form in an admin screen, call [[Function_Reference/check_admin_referer|check_admin_referer()]] specifying the string representing the action. For example:
check_admin_referer( 'delete-comment_'.$comment_id );
This call checks the nonce and the referrer, and if the check fails it takes the normal action (terminating script execution with a &quot;403 Forbidden&quot; response and an error message).
If you did not use the default field name (&lt;code&gt;_wpnonce&lt;/code&gt;) when you created the nonce, specify the field name. For example:
check_admin_referer( 'delete-comment_'.$comment_id, 'my_nonce' );
=== Verifying a nonce passed in an AJAX request ===
To verify a nonce that was passed in an AJAX request, call [[Function_Reference/check_ajax_referer|check_ajax_referer()]] specifying the string representing the action. For example:
check_ajax_referer( 'process-comment' );
This call checks the nonce (but not the referrer), and if the check fails then by default it terminates script execution.
If you did not use one of the default field names (&lt;code&gt;_wpnonce&lt;/code&gt; or &lt;code&gt;_ajax_nonce&lt;/code&gt;) when you created the nonce, or if you want to take some other action instead of terminating execution, you can specify additional parameters. For details, see: [[Function_Reference/check_ajax_referer|check_ajax_referer()]]
=== Verifying a nonce passed in some other context ===
To verify a nonce passed in some other context, call [[Function_Reference/wp_verify_nonce|wp_verify_nonce()]] specifying the nonce and the string representing the action. For example:
wp_verify_nonce( $_REQUEST['my_nonce'], 'process-comment'.$comment_id );
If the result is false, do not continue processing the request. Instead take some appropriate action. The usual action is to call [[Function_Reference/wp_nonce_ays|wp_nonce_ays()]], which sends a &quot;403 Forbidden&quot; response to the browser with the error message: &quot;Are you sure you want to do this?&quot;.
== Modifying the nonce system ==
You can modify the nonce system by adding various [[Plugin_API#Actions|actions]] and [[Plugin_API#Filters|filters]].
=== Modifying the nonce lifetime ===
By default, a nonce has a lifetime of one day. After that, the nonce is no longer valid even if it matches the action string. To change the lifetime, add a &lt;code&gt;nonce_life&lt;/code&gt; filter specifying the lifetime in seconds. For example, to change the lifetime to four hours:
add_filter( 'nonce_life', function () { return 4 * HOUR_IN_SECONDS; } );
=== Performing additional verification ===
To perform additional verification when check_admin_referrer() has found that the nonce and the referrer are valid, add a &lt;code&gt;check_admin_referer&lt;/code&gt; action. For example:
function my_additional_check ( $action, $result ) { ... }
add_action( 'check_admin_referrer', 'my_additional_check', 10, 2 );
For check_ajax_referer() add a &lt;code&gt;check_ajax_referer&lt;/code&gt; action in the same way.
=== Changing the error message ===
You can change the error message sent when a nonce is not valid, by using the translation system. For example:
function my_nonce_message ($translation) {
if ($translation == 'Are you sure you want to do this?')
return 'No! No! No!';
else
return $translation;
}
add_filter('gettext', 'my_nonce_message');
== Additional information ==
This section contains additional information about the nonce system in Wordpress that might occasionally be useful.
=== Nonce lifetime ===
The lifetime of a nonce is divided into two ''ticks''. When a nonce is valid, the functions that validate nonces return the current tick number, 1 or 2. You could use this information, for example, to refresh nonces that are in their second tick so that they do not expire.
=== Nonce security ===
Nonces are generated using a key and salt that are unique to your site if you have installed WordPress correctly. NONCE_KEY and NONCE_SALT are defined in your [[Editing_wp-config.php|wp-config.php]] file, and the file contains comments that provide more information.
== Replacing the nonce system ==
Some of the functions that make up the nonce system are [[Pluggable_Functions|pluggable]], so that you can replace them by supplying your own functions.
To change the way admin requests or AJAX requests are verified, you can replace check_admin_referrer() or check_ajax_referrer(), or both.
To replace the nonce system with some other nonce system, you can replace wp_create_nonce(), wp_verify_nonce() and wp_nonce_tick().
== Related ==
{{Nonces}}
* [[Creating Options Pages]]
* [[Plugin API/Filter Reference]]
* [[Plugin API/Action Reference]]
== Resources ==
* [http://markjaquith.wordpress.com/2006/06/02/wordpress-203-nonces/ WordPress 2.0.3: Nonces | Mark on WordPress]
* [http://www.prelovac.com/vladimir/improving-security-in-wordpress-plugins-using-nonces Improving security in Wordpress plugins using Nonces | Prelovac.com]
* [[Wikipedia:Cryptographic_nonce|Cryptographic nonce - Wikipedia, the free encyclopedia]]
* [[Wikipedia:Cross-site_request_forgery|Cross-site request forgery - Wikipedia, the free encyclopedia]]
*[http://www.wp-entwickler.at/wordpress-sicherheit-bei-formulareingaben-und-ajax-aufrufen-verwendet-nonces/ Einf&uuml;hrung zu Nonces und deren Verwendung] '''Artikel auf Deutsch'''
[[Category:Advanced_Topics]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_register_sidebar_widget" d:title="wp register sidebar widget">
<d:index d:value="wp register sidebar widget"/>
<h1>wp register sidebar widget</h1>
<p>== Description ==
Register [[WordPress Widgets]] for use in your themes [[Sidebars|sidebars]]. You can also modify your theme and start [[Customizing Your Sidebar]].
== Usage ==
%%%&lt;?php
wp_register_sidebar_widget(
$id,
$name,
$output_callback,
$options,
$params,
...
);
?&gt; %%%
== Parameters ==
{{Parameter|$id|int/string|Widget ID.}}
{{Parameter|$name|string|Widget display title.}}
{{Parameter|$output_callback|callback|Run when widget is called.}}
{{Parameter|$options|array/string|Widget Options.|optional}}
{{Parameter|$params,...|mixed|Widget parameters to add to widget.|optional}}
== Output Callback Function Parameters Format ==
&lt;tt&gt;function my_output_callback_function( $args, $params ){ ... }&lt;/tt&gt;
{{Parameter|$args|array|Various values merged into an array}}
{{Parameter|$params|array|The extra &lt;tt&gt;$params&lt;/tt&gt; given to &lt;tt&gt;wp_register_sidebar_widget&lt;/tt&gt;, as an array}}
&lt;b&gt;&lt;tt&gt;$args&lt;/tt&gt;&lt;/b&gt; array contains:
* [[Function Reference/register sidebars|register_sidebars()]] argument array values (&lt;tt&gt;'before_widget'&lt;/tt&gt;, etc.)
* &lt;tt&gt;'widget_id'&lt;/tt&gt;
* &lt;tt&gt;'widget_name'&lt;/tt&gt;
The &lt;tt&gt;'dynamic_sidebar_params'&lt;/tt&gt; filter is applied to the parameters (as an array), before your output function is called back.
== Example ==
The following code will create a widget called &quot;Your Widget&quot; which will become available in the WordPress Administrative Panels. The widget can then be dragged to an available sidebar for display.
''Note that this widget can only be used once in exactly 1 of the sidebars. For recursive widgets (widgets you can add to multiple times and add to multiple sidebars) please see the [[Function_Reference/register_widget|Register Widget]] function.''
&lt;pre&gt;
&lt;?php
function your_widget_display($args) {
extract($args);
echo $before_widget;
echo $before_title . 'My Unique Widget' . $after_title;
echo $after_widget;
// print some HTML for the widget to display here
echo &quot;Your Widget Test&quot;;
}
wp_register_sidebar_widget(
'your_widget_1', // your unique widget id
'Your Widget', // widget name
'your_widget_display', // callback function
array( // options
'description' =&gt; 'Description of what your widget does'
)
);
?&gt;
&lt;/pre&gt;
== Change Log ==
Since: 2.2.0
== Source File ==
&lt;tt&gt;wp_register_sidebar_widget()&lt;/tt&gt; is located in {{Trac|wp-includes/widgets.php}}.
== Related ==
{{Sidebar Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:Widgets]]</p>
</d:entry>
<d:entry id="get_post_mime_type" d:title="get post mime type">
<d:index d:value="get post mime type"/>
<h1>get post mime type</h1>
<p>{{Languages|
{{en|Function Reference/get post mime type}}
{{ru|Справочник_по_функциям/get_post_mime_type}}
{{ja|関数リファレンス/get post mime type}}
}}
== Description ==
Retrieve the mime type of an attachment based on the ID.
This function can be used with any [[Post Type]], but it makes more sense with [[Attachments]].
== Usage ==
%%%&lt;?php get_post_mime_type( $ID ) ?&gt;%%%
== Parameters ==
{{Parameter|$ID|integer|Post ID.|optional|&amp;#39;&amp;#39;}}
== Return Values ==
{{Return|Mime Type|boolean&amp;#124;string|False on failure or returns the mime type.}}
== Examples ==
===Return an icon image path according to the MIME type of the given post===
&lt;pre&gt;
function get_icon_for_attachment($post_id) {
$base = get_template_directory_uri() . &quot;/images/icons/&quot;;
$type = get_post_mime_type($post_id);
switch ($type) {
case 'image/jpeg':
case 'image/png':
case 'image/gif':
return $base . &quot;image.png&quot;; break;
case 'video/mpeg':
case 'video/mp4':
case 'video/quicktime':
return $base . &quot;video.png&quot;; break;
case 'text/csv':
case 'text/plain':
case 'text/xml':
return $base . &quot;text.png&quot;; break;
default:
return $base . &quot;file.png&quot;;
}
}
// call it like this:
echo '&lt;img src=&quot;'.get_icon_for_attachment($my_attachment-&gt;ID).'&quot; /&gt;';
&lt;/pre&gt;
== Notes ==
WordPress already has a function to get the mime type icon called wp_mime_type_icon http://codex.wordpress.org/Function_Reference/wp_mime_type_icon
== Change Log ==
* Since: [[Version 2.0|2.0.0]]
== Source File ==
&lt;tt&gt;get_post_mime_type()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_post_type" d:title="get post type">
<d:index d:value="get post type"/>
<h1>get post type</h1>
<p>{{Languages|
{{en|Function Reference/get post type}}
{{it|Riferimento_funzioni/get_post_type}}
{{ja|関数リファレンス/get post type}}
{{ru|Справочник_по_функциям/get_post_type}}
}}
== Description ==
Retrieve the post type of the current post or of a given post.
== Usage ==
%%%&lt;?php echo get_post_type( $post ) ?&gt;%%%
== Parameters ==
{{Parameter|$post|mixed|Post object or post ID. If empty, the current post will be used.|optional|&lt;tt&gt;null&lt;/tt&gt;}}
== Return Values ==
; &lt;tt&gt;(boolean&amp;#124;string)&lt;/tt&gt; : post type or &lt;tt&gt;false&lt;/tt&gt; on failure.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
Display the post type. This example needs to be inside the loop.
&lt;pre&gt;
&lt;?php echo 'The post type is: ' . get_post_type( get_the_ID() ); ?&gt;
&lt;/pre&gt;
== Notes ==
* Uses: &lt;tt&gt;[[Function_Reference/get_post | get_post()]]&lt;/tt&gt; To retrieve the post.
== Change Log ==
* [[Version 3.5 | 3.5.0]]: The default for &lt;tt&gt;$post&lt;/tt&gt; is now &lt;tt&gt;null&lt;/tt&gt; instead of &lt;tt&gt;false&lt;/tt&gt;, and &lt;tt&gt;[[Function_Reference/get_post | get_post()]]&lt;/tt&gt; is used instead of directly accessing the global &lt;tt&gt;$post&lt;/tt&gt; variable.
* Since: [[Version 2.1|2.1.0]]
== Source File ==
&lt;tt&gt;get_post_type()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Post Type Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_extended" d:title="get extended">
<d:index d:value="get extended"/>
<h1>get extended</h1>
<p>{{Languages|
{{en|Function Reference/get_extended}}
{{it|Riferimento funzioni/get_extended}}
{{ja|関数リファレンス/get_extended}}
{{ru|Справочник_по_функциям/get_extended}}
}}
{{Stub}}
== Description ==
Get extended entry info (&lt;tt&gt;&lt;nowiki&gt;&lt;!--more--&gt;&lt;/nowiki&gt;&lt;/tt&gt;).
There should not be any space after the second dash and before the word 'more'. There can be text or space(s) after the word 'more', but won't be referenced.
The returned array has &lt;tt&gt;'main'&lt;/tt&gt; and &lt;tt&gt;'extended'&lt;/tt&gt; keys. Main has the text before the &lt;tt&gt;&lt;nowiki&gt;&lt;!--more--&gt;&lt;/nowiki&gt;&lt;/tt&gt;. The &lt;tt&gt;'extended'&lt;/tt&gt; key has the content after the &lt;tt&gt;&lt;nowiki&gt;&lt;!--more--&gt;&lt;/nowiki&gt;&lt;/tt&gt; comment.
== Usage ==
%%%&lt;?php get_extended( $post_content ) ?&gt;%%%
== Parameters ==
{{Parameter|$post_content|string|Post content.}}
== Return Values ==
; &lt;tt&gt;(array)&lt;/tt&gt; : Post before (&lt;tt&gt;'main'&lt;/tt&gt;) and after (&lt;tt&gt;'extended'&lt;/tt&gt;).
== Examples ==
=== Displaying small excerpts from latest posts. ===
If you want to display the latest posts on your WordPress blog, but only the content which comes before the &lt;tt&gt;&lt;nowiki&gt;&lt;!--more--&gt;&lt;/nowiki&gt;&lt;/tt&gt; tag, you can use this:
&lt;pre&gt;
&lt;ul&gt;
&lt;?php
global $post;
$args = array( 'numberposts' =&gt; 5 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata( $post );
$content_arr = get_extended (get_the_content() ); ?&gt;
&lt;li&gt;
&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
&lt;/br&gt;
&lt;?php echo $content_arr['main']; //Display the part before the more tag ?&gt;
&lt;/li&gt;
&lt;?php endforeach; ?&gt;
&lt;/ul&gt;
&lt;/pre&gt;
'''Note:''' ''&lt;tt&gt;$content_arr['extended']&lt;/tt&gt; contains the contents after the more tag.''
== Notes ==
== Change Log ==
Since: [[Version 1.0|1.0.0]]
== Source File ==
&lt;tt&gt;get_extended()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
* &lt;tt&gt;[[Function_Reference/the_excerpt | the_excerpt()]]&lt;/tt&gt; - Retrieve the excerpt for the current post in the loop.
* &lt;tt&gt;[[Function_Reference/get_the_excerpt | get_the_excerpt()]]&lt;/tt&gt; - Get the excerpt for a post.
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_publish_post" d:title="wp publish post">
<d:index d:value="wp publish post"/>
<h1>wp publish post</h1>
<p>{{Languages|
{{en|Function Reference/wp publish post}}
{{ja|関数リファレンス/wp publish post}}
}}
== Description ==
Publish a post by transitioning the post status.
'''Note:''' This function does not do anything except transition the post status. If you want to ensure &lt;tt&gt;post_name&lt;/tt&gt; is set, use [[Function_Reference/wp_update_post|&lt;tt&gt;wp_update_post()&lt;/tt&gt;]] instead.
== Usage ==
%%%&lt;?php wp_publish_post( $post_id ) ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|Post ID.}}
== Return Values ==
; &lt;tt&gt;(null)&lt;/tt&gt; :
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] to initiate the following action hooks, passing &lt;tt&gt;$post-&gt;ID&lt;/tt&gt; and &lt;tt&gt;$post&lt;/tt&gt; (post data) parameters:
** 'edit_post'
** [[Plugin_API/Action_Reference/save_post|&lt;tt&gt;'save_post'&lt;/tt&gt;]]
** [[Plugin_API/Action_Reference/wp_insert_post|&lt;tt&gt;'wp_insert_post'&lt;/tt&gt;]]
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_publish_post()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
[http://alexking.org/blog/2011/09/19/wp_publish_post-does-not-set-post_ Alex King's post on &lt;tt&gt;wp_publish_post()&lt;/tt&gt; vs &lt;tt&gt;wp_update_post()&lt;/tt&gt;]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_all_page_ids" d:title="get all page ids">
<d:index d:value="get all page ids"/>
<h1>get all page ids</h1>
<p>{{Languages|
{{en|Function Reference/get_all_page_ids}}
{{it|Riferimento funzioni/get_all_page_ids}}
}}
== Description ==
Get a list of page IDs.
== Usage ==
%%%&lt;?php get_all_page_ids() ?&gt;%%%
== Parameters ==
* None
== Return Values ==
; &lt;tt&gt;(array)&lt;/tt&gt; : List of page IDs.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_all_page_ids()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Page Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_page_uri" d:title="get page uri">
<d:index d:value="get page uri"/>
<h1>get page uri</h1>
<p>== Description ==
Builds and returns a URI for a page from a page id.
If the page has parents, those are prepended to the URI to provide a full path. For example, a third level page might return a URI like this:
&lt;pre&gt;top-level-page/sub-page/current-page&lt;/pre&gt;
== Usage ==
%%%&lt;?php get_page_uri( $page_id ) ?&gt;%%%
== Parameters ==
{{Parameter|$page_id|integer|Page ID.}}
== Return Values ==
; &lt;tt&gt;(string)&lt;/tt&gt; : Page URI.
== Examples ==
&lt;pre&gt;
&lt;?php
$page_id = 5;
$uri = get_page_uri($page_id);
echo '&lt;a href=&quot;'. $uri .'&quot;&gt;The Page&lt;/a&gt;';
?&gt;
&lt;/pre&gt;
== Notes ==
This function will return a &quot;slug&quot; style URI regardless of whether [[Using_Permalinks#Using_.22Pretty.22_permalinks|&quot;pretty&quot; Permalinks]] are configured.
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_page_uri()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Page Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_attached_file" d:title="get attached file">
<d:index d:value="get attached file"/>
<h1>get attached file</h1>
<p>== Description ==
Retrieve attached file path based on attachment ID.
You can optionally send it through the 'get_attached_file' filter, but by default it will just return the file path unfiltered.
The function works by getting the single post meta name, named '&lt;tt&gt;_wp_attached_file&lt;/tt&gt;' and returning it. This is a convenience function to prevent looking up the meta name and provide a mechanism for sending the attached file name through a filter.
== Usage ==
%%%&lt;?php get_attached_file( $attachment_id, $unfiltered ); ?&gt;%%%
== Parameters ==
{{Parameter|$attachment_id|integer|Attachment ID.}}
{{Parameter|$unfiltered|boolean|Whether to apply filters or not.|optional|false}}
== Return Values ==
; &lt;tt&gt;(string)&lt;/tt&gt; : The file path to the attached file.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] to call [[Function_Reference/get_attached_file|&lt;tt&gt;get_attached_file()&lt;/tt&gt;]] on file path and &lt;tt&gt;$attachment_id&lt;/tt&gt;.
* Uses: [[Function_Reference/get_post_meta|&lt;tt&gt;get_post_meta()&lt;/tt&gt;]] on &lt;tt&gt;$attachment_id&lt;/tt&gt;, the '&lt;tt&gt;_wp_attached_file&lt;/tt&gt;' meta name.
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;tt&gt;get_attached_file()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="update_attached_file" d:title="update attached file">
<d:index d:value="update attached file"/>
<h1>update attached file</h1>
<p>== Description ==
Update attachment file path based on attachment ID.
Used to update the file path of the attachment, which uses post meta name '&lt;tt&gt;_wp_attached_file&lt;/tt&gt;' to store the path of the attachment.
Note: This does not move the file. This simply updates the '&lt;tt&gt;_wp_attached_file&lt;/tt&gt;' post meta after a move.
== Usage ==
%%%&lt;?php update_attached_file( $attachment_id, $file ) ?&gt;%%%
== Parameters ==
{{Parameter|$attachment_id|integer|Attachment ID}}
{{Parameter|$file|string|File path for the attachment}}
== Return Values ==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : False on failure, true on success.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] to add &lt;tt&gt;update_attached_file()&lt;/tt&gt; on &lt;tt&gt;$file&lt;/tt&gt; and &lt;tt&gt;$attachment_id&lt;/tt&gt;.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;update_attached_file()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php|tags/3.4.2|189}}
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="is_local_attachment" d:title="is local attachment">
<d:index d:value="is local attachment"/>
<h1>is local attachment</h1>
<p>{{Languages|
{{en|Function Reference/is_local_attachment}}
{{it|Riferimento funzioni/is_local_attachment}}
}}
== Description ==
Check if the attachment URI is local one and is really an attachment.
== Usage ==
%%%&lt;?php is_local_attachment( $url ) ?&gt;%%%
== Parameters ==
{{Parameter|$url|string|URL to check}}
== Return Values ==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_local_attachment()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_get_attachment_metadata" d:title="wp get attachment metadata">
<d:index d:value="wp get attachment metadata"/>
<h1>wp get attachment metadata</h1>
<p>{{Languages|
{{en|Function Reference/wp_get_attachment_metadata}}
{{it|Riferimento funzioni/wp_get_attachment_metadata}}
}}
== Description ==
Retrieve attachment meta field for attachment ID.
== Usage ==
%%%&lt;?php wp_get_attachment_metadata( $attachment_id, $unfiltered ); ?&gt;%%%
== Parameters ==
{{Parameter|$attachment_id|integer|Attachment ID}}
{{Parameter|$unfiltered|boolean|If true, filters are not run.|optional|false}}
== Return Values ==
{{Return||array&amp;#124;boolean|Attachment meta field. False on failure.}}
The fields are:
; &lt;tt&gt;width&lt;/tt&gt; : (''integer'') The width of the attachment
; &lt;tt&gt;height&lt;/tt&gt; : (''integer'') The height of the attachment
; &lt;tt&gt;file&lt;/tt&gt; : (''string'') The file path relative to `wp-content/uploads/`
; &lt;tt&gt;sizes&lt;/tt&gt; : (''array'') Keys are size slugs, each value is an array containing 'file', 'width', 'height', and 'mime-type'
; &lt;tt&gt;image_meta&lt;/tt&gt; : (''array'')
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
Array
(
[width] =&gt; 2400
[height] =&gt; 1559
[file] =&gt; 2011/12/press_image.jpg
[sizes] =&gt; Array
(
[thumbnail] =&gt; Array
(
[file] =&gt; press_image-150x150.jpg
[width] =&gt; 150
[height] =&gt; 150
[mime-type] =&gt; image/jpeg
)
[medium] =&gt; Array
(
[file] =&gt; press_image-4-300x194.jpg
[width] =&gt; 300
[height] =&gt; 194
[mime-type] =&gt; image/jpeg
)
[large] =&gt; Array
(
[file] =&gt; press_image-1024x665.jpg
[width] =&gt; 1024
[height] =&gt; 665
[mime-type] =&gt; image/jpeg
)
[post-thumbnail] =&gt; Array
(
[file] =&gt; press_image-624x405.jpg
[width] =&gt; 624
[height] =&gt; 405
[mime-type] =&gt; image/jpeg
)
)
[image_meta] =&gt; Array
(
[aperture] =&gt; 5
[credit] =&gt;
[camera] =&gt; Canon EOS-1Ds Mark III
[caption] =&gt;
[created_timestamp] =&gt; 1323190643
[copyright] =&gt;
[focal_length] =&gt; 35
[iso] =&gt; 800
[shutter_speed] =&gt; 0.016666666666667
[title] =&gt;
)
)
== Notes ==
== Change Log ==
Since: [[Version 2.1|2.1.0]]
== Source File ==
&lt;tt&gt;wp_get_attachment_metadata()&lt;/tt&gt; is located in {{Source|wp-includes/post.php}}
== Related ==
{{Attachment Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_update_attachment_metadata" d:title="wp update attachment metadata">
<d:index d:value="wp update attachment metadata"/>
<h1>wp update attachment metadata</h1>
<p>{{Languages|
{{en|Function Reference/wp_update_attachment_metadata}}
{{it|Riferimento funzioni/wp_update_attachment_metadata}}
}}
== Description ==
Update metadata for an attachment.
== Usage ==
%%%&lt;?php wp_update_attachment_metadata( $post_id, $data ); ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|Attachment ID.}}
{{Parameter|$data|array|Attachment data.}}
== Return Values ==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : Returns value from [[Function_Reference/update_post_meta|&lt;tt&gt;update_post_meta()&lt;/tt&gt;]]
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] to add &lt;tt&gt;wp_update_attachment_metadata()&lt;/tt&gt; on &lt;tt&gt;$data&lt;/tt&gt; and post ID.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_update_attachment_metadata()&lt;/tt&gt; is located in &lt;tt&gt;[http://core.trac.wordpress.org/browser/trunk/wp-includes/post.php wp-includes/post.php]&lt;/tt&gt;.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_get_attachment_thumb_file" d:title="wp get attachment thumb file">
<d:index d:value="wp get attachment thumb file"/>
<h1>wp get attachment thumb file</h1>
<p>{{Languages|
{{en|Function Reference/wp_get_attachment_thumb_file}}
{{it|Riferimento funzioni/wp_get_attachment_thumb_file}}
}}
== Description ==
Retrieve thumbnail for an attachment.
== Usage ==
%%%&lt;?php wp_get_attachment_thumb_file( $post_id ); ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|Attachment ID.|optional|0}}
== Return Values ==
; &lt;tt&gt;(mixed)&lt;/tt&gt; : False on failure. Thumbnail file path on success.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;wp_get_attachment_thumb_file()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Attachment Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_get_attachment_thumb_url" d:title="wp get attachment thumb url">
<d:index d:value="wp get attachment thumb url"/>
<h1>wp get attachment thumb url</h1>
<p>{{Languages|
{{en|Function Reference/wp_get_attachment_thumb_url}}
{{it|Riferimento funzioni/wp_get_attachment_thumb_url}}
}}
== Description ==
Retrieve URL for an attachment thumbnail.
== Usage ==
%%%&lt;?php wp_get_attachment_thumb_url( $attachment_id ); ?&gt;%%%
== Parameters ==
{{Parameter|$attachment_id|integer|Attachment ID|optional|0}}
== Return Values ==
{{Return||string&amp;#124;boolean|False on failure. Thumbnail URL on success.}}
== Examples ==
&lt;pre&gt;
&lt;?php
$thumb_id = 25;
$url = wp_get_attachment_thumb_url( $thumb_id );
?&gt;
&lt;img src=&quot;&lt;?php echo $url ?&gt;&quot;/&gt;
&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;wp_get_attachment_thumb_url()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Attachment Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_mime_type_icon" d:title="wp mime type icon">
<d:index d:value="wp mime type icon"/>
<h1>wp mime type icon</h1>
<p>{{Languages|
{{en|Function Reference/wp_mime_type_icon}}
{{it|Riferimento funzioni/wp_mime_type_icon}}
}}
== Description ==
Retrieve the icon for a [[wikipedia:MIME|MIME type]].
== Usage ==
%%%&lt;?php wp_mime_type_icon( $mime ) ?&gt;%%%
== Parameters ==
{{Parameter|$mime|string|MIME type|optional|0}}
== Return Values ==
; &lt;tt&gt;(string&amp;#124;boolean)&lt;/tt&gt; : Returns a value from The filtered value after all hooked functions are applied to it.
== Examples ==
=== Display the icon image of the video format ===
&lt;pre&gt;
&lt;?php
$img = wp_mime_type_icon('video/mp4');
?&gt;
&lt;img src=&quot;&lt;?php echo $img ?&gt;&quot; /&gt;
&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters&lt;/tt&gt;]] calls '&lt;tt&gt;wp_mime_type_icon&lt;/tt&gt;' on &lt;tt&gt;$icon&lt;/tt&gt;, &lt;tt&gt;$mime&lt;/tt&gt; and &lt;tt&gt;$post_id&lt;/tt&gt;
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_mime_type_icon()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_check_for_changed_slugs" d:title="wp check for changed slugs">
<d:index d:value="wp check for changed slugs"/>
<h1>wp check for changed slugs</h1>
<p>== Description ==
Checked for changed slugs for published posts and save old slug.
The function is used along with form POST data. It checks for the wp-old-slug POST field. Will only be concerned with published posts and the slug actually changing.
If the slug was changed and not already part of the old slugs then it will be added to the post meta field ('&lt;tt&gt;_wp_old_slug&lt;/tt&gt;') for storing old slugs for that post.
The most logical usage of this function is redirecting changed posts, so that those that linked to an changed post will be redirected to the new post.
== Usage ==
%%%&lt;?php wp_check_for_changed_slugs( $post_id ); ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|Post ID.}}
== Return Values ==
; &lt;tt&gt;(integer)&lt;/tt&gt; : Same as &lt;tt&gt;$post_id&lt;/tt&gt;
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: May use [[Function_Reference/add_post_meta|&lt;tt&gt;add_post_meta()&lt;/tt&gt;]] or [[Function_Reference/delete_post_meta|&lt;tt&gt;delete_post_meta()&lt;/tt&gt;]] depending on current post data ([[Function_Reference/get_post_meta|&lt;tt&gt;get_post_meta()&lt;/tt&gt;]]).
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;wp_check_for_changed_slugs()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_get_post_categories" d:title="wp get post categories">
<d:index d:value="wp get post categories"/>
<h1>wp get post categories</h1>
<p>{{Languages|
{{en|Function Reference/wp_get_post_categories}}
{{it|Riferimento funzioni/wp_get_post_categories}}
{{ja|関数リファレンス/wp_get_post_categories}}
}}
== Description ==
The function wp_get_post_categories() retrieve a list of categories for a post.
Compatibility layer for [[Glossary#Theme|themes]] and [[Glossary#Plugin|plugins]]. Also an easy layer of abstraction away from the complexity of the [[WordPress_Taxonomy|taxonomy layer]].
== Usage ==
%%%&lt;?php wp_get_post_categories( $post_id, $args ); ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|The Post ID.|optional|0}}
{{Parameter|$args|array|Overwrite the defaults.|optional|array|}}
Default $args are:
$defaults = array('fields' =&gt; 'ids');
== Return Values ==
; &lt;tt&gt;(array)&lt;/tt&gt; : The array contains a list of category ID's.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
The example below shows how categories are retrieved, and then additional information is retrieved for each category.
&lt;pre&gt;
$post_categories = wp_get_post_categories( $post_id );
$cats = array();
foreach($post_categories as $c){
$cat = get_category( $c );
$cats[] = array( 'name' =&gt; $cat-&gt;name, 'slug' =&gt; $cat-&gt;slug );
}
&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/wp_get_object_terms|&lt;tt&gt;wp_get_object_terms()&lt;/tt&gt;]] Retrieves the categories.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_get_post_categories()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_set_post_categories" d:title="wp set post categories">
<d:index d:value="wp set post categories"/>
<h1>wp set post categories</h1>
<p>{{Languages|
{{en|Function Reference/wp_set_post_categories}}
{{ja|関数リファレンス/wp_set_post_categories}}
}}
== Description ==
Set categories for a post.
== Usage ==
%%%&lt;?php wp_set_post_categories( $post_ID, $post_categories, $append ) ?&gt;%%%
== Parameters ==
{{Parameter|$post_ID|integer|Post ID.|optional|0}}
{{Parameter|$post_categories|array|Array of category IDs.|optional|array}}
{{Parameter|$append|boolean|If true, categories will be appended to the post. If false, categories will replace existing categories.|optional|false}}
== Return Values ==
; &lt;tt&gt;(boolean&amp;#124;mixed)&lt;/tt&gt;: Returns an array of category IDs that were assigned to the post ID.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
If no categories are passed with a post ID that has a post type of '''post''', the default category will be used.
'''Be careful''', as &lt;tt&gt;wp_set_post_categories&lt;/tt&gt; will overwrite any existing categories already assigned to the post unless &lt;tt&gt;$append&lt;/tt&gt; is set to true.
If an ID is passed with the categories array that is '''not''' associated with a valid category, it will be stripped before the object terms are updated and from the return array.
[[Function Reference/wp_set_object_terms|wp_set_object_terms()]] performs the same function with more granular control for built in categories and can also be used to set any custom taxonomies.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_set_post_categories()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
* [[Function Reference/wp_set_object_terms|wp_set_object_terms()]]
* [[Function Reference/wp_set_post_tags|wp_set_post_tags()]]
* [[Function Reference/wp_set_post_terms|wp_set_post_terms()]]
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
{{Copyedit}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_profile" d:title="get profile">
<d:index d:value="get profile"/>
<h1>get profile</h1>
<p>{{Deprecated|new_function=get_the_author_meta}}
== Description ==
Retrieve user data based on field.
Use &lt;tt&gt;get_profile()&lt;/tt&gt; will make a database query to get the value of the table column. The value might be cached using the query cache, but care should be taken when using the function to not make a lot of queries for retrieving user profile information.
If the &lt;tt&gt;$user&lt;/tt&gt; parameter is not used, then the user will be retrieved from a cookie of the user. Therefore, if the cookie does not exist, then no value might be returned. Sanity checking must be done to ensure that when using &lt;tt&gt;get_profile()&lt;/tt&gt; that (&lt;tt&gt;empty|null|false&lt;/tt&gt;) values are handled and that something is at least displayed.
== Usage ==
%%%&lt;?php get_profile( $field, $user ); ?&gt;%%%
== Parameters ==
{{Parameter|$field|string|User field to retrieve. See [[Database_Description#Table:_wp_users|users table]] for possible &lt;tt&gt;$field&lt;/tt&gt; values.}}
{{Parameter|$user|string|User username. Uses [[WordPress_Cookies|user cookie]] to determine user if this is false or omitted.|optional|false}}
== Return Values ==
; &lt;tt&gt;(string)&lt;/tt&gt; : The value in the field.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] Reads from the [[Database_Description#Table:_wp_users|users table]].
== Change Log ==
* Deprecated: 3.0
* Since: 1.5.0
== Source File ==
&lt;tt&gt;get_profile()&lt;/tt&gt; is located in {{Trac|wp-includes/user.php|tags/2.9.2}} - (2.9.2)&lt;br /&gt;&lt;tt&gt;get_profile()&lt;/tt&gt; is located in {{Trac|wp-includes/deprecated.php|branches/3.0}} - (Deprecated, 3.0)
== Related ==
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="set_current_user" d:title="set current user">
<d:index d:value="set current user"/>
<h1>set current user</h1>
<p>{{Deprecated|new_function=wp_set_current_user|version=3.0}}
== Description ==
This function can be replaced via [[Glossary#plugins|plugins]]. If plugins do not redefine these functions, then this will be used instead.
Changes the current user by ID or name.
Set &lt;tt&gt;$id&lt;/tt&gt; to null and specify a name if you do not know a user's ID.
== Usage ==
%%%&lt;?php set_current_user( $id, $name ) ?&gt;%%%
== Parameters ==
{{Parameter|$id|integer&amp;#124;null|User ID.}}
{{Parameter|$name|string|The user's username|optional|&amp;#39;&amp;#39;}}
== Return Values ==
; &lt;tt&gt;(object)&lt;/tt&gt; : returns values returned by [[Function_Reference/wp_set_current_user|&lt;tt&gt;wp_set_current_user()&lt;/tt&gt;]]
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* This function can be replaced via [[Glossary#plugins|plugins]]. If plugins do not redefine these functions, then this will be used instead.
* Uses: [[Function_Reference/wp_set_current_user|&lt;tt&gt;wp_set_current_user()&lt;/tt&gt;]]
== Change Log ==
* Deprecated: [[Version 3.0|3.0.0]]
* Since: [[Version 2.0.1|2.0.1]]
== Source File ==
&lt;tt&gt;set_current_user()&lt;/tt&gt; is located in {{Trac|wp-includes/pluggable-deprecated.php}}. Before deprecation it was located in {{Trac|wp-includes/pluggable.php}}.
== Related ==
{{Current User Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_set_current_user" d:title="wp set current user">
<d:index d:value="wp set current user"/>
<h1>wp set current user</h1>
<p>== Description ==
This function can be replaced via [[Glossary#plugins|plugins]]. If plugins do not redefine these functions, then this will be used instead.
Changes the current user by ID or name.
Set &lt;tt&gt;$id&lt;/tt&gt; to null and specify a name if you do not know a user's ID.
Some WordPress functionality is based on the current user and not based on the signed in user. &lt;tt&gt;wp_set_current_user()&lt;/tt&gt; opens the ability to edit and perform actions on users who aren't signed in.
== Usage ==
%%%&lt;?php wp_set_current_user( $id, $name ); ?&gt;%%%
== Parameters ==
{{Parameter|$id|integer|User ID}}
{{Parameter|$name|string|User's username|optional|&amp;#39;&amp;#39;}}
=== Return Values ===
{{Return|WP_User|object|[[Class_Reference/WP_User|WP_User]] object with the current user}}.
== Examples ==
Note that setting the current user does not log in that user. This example will set the current user and log them in.
%%%$user_id = 12345;
$user = get_user_by( 'id', $user_id );
if( $user ) {
wp_set_current_user( $user_id, $user-&gt;user_login );
wp_set_auth_cookie( $user_id );
do_action( 'wp_login', $user-&gt;user_login );
}%%%
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* This function can be replaced via [[Glossary#plugins|plugins]]. If plugins do not redefine these functions, then this will be used instead.
* Uses: [[Class_Reference/WP_User|&lt;tt&gt;WP_User&lt;/tt&gt;]] object
* Uses: [[Function_Reference/setup_userdata|&lt;tt&gt;setup_userdata()&lt;/tt&gt;]]
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] Calls 'set_current_user' hook after setting the current user.
== Change Log ==
Since: 2.0.4
== Source File ==
&lt;tt&gt;wp_set_current_user()&lt;/tt&gt; is located in {{Trac|wp-includes/pluggable.php}}.
== Related ==
{{Current User Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_userdatabylogin" d:title="get userdatabylogin">
<d:index d:value="get userdatabylogin"/>
<h1>get userdatabylogin</h1>
<p>{{Pluggable_Deprecated|new_function=get_user_by}}
Use [[Function_Reference/get_user_by|get_user_by( 'login', $user_login )]] instead.
== Description ==
This function can be replaced via [[Glossary#plugins|plugins]]. If plugins do not redefine these functions, then this will be used instead.
Retrieve user info by login name.
== Usage ==
%%%&lt;?php get_userdatabylogin( $user_login ) ?&gt;%%%
== Parameters ==
{{Parameter|$user_login|string|User's username}}
== Return Values ==
; &lt;tt&gt;(boolean&amp;#124;object)&lt;/tt&gt; : False on failure. User DB row object on success.
== Notes ==
* This function can be replaced via [[Glossary#plugins|plugins]]. If plugins do not redefine these functions, then this will be used instead.
== Change Log ==
Since: 0.71. Deprecated since: 3.3.
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_userdatabylogin()&lt;/tt&gt; is located in {{Trac|wp-includes/pluggable-deprecated.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
== See Also ==
[[Function_Reference/get_user_by|get_user_by()]], [[Function_Reference/get_currentuserinfo|get_currentuserinfo()]], [[Function_Reference/get_userdata|get_userdata()]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="validate_username" d:title="validate username">
<d:index d:value="validate username"/>
<h1>validate username</h1>
<p>== Description ==
Checks whether username is valid.
'''Note:''' this function attempts to sanitize the username, and if it &quot;passes&quot;, the name is considered valid. For additional logic, you can use the 'validate_username' hook.
== Usage ==
%%%&lt;?php validate_username( $username ) ?&gt;%%%
== Parameters ==
{{Parameter|$username|string|Username.}}
== Return Values ==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : Returns &lt;tt&gt;true&lt;/tt&gt; if &lt;tt&gt;$username&lt;/tt&gt; is valid, &lt;tt&gt;false&lt;/tt&gt; if &lt;tt&gt;$username&lt;/tt&gt; is invalid.
== Examples ==
&lt;pre&gt;
&lt;?php
if (!empty($_POST['username']) &amp;&amp; validate_username($_POST['username'])) {
// Go ahead and save the user...
}
?&gt;
&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls [[Plugin_API/Filter_Reference#Database_Writes|&lt;tt&gt;validate_username&lt;/tt&gt;]] hook on &lt;tt&gt;$valid&lt;/tt&gt; check and &lt;tt&gt;$username&lt;/tt&gt; as parameters.
* Uses: [[Function_Reference/sanitize_user|&lt;tt&gt;sanitize_user()&lt;/tt&gt;]]
== Change Log ==
Since: 2.0.1
== Source File ==
&lt;b&gt;Before&lt;/b&gt; 3.0 &lt;br/&gt;
&lt;tt&gt;validate_username()&lt;/tt&gt; is located in &lt;tt&gt;[http://core.trac.wordpress.org/browser/branches/2.9/wp-includes/registration.php wp-includes/registration.php]&lt;/tt&gt;.&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;After&lt;/b&gt; 3.0 &lt;br/&gt;
&lt;tt&gt;validate_username()&lt;/tt&gt; is located in &lt;tt&gt;[http://core.trac.wordpress.org/browser/trunk/wp-includes/user.php wp-includes/user.php]&lt;/tt&gt;.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_insert_user" d:title="wp insert user">
<d:index d:value="wp insert user"/>
<h1>wp insert user</h1>
<p>== Description ==
Insert a user into the database. For '''updating an existing user''', use [[Function Reference/wp_update_user|&lt;tt&gt;wp_update_user&lt;/tt&gt;]] function instead.
== Usage ==
%%%&lt;?php wp_insert_user( $userdata ); ?&gt;%%%
== Parameters ==
{{Parameter|$userdata|mixed|An array of user data, stdClass or [[Class_Reference/WP_User|WP_User]] object.}}
== Return Values ==
; &lt;tt&gt;(mixed)&lt;/tt&gt; : If successful, returns the newly-created user's user_id, otherwise returns a [[Class_Reference/WP_Error|WP_Error]] object.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
Below is an example showing how to insert a new user with the website profile field filled.
&lt;pre&gt;
&lt;?php
$website = &quot;http://example.com&quot;;
$userdata = array(
'user_login' =&gt; 'login_name',
'user_url' =&gt; $website,
'user_pass' =&gt; NULL // When creating an user, `user_pass` is expected.
);
$user_id = wp_insert_user( $userdata ) ;
//On success
if( !is_wp_error($user_id) ) {
echo &quot;User created : &quot;. $user_id;
} ?&gt;
&lt;/pre&gt;
== Notes ==
* Uses: [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] WordPress database layer.
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls filters for most of the &lt;tt&gt;$userdata&lt;/tt&gt; fields with the prefix 'pre_user'. See [[#Description|description above]].
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] Calls 'profile_update' hook when updating giving the user's ID
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] Calls 'user_register' hook when creating a new user giving the user's ID
{| border=&quot;0&quot; cellspacing=&quot;5&quot; summary=&quot;User data array fields.&quot;
|+ The &lt;tt&gt;$userdata&lt;/tt&gt; array can contain the following fields
|-
! style=&quot;font-weight:bold&quot; | Field Name
! Description
! [[Plugin_API/Filter_Reference#Database_Writes_4|Associated Filter]]
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | ID
| An integer that will be used for updating an existing user.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | user_pass
| A string that contains the plain text password for the user.
| &lt;tt&gt;pre_user_pass&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | user_login
| A string that contains the user's username for logging in.
| &lt;tt&gt;pre_user_login&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | user_nicename
| A string that contains a URL-friendly name for the user. The default is the user's username.
| &lt;tt&gt;pre_user_nicename&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | user_url
| A string containing the user's URL for the user's web site.
| &lt;tt&gt;pre_user_url&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | user_email
| A string containing the user's email address.
| &lt;tt&gt;pre_user_email&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | display_name
| A string that will be shown on the site. Defaults to user's username. It is likely that you will want to change this, for both appearance and security through obscurity (that is if you dont use and delete the default admin user).
| &lt;tt&gt;pre_user_display_name&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | nickname
| The user's nickname, defaults to the user's username.
| &lt;tt&gt;pre_user_nickname&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | first_name
| The user's first name.
| &lt;tt&gt;pre_user_first_name&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | last_name
| The user's last name.
| &lt;tt&gt;pre_user_last_name&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | description
| A string containing content about the user.
| &lt;tt&gt;pre_user_description&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | rich_editing
| A string for whether to enable the rich editor or not. False if not empty.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | user_registered
| The date the user registered. Format is Y-m-d H:i:s.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | role
| A string used to set the user's role.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | jabber
| User's Jabber account.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | aim
| User's AOL IM account.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | yim
| User's Yahoo IM account.
| (none)
|}
If there is no ID, a new user will be created.
If ''' you pass an ID ''', the user with that ID will be updated, and these meta fields are updated if set in '''$userdata''' otherwise they are set to null:
&lt;pre&gt;
first_name,
last_name,
nickname,
description,
rich_editing,
comment_shortcuts,
admin_color,
use_ssl,
show_admin_bar_front
&lt;/pre&gt;
When performing an update operation using [[Function Reference/wp_insert_user|&lt;tt&gt;wp_insert_user&lt;/tt&gt;]], user_pass should be the hashed password and not the plain text password.
== Change Log ==
* [[Version_3.5|3.5.0]]: Now accepts stdClass or [[Class Reference/WP_User|WP_User]] object
* Since: 2.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
As of 3.1 &lt;tt&gt;wp_insert_user()&lt;/tt&gt; is located in {{Trac|wp-includes/user.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
[[Function Reference/wp_update_user|wp_update_user]], [[Function Reference/wp_create_user|wp_create_user]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="page_uri_index" d:title="page uri index">
<d:index d:value="page uri index"/>
<h1>page uri index</h1>
<p>== Description ==
{{Rename}}'''Note:''' This is not a directly callable function, it is a method of the WP_Rewrite class. This page should be moved from Function Reference to Rewrite API
&lt;hr&gt;
Retrieve all pages and attachments for pages URIs.
The attachments are for those that have pages as parents and will be retrieved.
== Usage ==
%%%&lt;?php $wp_rewrite-&gt;page_uri_index() ?&gt;%%%
== Parameters ==
None
== Return Values ==
; &lt;tt&gt;(array)&lt;/tt&gt; : Array of page URIs as first element and attachment URIs as second element.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_page_hierarchy|&lt;tt&gt;get_page_hierarchy()&lt;/tt&gt;]] on db query result in [[Database_Description#Table:_wp_posts|posts table]].
* Uses: [[Function_Reference/get_page_uri|&lt;tt&gt;get_page_uri()&lt;/tt&gt;]] on each page ID.
== Change Log ==
Since: 2.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;page_uri_index()&lt;/tt&gt; is located in &lt;tt&gt;wp-includes/rewrite.php&lt;/tt&gt;.
== Related ==
{{Page Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_page_children" d:title="get page children">
<d:index d:value="get page children"/>
<h1>get page children</h1>
<p>{{Languages|
{{en|Function Reference/get_page_children}}
{{it|Riferimento funzioni/get_page_children}}
}}
== Description ==
Retrieve child pages from list of pages matching page ID.
Matches against the pages parameter against the page ID. Also matches all children for the same to retrieve all children of a page. Does not make any SQL queries to get the children.
== Usage ==
%%%&lt;?php &amp;get_page_children( $page_id, $pages ) ?&gt;
&lt;?php get_page_children( $page_id, $pages ) ?&gt;%%%
== Parameters ==
{{Parameter|$page_id|integer|Page ID.}}
{{Parameter|$pages|array|List of pages' objects.}}
== Return Values ==
; &lt;tt&gt;(array)&lt;/tt&gt; :
== Examples ==
&lt;pre&gt;&lt;?php
// Set up the objects needed
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query-&gt;query(array('post_type' =&gt; 'page'));
// Get the page as an Object
$portfolio = get_page_by_title('Portfolio');
// Filter through all pages and find Portfolio's children
$portfolio_children = get_page_children( $portfolio-&gt;ID, $all_wp_pages );
// echo what we get back from WP to the browser
echo '&amp;lt;pre&gt;' . print_r( $portfolio_children, true ) . '&amp;lt;/pre&gt;';
?&gt;&lt;/pre&gt;
== Notes ==
This function calls itself recursively.
== Change Log ==
Since: 1.5.1
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;&amp;get_page_children()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Page Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_get_recent_posts" d:title="wp get recent posts">
<d:index d:value="wp get recent posts"/>
<h1>wp get recent posts</h1>
<p>{{Languages|
{{en|Function Reference/wp get recent posts}}
{{ja|????????/wp get recent posts}}
}}
== Description ==
Retrieve the most recent posts.
== Usage ==
%%%&lt;?php wp_get_recent_posts( $args, $output ) ?&gt;%%%
=== Default Usage ===
%%%&lt;?php $args = array(
'numberposts' =&gt; 10,
'offset' =&gt; 0,
'category' =&gt; 0,
'orderby' =&gt; 'post_date',
'order' =&gt; 'DESC',
'include' =&gt; '',
'exclude' =&gt; '',
'meta_key' =&gt; '',
'meta_value' =&gt;'',
'post_type' =&gt; 'post',
'post_status' =&gt; 'draft, publish, future, pending, private',
'suppress_filters' =&gt; true );
$recent_posts = wp_get_recent_posts( $args, ARRAY_A );
?&gt;%%%
== Return Value ==
{{Return|$posts|array|List of post arrays (default) or objects depending on '''$output'''}}
== Parameters ==
{{Parameter|$args|array||optional|array}}
{{Parameter|$output|string|Constant OBJECT, ARRAY_A|optional|ARRAY_A}}
== Examples ==
This is an example that shows how to use the wp_get_recent_posts() function to list the recent 10 posts.
&lt;pre&gt;
&lt;h2&gt;Recent Posts&lt;/h2&gt;
&lt;ul&gt;
&lt;?php
$recent_posts = wp_get_recent_posts();
foreach( $recent_posts as $recent ){
echo '&lt;li&gt;&lt;a href=&amp;quot;' . get_permalink($recent[&amp;quot;ID&amp;quot;]) . '&amp;quot; title=&amp;quot;Look '.esc_attr($recent[&amp;quot;post_title&amp;quot;]).'&amp;quot; &gt;' . $recent[&amp;quot;post_title&amp;quot;].'&lt;/a&gt; &lt;/li&gt; ';
}
?&gt;
&lt;/ul&gt;
&lt;/pre&gt;
If you want to delimit more or less recent posts you have to put the number in the function parameter like this example below:
&lt;pre&gt;
&lt;h2&gt;Recent Posts&lt;/h2&gt;
&lt;ul&gt;
&lt;?php
$args = array( 'numberposts' =&gt; '5' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo '&lt;li&gt;&lt;a href=&amp;quot;' . get_permalink($recent[&amp;quot;ID&amp;quot;]) . '&amp;quot; title=&amp;quot;Look '.esc_attr($recent[&amp;quot;post_title&amp;quot;]).'&amp;quot; &gt;' . $recent[&amp;quot;post_title&amp;quot;].'&lt;/a&gt; &lt;/li&gt; ';
}
?&gt;
&lt;/ul&gt;
&lt;/pre&gt;
To exclude posts with a certain post format, you can use [[Class_Reference/WP_Query#Taxonomy_Parameters]] like this next example, which excludes all posts with the 'aside' and 'image' formats:
&lt;pre&gt;
&lt;h2&gt;Recent Posts&lt;/h2&gt;
&lt;ul&gt;
&lt;?php
$args = array( 'numberposts' =&gt; '5', 'tax_query' =&gt; array(
array(
'taxonomy' =&gt; 'post_format',
'field' =&gt; 'slug',
'terms' =&gt; 'post-format-aside',
'operator' =&gt; 'NOT IN'
),
array(
'taxonomy' =&gt; 'post_format',
'field' =&gt; 'slug',
'terms' =&gt; 'post-format-image',
'operator' =&gt; 'NOT IN'
)
) );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo '&lt;li&gt;&lt;a href=&amp;quot;' . get_permalink($recent[&amp;quot;ID&amp;quot;]) . '&amp;quot;
title=&amp;quot;'.esc_attr( __($recent[&amp;quot;post_title&amp;quot;])).'&amp;quot; &gt;' . ( __($recent[&amp;quot;post_title&amp;quot;])).'&lt;/a&gt; &lt;/li&gt; ';
}
?&gt;
&lt;/ul&gt;
&lt;/pre&gt;
In the last example you can see the post_title wrapped in a __() function reference,
this is used for internationalization (it's important in case you're dealing with multilanguage site).
== Notes ==
* Uses: [[Function_Reference/wp_parse_args|wp_parse_args()]]
* Uses: [[Function_Reference/get_posts|get_posts()]]
* Only the value of &lt;tt&gt;ARRAY_A&lt;/tt&gt; is checked for $output. Any other value or constant passed will return an array of objects.
* This function returns posts in an associative array (&lt;tt&gt;ARRAY_A&lt;/tt&gt;) format which is compatible with WordPress versions below 3.1. To get output similar to &lt;tt&gt;get_posts()&lt;/tt&gt;, use &lt;tt&gt;OBJECT&lt;/tt&gt; as the second parameter: &lt;tt&gt;wp_get_recent_posts( $args, OBJECT );&lt;/tt&gt;
== Change Log ==
* Since: [[Version 1.0|1.0.0]]
* [[Version 3.1|3.1.0]]: The &lt;tt&gt;$num&lt;/tt&gt; parameter deprecated in favor of &lt;tt&gt;$args&lt;/tt&gt;.
== Source File ==
&lt;tt&gt;wp_get_recent_posts()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_get_single_post" d:title="wp get single post">
<d:index d:value="wp get single post"/>
<h1>wp get single post</h1>
<p>{{Languages|
{{en|Function Reference/wp get single post}}
{{ja|関数リファレンス/wp get single post}}
}}
{{Deprecated|version=3.5|new_function=get_post}}
== Description ==
Retrieve a single post, based on post ID.
== Usage ==
%%%&lt;?php wp_get_single_post( $postid, $mode ) ?&gt;%%%
== Parameters ==
{{Parameter|$postid|integer|Post ID.|optional|0}}
{{Parameter|$mode|string|How to return result. Expects a Constant: &lt;tt&gt;OBJECT&lt;/tt&gt;, &lt;tt&gt;ARRAY_N&lt;/tt&gt;, or &lt;tt&gt;ARRAY_A&lt;/tt&gt;.|optional|&lt;tt&gt;OBJECT&lt;/tt&gt;}}
== Return Values ==
; &lt;tt&gt;(object&amp;#124;array)&lt;/tt&gt; : Post object or array holding post contents and information with two additional fields (or keys): '&lt;tt&gt;post_category&lt;/tt&gt;' and '&lt;tt&gt;tags_input&lt;/tt&gt;'.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_post|&lt;tt&gt;get_post()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_get_post_categories|&lt;tt&gt;wp_get_post_categories()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_get_post_tags|&lt;tt&gt;wp_get_post_tags()&lt;/tt&gt;]]
== Change Log ==
* Deprecated: [[Version 3.5|3.5.0]]
* Since: 1.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_get_single_post()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_trim_excerpt" d:title="wp trim excerpt">
<d:index d:value="wp trim excerpt"/>
<h1>wp trim excerpt</h1>
<p>{{Languages|
{{en|Function Reference/wp trim excerpt}}
{{ja| 関数リファレンス/wp trim excerpt}}
}}
== Description ==
Generates an excerpt from the content, if needed. Must be used inside the &quot;Loop&quot;.
The excerpt word amount will be 55 words and if the amount is greater than that, then the string '&lt;tt&gt; [...]&lt;/tt&gt;' will be appended to the excerpt. If the string is less than 55 words, then the content will be returned as is.
== Usage ==
%%%&lt;?php wp_trim_excerpt( $text ) ?&gt;%%%
== Parameters ==
{{Parameter|$text|string|The excerpt. If set to empty an excerpt is generated. If you supply text it will be returned untouched. It will &lt;strong&gt;not&lt;/strong&gt; be shortened.}}
== Return Values ==
; &lt;tt&gt;(string)&lt;/tt&gt; : The excerpt.
== Examples ==
== Notes ==
* Uses: [[Function_Reference/get_the_content|&lt;tt&gt;get_the_content&lt;/tt&gt;]]
* Uses: [[Function_Reference/strip_shortcodes|&lt;tt&gt;strip_shortcodes()&lt;/tt&gt;]] on &lt;tt&gt;$text&lt;/tt&gt;.
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] for '&lt;tt&gt;the_content&lt;/tt&gt;' on &lt;tt&gt;$text&lt;/tt&gt;.
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] for '&lt;tt&gt;[[Plugin API/Filter Reference/excerpt length|excerpt_length]]&lt;/tt&gt;' on &lt;tt&gt;55&lt;/tt&gt;.
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] for '&lt;tt&gt;[[Plugin API/Filter Reference/excerpt more|excerpt_more]]&lt;/tt&gt;' on '&lt;tt&gt;[...]&lt;/tt&gt;'.
== Change Log ==
* Since: 1.5.0
* [[Version 2.8|2.8]] : Added the '&lt;tt&gt;[[Plugin API/Filter Reference/excerpt length|excerpt_length]]&lt;/tt&gt;' filter.
* [[Version 2.9|2.9]] : Added the '&lt;tt&gt;[[Plugin API/Filter Reference/excerpt more|excerpt_more]]&lt;/tt&gt;' filter. ([https://core.trac.wordpress.org/ticket/10395 Ticket 10395])
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_trim_excerpt()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
[[Function_Reference/the_excerpt_rss|the_excerpt_rss]]
[[Function_Reference/wp_trim_words|wp_trim_words]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_the_content" d:title="get the content">
<d:index d:value="get the content"/>
<h1>get the content</h1>
<p>{{Languages|
{{en|Function Reference/get the content}}
{{ja|Function Reference/get the content}}
{{zh-cn|get the content}}
}}
== Description ==
Retrieve the post content.
(Must be used in a Loop)
== Usage ==
%%%&lt;?php get_the_content( $more_link_text, $stripteaser ) ?&gt;%%%
== Parameters ==
{{Parameter|$more_link_text|string|Content for when there is more text.|optional|null}}
{{Parameter|$stripteaser|boolean|Strip teaser content before the more text.|optional|false}}
== Return Values ==
; &lt;tt&gt;(string)&lt;/tt&gt; :
== Examples ==
=== Display the post content, ending with &quot;Read more&quot; if needed ===
&lt;pre&gt;
&lt;?php
$content = get_the_content('Read more');
print $content;
?&gt;
&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/post_password_required|&lt;tt&gt;post_password_required()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_the_password_form|&lt;tt&gt;get_the_password_form()&lt;/tt&gt;]] if [[Function_Reference/post_password_required|&lt;tt&gt;post_password_required()&lt;/tt&gt;]] fails
* Uses: [[Function_Reference/wp_kses_no_null|&lt;tt&gt;wp_kses_no_null()&lt;/tt&gt;]] while processing the &lt;!--more--&gt; tag.
* Uses: [[Function_Reference/balanceTags|&lt;tt&gt;balanceTags()&lt;/tt&gt;]]
* Uses: [[Template_Tags/get_permalink|&lt;tt&gt;get_permalink()&lt;/tt&gt;]]
* Uses global: &lt;tt&gt;$id&lt;/tt&gt;
* Uses global: &lt;tt&gt;$post&lt;/tt&gt;
* Uses global: &lt;tt&gt;$more&lt;/tt&gt;
* Uses global: &lt;tt&gt;$page&lt;/tt&gt;
* Uses global: &lt;tt&gt;$pages&lt;/tt&gt;
* Uses global: &lt;tt&gt;$multipage&lt;/tt&gt;
* Uses global: &lt;tt&gt;$preview&lt;/tt&gt;
* Uses global: &lt;tt&gt;$pagenow&lt;/tt&gt;
If you use plugins that filter content ([[Function_Reference/add_filter|add_filter]]('the_content')), then this will not apply the filters, unless you call it this way (using [[Function_Reference/apply_filters|apply_filters]]):
%%%&lt;?php apply_filters('the_content',get_the_content( $more_link_text, $stripteaser, $more_file )) ?&gt;%%%
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;get_the_content()&lt;/tt&gt; is located in {{Trac|wp-includes/post-template.php|tags/{{CurrentVersion}}|180}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_update_user" d:title="wp update user">
<d:index d:value="wp update user"/>
<h1>wp update user</h1>
<p>{{Languages|
{{en|Function Reference/wp_update_user}}
{{ko|Function Reference/wp_update_user}}
}}
== Description ==
This function updates a single user in the database. This update can contain multiple pieces of user metadata as an array.
To update a single piece of user metadata, use [[Function_Reference/update_user_meta|update_user_meta()]] instead.
To create a ''new'' user, use [[Function_Reference/wp_insert_user|wp_insert_user()]] instead.
'''Note:''' If current user's password is being updated, then the cookies will be cleared!
===Special Note===
&lt;del&gt;If &lt;tt&gt;$userdata&lt;/tt&gt; does not contain an 'ID' key, then a new user will be created and the new user's ID will be returned.&lt;/del&gt; Since version 3.6 this is no longer the case, but this behavior may be restored in the future. See [https://core.trac.wordpress.org/ticket/16731 ticket #16731].
== Usage ==
%%%&lt;?php wp_update_user( $userdata ) ?&gt;%%%
== Parameters ==
{{Parameter|$userdata|mixed|An array of user data, stdClass or [[Class_Reference/WP_User|WP_User]] object.}}
== Return Values ==
; &lt;tt&gt;(mixed)&lt;/tt&gt; : If successful, returns the user_id, otherwise returns a [[Class_Reference/WP_Error|WP_Error]] object.
== Examples ==
Below is an example showing how to update a user's website profile field:
&lt;pre&gt;
&lt;?php
$user_id = 1;
$website = 'http://wordpress.org';
$user_id = wp_update_user( array( 'ID' =&gt; $user_id, 'user_url' =&gt; $website ) );
if ( is_wp_error( $user_id ) ) {
// There was an error, probably that user doesn't exist.
} else {
// Success!
}
&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/get_userdata|&lt;tt&gt;get_userdata()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_hash_password|&lt;tt&gt;wp_hash_password()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_insert_user|&lt;tt&gt;wp_insert_user()&lt;/tt&gt;]] Used to update existing user or add new one if user doesn't exist already
* Uses: [[Function_Reference/wp_get_current_user|&lt;tt&gt;wp_get_current_user()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_clear_auth_cookie|&lt;tt&gt;wp_clear_auth_cookie()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_set_auth_cookie|&lt;tt&gt;wp_set_auth_cookie()&lt;/tt&gt;]]
{| border=&quot;0&quot; cellspacing=&quot;5&quot; summary=&quot;User data array fields.&quot;
|+ The &lt;tt&gt;$userdata&lt;/tt&gt; array can contain the following fields
|-
! style=&quot;font-weight:bold&quot; | Field Name
! Description
! [[Plugin_API/Filter_Reference#Database_Writes_4|Associated Filter]]
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | ID
| An integer that will be used for updating an existing user.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | user_pass
| A string that contains the plain text password for the user.
| &lt;tt&gt;pre_user_pass&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | user_login
| A string that contains the user's username for logging in. Please note that the function cannot alter this field, since WordPress does not allow usernames to be changed.
| &lt;tt&gt;pre_user_login&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | user_nicename
| A string that contains a URL-friendly name for the user. The default is the user's username.
| &lt;tt&gt;pre_user_nicename&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | user_url
| A string containing the user's URL for the user's web site.
| &lt;tt&gt;pre_user_url&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | user_email
| A string containing the user's email address.
| &lt;tt&gt;pre_user_email&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | display_name
| A string that will be shown on the site. Defaults to user's username. It is likely that you will want to change this, for both appearance and security through obscurity (that is if you dont use and delete the default admin user).
| &lt;tt&gt;pre_user_display_name&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | nickname
| The user's nickname, defaults to the user's username.
| &lt;tt&gt;pre_user_nickname&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | first_name
| The user's first name.
| &lt;tt&gt;pre_user_first_name&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | last_name
| The user's last name.
| &lt;tt&gt;pre_user_last_name&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | description
| A string containing content about the user.
| &lt;tt&gt;pre_user_description&lt;/tt&gt;
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | rich_editing
| A string for whether to enable the rich editor or not. False if not empty.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | user_registered
| The date the user registered. Format is Y-m-d H:i:s.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | role
| A string used to set the user's role.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | jabber
| User's Jabber account.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | aim
| User's AOL IM account.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | yim
| User's Yahoo IM account.
| (none)
|-valign=&quot;top&quot;
| style=&quot;font-weight:bold&quot; | show_admin_bar_front
| Show the WP admin bar on the front-end.
| (none)
|}
Remember, &lt;tt&gt;user_pass&lt;/tt&gt; should be the plain text password as it will be automatically hashed by WordPress.
== Change Log ==
* [[Version_3.5|3.5.0]]: Now accepts stdClass or [[Class Reference/WP_User|WP_User]] object.
* Since: [[Version 2.0|2.0.0]]
== Source File ==
&lt;tt&gt;wp_update_user()&lt;/tt&gt; is located in {{Trac|wp-includes/user.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_lastcommentmodified" d:title="get lastcommentmodified">
<d:index d:value="get lastcommentmodified"/>
<h1>get lastcommentmodified</h1>
<p>== Description ==
The date the last comment was modified. If &lt;tt&gt;$cache_lastcommentmodified&lt;/tt&gt; is set this function returns its value from the cache without hitting the database.
== Usage ==
%%%&lt;?php get_lastcommentmodified( $timezone ) ?&gt;%%%
== Parameters ==
{{Parameter|$timezone|string|Which timezone to use in reference to '&lt;tt&gt;gmt&lt;/tt&gt;', '&lt;tt&gt;blog&lt;/tt&gt;', or '&lt;tt&gt;server&lt;/tt&gt;' locations.|optional|'server'}}
== Return Values ==
; &lt;tt&gt;(string)&lt;/tt&gt; : Last comment modified date as a [http://dev.mysql.com/doc/refman/4.1/en/datetime.html MySQL DATETIME].
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] to read from the [[Database_Description#Table:_wp_comments|comments table]].
* Uses global: array &lt;tt&gt;$cache_lastcommentmodified&lt;/tt&gt;
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_lastcommentmodified()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="sanitize_comment_cookies" d:title="sanitize comment cookies">
<d:index d:value="sanitize comment cookies"/>
<h1>sanitize comment cookies</h1>
<p>== Description ==
Sanitizes the cookies sent to the user already.
Will only do anything if the cookies have already been created for the user. Mostly used after cookies had been sent to use elsewhere.
== Usage ==
%%%&lt;?php sanitize_comment_cookies() ?&gt;%%%
== Parameters ==
None
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] with 'pre_comment_author_name' on 'comment_author' cookie
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] with 'pre_comment_author_email' on 'comment_author_email' cookie
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] with 'pre_comment_author_url' on 'comment_author_url' cookie
== Change Log ==
Since: 2.0.4
== Source File ==
&lt;tt&gt;sanitize_comment_cookies()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_allow_comment" d:title="wp allow comment">
<d:index d:value="wp allow comment"/>
<h1>wp allow comment</h1>
<p>== Description ==
Validates whether this comment is allowed to be made or not.
== Usage ==
%%%&lt;?php wp_allow_comment( $commentdata ) ?&gt;%%%
== Parameters ==
{{Parameter|$commentdata|array|Contains information on the comment}}
== Return Values ==
; &lt;tt&gt;(mixed)&lt;/tt&gt; : Signifies the approval status (0|1|'spam')
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls 'pre_comment_approved' hook on the type of comment
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] Calls 'check_comment_flood' hook on &lt;tt&gt;$comment_author_IP&lt;/tt&gt;, &lt;tt&gt;$comment_author_email&lt;/tt&gt;, and &lt;tt&gt;$comment_date_gmt&lt;/tt&gt;
* Uses: The &lt;tt&gt;WP_User&lt;/tt&gt; object.
* Uses: [[Function_Reference/get_userdata|&lt;tt&gt;get_userdata()&lt;/tt&gt;]]
* Uses: [[Function_Reference/check_comment|&lt;tt&gt;check_comment()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_blacklist_check|&lt;tt&gt;wp_blacklist_check() to find spam.&lt;/tt&gt;]]
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;tt&gt;wp_allow_comment()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_delete_comment" d:title="wp delete comment">
<d:index d:value="wp delete comment"/>
<h1>wp delete comment</h1>
<p>== Description ==
Trashes or deletes a comment.
The comment is moved to trash instead of permanently deleted unless trash is disabled, item is already in the trash, or &lt;tt&gt;$force_delete&lt;/tt&gt; is true.
The post comment count will be updated if the comment was approved and has a post ID available.
== Usage ==
%%%&lt;?php wp_delete_comment( $comment_id, $force_delete ) ?&gt;%%%
== Parameters ==
{{Parameter|$comment_id|integer|Comment ID}}
{{Parameter|$force_delete|boolean|Move comment to trash or delete.|optional|false}}
== Return Values ==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : False if delete comment query failure, true on success.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] Calls 'delete_comment' hook on comment ID
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] Calls 'wp_set_comment_status' hook on comment ID with 'delete' set for the second parameter
* Uses: [[Function_Reference/wp_transition_comment_status|&lt;tt&gt;wp_transition_comment_status()&lt;/tt&gt;]] Passes new and old comment status along with &lt;tt&gt;$comment&lt;/tt&gt; object
* Uses: [[Function_Reference/get_comment|&lt;tt&gt;get_comment()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_update_comment_count|&lt;tt&gt;wp_update_comment_count()&lt;/tt&gt;]] to decrease count on success.
* Uses: [[Function_Reference/clean_comment_cache|&lt;tt&gt;clean_comment_cache()&lt;/tt&gt;]] to remove comment form cache on success.
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;tt&gt;wp_delete_comment()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&amp;nbsp;
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_get_comment_status" d:title="wp get comment status">
<d:index d:value="wp get comment status"/>
<h1>wp get comment status</h1>
<p>{{Languages|
{{en|Function Reference/wp_get_comment_status}}
{{it|Riferimento funzioni/wp_get_comment_status}}
}}
== Description ==
The status of a comment by ID.
== Usage ==
%%%&lt;?php wp_get_comment_status( $comment_id ) ?&gt;%%%
== Parameters ==
{{Parameter|$comment_id|integer|Comment ID}}
== Return Values ==
; &lt;tt&gt;(string&amp;#124;boolean)&lt;/tt&gt; : Status might be '&lt;tt&gt;deleted&lt;/tt&gt;', '&lt;tt&gt;approved&lt;/tt&gt;', '&lt;tt&gt;unapproved&lt;/tt&gt;', '&lt;tt&gt;spam&lt;/tt&gt;' or &lt;tt&gt;false&lt;/tt&gt; on failure.
== Examples ==
&lt;pre&gt;
&lt;?php
$status = wp_get_comment_status( $comment_id );
if ( $status == &quot;approved&quot; ) {
// show the comment
}
?&gt;
&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/get_comment|&lt;tt&gt;get_comment()&lt;/tt&gt;]]
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_get_comment_status()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&amp;nbsp;
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_get_current_commenter" d:title="wp get current commenter">
<d:index d:value="wp get current commenter"/>
<h1>wp get current commenter</h1>
<p>{{Languages|
{{en|Function Reference/wp_get_current_commenter}}
{{it|Riferimento funzioni/wp_get_current_commenter}}
}}
== Description ==
Get current commenter's name, email, and URL.
Expects cookies content to already be sanitized. User of this function might wish to recheck the returned array for validity.
== Usage ==
%%%&lt;?php wp_get_current_commenter() ?&gt;%%%
== Parameters ==
== Return Values ==
; &lt;tt&gt;(array)&lt;/tt&gt; : Comment author, email, url respectively.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Return array is mapped like this:
&lt;pre&gt;
Array (
['comment_author'] =&gt; 'Harriet Smith,
['comment_author_email'] =&gt; 'hsmith@,example.com',
['comment_author_url'] =&gt; 'http://example.com/'
)
&lt;/pre&gt;
== Change Log ==
Since: 2.0.4
== Source File ==
&lt;tt&gt;wp_get_current_commenter()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&amp;nbsp;
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_insert_comment" d:title="wp insert comment">
<d:index d:value="wp insert comment"/>
<h1>wp insert comment</h1>
<p>== Description ==
Inserts a comment to the database.
The available &lt;tt&gt;$commentdata&lt;/tt&gt; key names are '&lt;tt&gt;comment_author_IP&lt;/tt&gt;', '&lt;tt&gt;comment_date&lt;/tt&gt;', '&lt;tt&gt;comment_date_gmt&lt;/tt&gt;', '&lt;tt&gt;comment_parent&lt;/tt&gt;', '&lt;tt&gt;comment_approved&lt;/tt&gt;', and '&lt;tt&gt;user_id&lt;/tt&gt;'.
Also, consider using [[Function Reference/wp new comment|wp_new_comment()]], which sanitizes and validates comment data before calling wp_insert_comment() to insert the comment into the database.
== Usage ==
&lt;!-- this was wrapped in a triple percent (%%%), but it prevented the double apostrophe ('') from being rendered --&gt;
&lt;pre&gt;&lt;?php
$time = current_time('mysql');
$data = array(
'comment_post_ID' =&gt; 1,
'comment_author' =&gt; 'admin',
'comment_author_email' =&gt; 'admin@admin.com',
'comment_author_url' =&gt; 'http://',
'comment_content' =&gt; 'content here',
'comment_type' =&gt; '',
'comment_parent' =&gt; 0,
'user_id' =&gt; 1,
'comment_author_IP' =&gt; '127.0.0.1',
'comment_agent' =&gt; 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)',
'comment_date' =&gt; $time,
'comment_approved' =&gt; 1,
);
wp_insert_comment($data);
?&gt;&lt;/pre&gt;
== Parameters ==
{{Parameter|$commentdata|array|Contains information on the comment.}}
== Return Values ==
; &lt;tt&gt;(integer)&lt;/tt&gt; : The new comment's ID.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* Uses: [[Function_Reference/current_time|&lt;tt&gt;current_time()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_gmt_from_date|&lt;tt&gt;get_gmt_from_date()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_update_comment_count|&lt;tt&gt;wp_update_comment_count()&lt;/tt&gt;]]
* Uses:Inserts a record in the [[Database_Description#Table:_wp_comments|comments table]] in the database
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_insert_comment()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="register_taxonomy" d:title="register taxonomy">
<d:index d:value="register taxonomy"/>
<h1>register taxonomy</h1>
<p>{{Languages|
{{en|Function Reference/register_taxonomy}}
{{zh-cn|函数参考/register_taxonomy}}
{{ja|関数リファレンス/register_taxonomy}}
}}
== Description ==
This function adds or overwrites a [[Taxonomies|taxonomy]]. It takes in a name, an object name that it affects, and an array of parameters. It does not return anything.
Care should be used in selecting a taxonomy name so that it does not conflict with other taxonomies, post types, and [http://core.trac.wordpress.org/browser/trunk/wp-includes/class-wp.php reserved WordPress public and private query variables]. A complete list of those is described in the [[#Reserved Terms|Reserved Terms section]]. In particular, capital letters should be avoided (This was allowed in 3.0, but not enforced until 3.1 with the &quot;Cheatin'&quot; error).
== Usage ==
%%% &lt;?php register_taxonomy( $taxonomy, $object_type, $args ); ?&gt; %%%
'''Use the &lt;tt&gt;init&lt;/tt&gt; action to call this function.''' Calling it outside of an action can lead to troubles. See [http://core.trac.wordpress.org/ticket/15568 #15568] for details.
Better '''be safe than sorry''' when registering custom taxonomies for custom post types. Use [[Function Reference/register_taxonomy_for_object_type|register_taxonomy_for_object_type()]] right after the function to interconnect them. Else you could run into minetraps where the post type isn't attached inside filter callback that run during &lt;code&gt;parse_request&lt;/code&gt; or &lt;code&gt;pre_get_posts&lt;/code&gt;.
== Parameters ==
{{Parameter|$taxonomy|string|The name of the taxonomy. Name should only contain lowercase letters and the underscore character, and not be more than 32 characters long (database structure restriction).}}
{{Parameter|$object_type|array/string|Name of the object type for the taxonomy object. Object-types can be built-in [[Post Type]] or any [[Post_Types#Custom_Types|Custom Post Type]] that may be registered.}}
:Builtin Post Types:
:* '''&lt;tt&gt;post&lt;/tt&gt;'''
:* '''&lt;tt&gt;page&lt;/tt&gt;'''
:* '''&lt;tt&gt;attachment&lt;/tt&gt;'''
:* '''&lt;tt&gt;revision&lt;/tt&gt;'''
:* '''&lt;tt&gt;nav_menu_item&lt;/tt&gt;'''
:Custom Post Types:
:* '''&lt;tt&gt;{custom_post_type}&lt;/tt&gt;''' - Custom Post Type names must be all in lower-case and without any spaces.
:* '''&lt;tt&gt;null&lt;/tt&gt;''' - Setting explicitly to &lt;tt&gt;null&lt;/tt&gt; registers the taxonomy but doesn't associate it with any objects, so it won't be directly available within the Admin UI. You will need to manually register it using the 'taxonomy' parameter (passed through $args) when registering a custom post_type (see [[Function_Reference/register_post_type|register_post_type()]]), or using [[Function_Reference/register_taxonomy_for_object_type|register_taxonomy_for_object_type()]].
{{Parameter|$args|array/string|An array of [[#Arguments|Arguments]].|optional}}
=== Arguments ===
{{Parameter|label|string|A '''plural''' descriptive name for the taxonomy marked for translation.|optional|overridden by ''$labels-&gt;name''}}
{{Parameter|labels|array|labels - An array of labels for this taxonomy. By default tag labels are used for non-hierarchical types and category labels for hierarchical ones.|optional|if empty, name is set to label value, and singular_name is set to name value}}
:* ''''name'''' - general name for the taxonomy, usually plural. The same as and overridden by $tax-&gt;label. Default is &lt;code&gt;_x( 'Post Tags', 'taxonomy general name' )&lt;/code&gt; or &lt;code&gt;_x( 'Categories', 'taxonomy general name' )&lt;/code&gt;. When internationalizing this string, please use a [[I18n_for_WordPress_Developers#Disambiguation_by_context|gettext context]] matching your post type. Example: &lt;code&gt;_x('Writers', 'taxonomy general name');&lt;/code&gt;
:* ''''singular_name'''' - name for one object of this taxonomy. Default is &lt;code&gt;_x( 'Post Tag', 'taxonomy singular name' )&lt;/code&gt; or &lt;code&gt;_x( 'Category', 'taxonomy singular name' )&lt;/code&gt;. When internationalizing this string, please use a [[I18n_for_WordPress_Developers#Disambiguation_by_context|gettext context]] matching your post type. Example: &lt;code&gt;_x('Writer', 'taxonomy singular name');&lt;/code&gt;
:* ''''menu_name'''' - the menu name text. This string is the name to give menu items. If not set, defaults to value of ''name'' label.
:* ''''all_items'''' - the all items text. Default is &lt;code&gt;__( 'All Tags' )&lt;/code&gt; or &lt;code&gt;__( 'All Categories' )&lt;/code&gt;
:* ''''edit_item'''' - the edit item text. Default is &lt;code&gt;__( 'Edit Tag' )&lt;/code&gt; or &lt;code&gt;__( 'Edit Category' )&lt;/code&gt;
:* ''''view_item'''' - the view item text, Default is &lt;code&gt;__( 'View Tag' )&lt;/code&gt; or &lt;code&gt;__( 'View Category' )&lt;/code&gt;
:* ''''update_item'''' - the update item text. Default is &lt;code&gt;__( 'Update Tag' )&lt;/code&gt; or &lt;code&gt;__( 'Update Category' )&lt;/code&gt;
:* ''''add_new_item'''' - the add new item text. Default is &lt;code&gt;__( 'Add New Tag' )&lt;/code&gt; or &lt;code&gt;__( 'Add New Category' )&lt;/code&gt;
:* ''''new_item_name'''' - the new item name text. Default is &lt;code&gt;__( 'New Tag Name' )&lt;/code&gt; or &lt;code&gt;__( 'New Category Name' )&lt;/code&gt;
:* ''''parent_item'''' - the parent item text. This string is not used on non-hierarchical taxonomies such as post tags. Default is null or &lt;code&gt;__( 'Parent Category' )&lt;/code&gt;
:* ''''parent_item_colon'''' - The same as &lt;code&gt;parent_item&lt;/code&gt;, but with colon &lt;code&gt;:&lt;/code&gt; in the end null, &lt;code&gt;__( 'Parent Category:' )&lt;/code&gt;
:* ''''search_items'''' - the search items text. Default is &lt;code&gt;__( 'Search Tags' )&lt;/code&gt; or &lt;code&gt;__( 'Search Categories' )&lt;/code&gt;
:* ''''popular_items'''' - the popular items text. This string is not used on hierarchical taxonomies. Default is &lt;code&gt;__( 'Popular Tags' )&lt;/code&gt; or null
:* ''''separate_items_with_commas'''' - the separate item with commas text used in the taxonomy meta box. This string is not used on hierarchical taxonomies. Default is &lt;code&gt;__( 'Separate tags with commas' )&lt;/code&gt;, or null
:* ''''add_or_remove_items'''' - the add or remove items text and used in the meta box when JavaScript is disabled. This string is not used on hierarchical taxonomies. Default is &lt;code&gt;__( 'Add or remove tags' )&lt;/code&gt; or null
:* ''''choose_from_most_used'''' - the choose from most used text used in the taxonomy meta box. This string is not used on hierarchical taxonomies. Default is &lt;code&gt;__( 'Choose from the most used tags' )&lt;/code&gt; or null
:* ''''not_found'''' (3.6+) - the text displayed via clicking 'Choose from the most used tags' in the taxonomy meta box when no tags are available. This string is not used on hierarchical taxonomies. Default is &lt;code&gt;__( 'No tags found.' )&lt;/code&gt; or null
{{Parameter|public|boolean|If the taxonomy should be publicly queryable.|optional|true}}
{{Parameter|show_ui|boolean|Whether to generate a default UI for managing this taxonomy.|optional|if not set, defaults to value of ''public'' argument. As of [[Version_3.5|3.5]], setting this to &lt;strong&gt;false&lt;/strong&gt; for attachment taxonomies will hide the UI.}}
{{Parameter|show_in_nav_menus|boolean|true makes this taxonomy available for selection in navigation menus.|optional|if not set, defaults to value of ''public'' argument}}
{{Parameter|show_tagcloud|boolean|Whether to allow the Tag Cloud widget to use this taxonomy.|optional|if not set, defaults to value of ''show_ui'' argument}}
{{Parameter|meta_box_cb|callback|Provide a callback function name for the meta box display. (Available since [[Version 3.8|3.8]])|optional|null}}
'''Note:''' Defaults to the categories meta box (&lt;tt&gt;post_categories_meta_box()&lt;/tt&gt; in &lt;tt&gt;meta-boxes.php&lt;/tt&gt;) for hierarchical taxonomies and the tags meta box (&lt;tt&gt;post_tags_meta_box()&lt;/tt&gt;) for non-hierarchical taxonomies. No meta box is shown if set to false.
{{Parameter|show_admin_column|boolean|Whether to allow automatic creation of taxonomy columns on associated post-types table. (Available since [[Version 3.5|3.5]])|optional|false}}
{{Parameter|hierarchical|boolean|Is this taxonomy hierarchical (have descendants) like categories or not hierarchical like tags.|optional|false}}
'''Note:''' Hierarchical taxonomies will have a list with checkboxes to select an existing category in the taxonomy admin box on the post edit page (like default post categories). Non-hierarchical taxonomies will just have an empty text field to type-in taxonomy terms to associate with the post (like default post tags).
{{Parameter|update_count_callback|string|A function name that will be called when the count of an associated ''$object_type'', such as post, is updated. Works much like a hook.|optional|None - but see Note, below.}}
'''Note:''' While the default is &lt;tt&gt;&lt;nowiki&gt;''&lt;/nowiki&gt;&lt;/tt&gt;, when actually performing the count update in &lt;tt&gt;wp_update_term_count_now()&lt;/tt&gt;, if the taxonomy is only attached to &lt;tt&gt;post&lt;/tt&gt; types (as opposed to other WordPress objects, like &lt;tt&gt;user&lt;/tt&gt;), the built-in &lt;tt&gt;_update_post_term_count()&lt;/tt&gt; function will be used to count only published posts associated with that term, otherwise &lt;tt&gt;_update_generic_term_count()&lt;/tt&gt; will be used instead, that does no such checking.
This is significant in the case of '''attachments'''. Because an attachment is a type of &lt;tt&gt;post&lt;/tt&gt;, the default &lt;tt&gt;_update_post_term_count()&lt;/tt&gt; will be used. However, this may be undesirable, because this will only count attachments that are actually attached to another post (like when you insert an image into a post). This means that attachments that you simply upload to WordPress using the Media Library, but do not actually attach to another post will '''not''' be counted. If your intention behind associating a taxonomy with attachments was to leverage the Media Library as a sort of Document Management solution, you are probably more interested in the counts of unattached Media items, than in those attached to posts. In this case, you should force the use of &lt;tt&gt;_update_generic_term_count()&lt;/tt&gt; by setting '_update_generic_term_count' as the value for &lt;tt&gt;update_count_callback&lt;/tt&gt;.
{{Parameter|query_var|boolean or string|False to disable the query_var, set as string to use custom query_var instead of default which is $taxonomy, the taxonomy's &quot;name&quot;.|optional|$taxonomy}}
'''Note:''' The query_var is used for direct queries through WP_Query like &lt;code&gt;new WP_Query(array('people'=&gt;$person_name))&lt;/code&gt; and URL queries like &lt;code&gt;/?people=$person_name&lt;/code&gt;. Setting query_var to false will disable these methods, but you can still fetch posts with an explicit WP_Query taxonomy query like &lt;code&gt;WP_Query(array('taxonomy'=&gt;'people', 'term'=&gt;$person_name))&lt;/code&gt;.
{{Parameter|rewrite|boolean/array|Set to false to prevent automatic URL rewriting a.k.a. &quot;pretty permalinks&quot;. Pass an ''$args'' array to override default URL settings for permalinks as outlined below:|optional|true}}
:* ''''slug'''' - Used as pretty permalink text (i.e. /tag/) - defaults to $taxonomy (taxonomy's name slug)
:* ''''with_front'''' - allowing permalinks to be prepended with front base - defaults to true
:* ''''hierarchical'''' - true or false allow hierarchical urls (implemented in [[Version 3.1]]) - defaults to false
:* ''''ep_mask'''' - Assign an endpoint mask for this taxonomy - defaults to EP_NONE. For more info see [http://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/ this Make WordPress Plugins summary of endpoints].
'''Note:''' You may need to flush the rewrite rules after changing this. You can do it manually by going to the Permalink Settings page and re-saving the rules -- you don't need to change them -- or by calling &lt;tt&gt;$wp_rewrite-&gt;flush_rules()&lt;/tt&gt;. You should only flush the rules once after the taxonomy has been created, not every time the plugin/theme loads.
{{Parameter|capabilities|array|An array of the capabilities for this taxonomy.|optional}}
:* ''''manage_terms'''' - 'manage_categories'
:* ''''edit_terms'''' - 'manage_categories'
:* ''''delete_terms'''' - 'manage_categories'
:* ''''assign_terms'''' - 'edit_posts'
{{Parameter|sort|boolean|Whether this taxonomy should remember the order in which terms are added to objects.|optional}}
{{Parameter|_builtin|boolean|Whether this taxonomy is a native or &quot;built-in&quot; taxonomy. '''Note: this Codex entry is for documentation - core developers recommend you don't use this when registering your own taxonomy'''|not for general use|false}}
== Example ==
An example of registering a two taxonomies, genres and writers, for the post type called &quot;book&quot; (uses [[Version 3.1]] arguments):
Note: You can define custom taxonomies in a themes's &lt;code&gt;functions.php&lt;/code&gt; template file:
&lt;pre&gt;
&lt;?php
// hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'create_book_taxonomies', 0 );
// create two taxonomies, genres and writers for the post type &quot;book&quot;
function create_book_taxonomies() {
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' =&gt; _x( 'Genres', 'taxonomy general name' ),
'singular_name' =&gt; _x( 'Genre', 'taxonomy singular name' ),
'search_items' =&gt; __( 'Search Genres' ),
'all_items' =&gt; __( 'All Genres' ),
'parent_item' =&gt; __( 'Parent Genre' ),
'parent_item_colon' =&gt; __( 'Parent Genre:' ),
'edit_item' =&gt; __( 'Edit Genre' ),
'update_item' =&gt; __( 'Update Genre' ),
'add_new_item' =&gt; __( 'Add New Genre' ),
'new_item_name' =&gt; __( 'New Genre Name' ),
'menu_name' =&gt; __( 'Genre' ),
);
$args = array(
'hierarchical' =&gt; true,
'labels' =&gt; $labels,
'show_ui' =&gt; true,
'show_admin_column' =&gt; true,
'query_var' =&gt; true,
'rewrite' =&gt; array( 'slug' =&gt; 'genre' ),
);
register_taxonomy( 'genre', array( 'book' ), $args );
// Add new taxonomy, NOT hierarchical (like tags)
$labels = array(
'name' =&gt; _x( 'Writers', 'taxonomy general name' ),
'singular_name' =&gt; _x( 'Writer', 'taxonomy singular name' ),
'search_items' =&gt; __( 'Search Writers' ),
'popular_items' =&gt; __( 'Popular Writers' ),
'all_items' =&gt; __( 'All Writers' ),
'parent_item' =&gt; null,
'parent_item_colon' =&gt; null,
'edit_item' =&gt; __( 'Edit Writer' ),
'update_item' =&gt; __( 'Update Writer' ),
'add_new_item' =&gt; __( 'Add New Writer' ),
'new_item_name' =&gt; __( 'New Writer Name' ),
'separate_items_with_commas' =&gt; __( 'Separate writers with commas' ),
'add_or_remove_items' =&gt; __( 'Add or remove writers' ),
'choose_from_most_used' =&gt; __( 'Choose from the most used writers' ),
'not_found' =&gt; __( 'No writers found.' ),
'menu_name' =&gt; __( 'Writers' ),
);
$args = array(
'hierarchical' =&gt; false,
'labels' =&gt; $labels,
'show_ui' =&gt; true,
'show_admin_column' =&gt; true,
'update_count_callback' =&gt; '_update_post_term_count',
'query_var' =&gt; true,
'rewrite' =&gt; array( 'slug' =&gt; 'writer' ),
);
register_taxonomy( 'writer', 'book', $args );
}
?&gt;
&lt;/pre&gt;
== Basic Example ==
&lt;pre&gt;
&lt;?php
add_action( 'init', 'create_book_tax' );
function create_book_tax() {
register_taxonomy(
'genre',
'book',
array(
'label' =&gt; __( 'Genre' ),
'rewrite' =&gt; array( 'slug' =&gt; 'genre' ),
'hierarchical' =&gt; true,
)
);
}
?&gt;
&lt;/pre&gt;
Note: If you want to ensure that your custom taxonomy behaves like a tag, you must add the option 'update_count_callback' =&gt; '_update_post_term_count'. Not doing so will result in multiple comma-separated items added at once being saved as a single value, not as separate values. This can cause undue stress when using get_the_term_list and other term display functions.
==Reserved Terms==
Avoiding the following reserved terms is particularly important if you are passing the term through the $_GET or $_POST array. Doing so can cause WordPress to respond with a 404 error without any other hint or explanation.
* attachment
* attachment_id
* author
* author_name
* calendar
* cat
* category
* category__and
* category__in
* category__not_in
* category_name
* comments_per_page
* comments_popup
* customize_messenger_channel
* customized
* cpage
* day
* debug
* error
* exact
* feed
* hour
* link_category
* m
* minute
* monthnum
* more
* name
* nav_menu
* nonce
* nopaging
* offset
* order
* orderby
* p
* page
* page_id
* paged
* pagename
* pb
* perm
* post
* post__in
* post__not_in
* post_format
* post_mime_type
* post_status
* post_tag
* post_type
* posts
* posts_per_archive_page
* posts_per_page
* preview
* robots
* s
* search
* second
* sentence
* showposts
* static
* subpost
* subpost_id
* tag
* tag__and
* tag__in
* tag__not_in
* tag_id
* tag_slug__and
* tag_slug__in
* taxonomy
* tb
* term
* theme
* type
* w
* withcomments
* withoutcomments
* year
== Changelog ==
* [[Version_3.6|3.6.0]]:
** Add '&lt;tt&gt;not_found&lt;/tt&gt;' label.
* [[Version_3.5|3.5.0]]:
** Setting '&lt;tt&gt;show_ui&lt;/tt&gt;' to false hides UI for attachment taxonomies.
** Add '&lt;tt&gt;show_admin_column&lt;/tt&gt;' to allow automatic creation of taxonomy columns on associated post types.
* Since: [[Version 2.3|2.3.0]]
== Source File ==
&lt;tt&gt;register_taxonomy()&lt;/tt&gt; is located in {{Trac|wp-includes/taxonomy.php}}.
== Resources ==
* [http://generatewp.com/taxonomy/ WordPress Taxonomy Generator]
== Related ==
[http://codex.wordpress.org/Function_Reference/register_post_type register_post_type()]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_filter_comment" d:title="wp filter comment">
<d:index d:value="wp filter comment"/>
<h1>wp filter comment</h1>
<p>== Description ==
Filters and sanitizes comment data.
Sets the comment data '&lt;tt&gt;filtered&lt;/tt&gt;' field to true when finished. This can be checked as to whether the comment should be filtered and to keep from filtering the same comment more than once.
== Usage ==
%%%&lt;?php wp_filter_comment( $commentdata ) ?&gt;%%%
== Parameters ==
{{Parameter|$commentdata|array|Contains information on the comment.}}
== Return Values ==
; &lt;tt&gt;(array)&lt;/tt&gt; : Parsed comment information.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;pre_user_id&lt;/tt&gt;' hook on comment author's user ID
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;pre_comment_user_agent&lt;/tt&gt;' hook on comment author's user agent
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;pre_comment_author_name&lt;/tt&gt;' hook on comment author's name
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;pre_comment_content&lt;/tt&gt;' hook on the comment's content
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;pre_comment_user_ip&lt;/tt&gt;' hook on comment author's IP
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;pre_comment_author_url&lt;/tt&gt;' hook on comment author's URL
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;pre_comment_author_email&lt;/tt&gt;' hook on comment author's email address
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;tt&gt;wp_filter_comment()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&amp;nbsp;
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_category" d:title="get category">
<d:index d:value="get category"/>
<h1>get category</h1>
<p>{{Languages|
{{en| Function_Reference/get_category}}
{{ja|関数リファレンス/get_category}}
}}
== Description ==
Retrieves category data given a category ID or category object.
If you pass the &lt;tt&gt;$category&lt;/tt&gt; parameter an object, which is assumed to be the category row object retrieved the database. It will cache the category data.
If you pass &lt;tt&gt;$category&lt;/tt&gt; an integer of the category ID, then that category will be retrieved from the database, if it isn't already cached, and pass it back.
If you look at [[Function_Reference/get_term|&lt;tt&gt;get_term()&lt;/tt&gt;]], then both types will be passed through several filters and finally sanitized based on the &lt;tt&gt;$filter&lt;/tt&gt; parameter value.
The category will converted to maintain backwards compatibility.
&lt;b&gt;Note&lt;/b&gt;: use [[Function_Reference/get_term|&lt;tt&gt;get_term()&lt;/tt&gt;]] to get Link Categories based on their ID's. &lt;tt&gt;get_category&lt;/tt&gt; only returns Post Categories.
== Usage ==
%%%&lt;?php get_category( $category, $output, $filter ) ?&gt;%%%
== Parameters ==
{{Parameter|$category|integer&amp;#124;object|Category ID or Category row object}}
{{Parameter|$output|string|Constant OBJECT, ARRAY_A, or ARRAY_N|optional|OBJECT}}
{{Parameter|$filter|string|Default is raw or no WordPress defined filter will applied.|optional|'raw'}}
== Return Values ==
; (mixed) : Category data in type defined by &lt;tt&gt;$output&lt;/tt&gt; parameter.
== Examples ==
=== Print category data ===
&lt;pre&gt;$thisCat = get_category(get_query_var('cat'),false);
print_r($thisCat);&lt;/pre&gt;
produces;
&lt;pre&gt;stdClass Object
(
[term_id] =&gt; 85
[name] =&gt; Category Name
[slug] =&gt; category-name
[term_group] =&gt; 0
[term_taxonomy_id] =&gt; 85
[taxonomy] =&gt; category
[description] =&gt;
[parent] =&gt; 70
[count] =&gt; 0
[cat_ID] =&gt; 85
[category_count] =&gt; 0
[category_description] =&gt;
[cat_name] =&gt; Category Name
[category_nicename] =&gt; category-name
[category_parent] =&gt; 70
)&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/get_term|&lt;tt&gt;get_term()&lt;/tt&gt;]] Used to get the category data from the taxonomy.
* The &lt;code&gt;count&lt;/code&gt; attribute includes custom post types as well if the custom post type uses standard categories.
== Change Log ==
* Since: [[Version 1.5.1|1.5.1]]
== Source File ==
&lt;tt&gt;get_category()&lt;/tt&gt; is located in {{Trac|wp-includes/category.php}}.
== Related ==
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_signon" d:title="wp signon">
<d:index d:value="wp signon"/>
<h1>wp signon</h1>
<p>{{Languages|
{{en|Function Reference/wp_signon}}
{{it|Riferimento funzioni/wp_signon}}
}}
== Description ==
Authenticates a user with option to remember credentials. Replaces deprecated function [[Function_Reference/wp_login|wp_login]].
== Usage ==
%%% &lt;?php wp_signon( $credentials, $secure_cookie ) ?&gt; %%%
== Parameters ==
{{Parameter|$credentials|array|User info in order to sign on.|optional}}
{{Parameter|$secure_cookie|boolean|Whether to use secure cookie.|optional}}
'''NOTE:''' If you don't provide $credentials, wp_signon uses the $_POST variable (the keys being &quot;log&quot;, &quot;pwd&quot; and &quot;rememberme&quot;).
== Return Value ==
; '''(object)''' : Either [[Class_Reference/WP_Error|WP_Error]] on failure, or [[Class_Reference/WP_User|WP_User]] on success.
== Examples ==
This function and action can be placed in functions.php of the theme.
Using the hook after_setup_theme will make it run before the headers and cookies are sent, so it can set the needed cookie for login.
&lt;pre&gt;&lt;nowiki&gt;
function custom_login() {
$creds = array();
$creds['user_login'] = 'example';
$creds['user_password'] = 'plaintextpw';
$creds['remember'] = true;
$user = wp_signon( $creds, false );
if ( is_wp_error($user) )
echo $user-&gt;get_error_message();
}
// run it before the headers and cookies are sent
add_action( 'after_setup_theme', 'custom_login' );
&lt;/nowiki&gt;&lt;/pre&gt;
== Notes ==
*This function sends headers to the page. It must be run before any content is returned.
*This function sets an authentication cookie. Users will not be logged in if it is not sent.
== Change Log ==
Since: 2.5.0
== Source File ==
&lt;tt&gt;wp_signon()&lt;/tt&gt; is located in {{Trac|wp-includes/user.php}}.
== Related ==
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="wp_throttle_comment_flood" d:title="wp throttle comment flood">
<d:index d:value="wp throttle comment flood"/>
<h1>wp throttle comment flood</h1>
<p>{{Languages|
{{en|Function Reference/wp_throttle_comment_flood}}
{{it|Riferimento funzioni/wp_throttle_comment_flood}}
}}
== Description ==
Determine whether comment should be blocked because of comment flood.
== Usage ==
%%%&lt;?php wp_throttle_comment_flood( $block, $time_lastcomment, $time_newcomment ) ?&gt;%%%
== Parameters ==
{{Parameter|$block|boolean|True if plugin is blocking comments.}}
{{Parameter|$time_lastcomment|integer|Timestamp for last comment.}}
{{Parameter|$time_newcomment|integer|Timestamp for new comment.}}
== Return Values ==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : Returns true if &lt;tt&gt;$block&lt;/tt&gt; is true or if &lt;tt&gt;$block&lt;/tt&gt; is false and &lt;tt&gt;$time_newcomment - $time_lastcomment &amp;lt; 15&lt;/tt&gt;. Returns false otherwise.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;wp_throttle_comment_flood()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&amp;nbsp;
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_new_comment" d:title="wp new comment">
<d:index d:value="wp new comment"/>
<h1>wp new comment</h1>
<p>== Description ==
Adds a new comment to the database.
Filters new comment to ensure that the fields are sanitized and valid before inserting comment into database. Calls &lt;tt&gt;'comment_post'&lt;/tt&gt; action with comment ID and whether comment is approved by WordPress. Also has &lt;tt&gt;'preprocess_comment'&lt;/tt&gt; filter for processing the comment data before the function handles it.
== Usage ==
%%%&lt;?php wp_new_comment( $commentdata ) ?&gt;%%%
== Parameters ==
{{Parameter|$commentdata|array|Contains information on the comment.}}
== Return Values ==
; &lt;tt&gt;(integer)&lt;/tt&gt; : The ID of the comment after adding.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls &lt;tt&gt;'preprocess_comment'&lt;/tt&gt; hook on &lt;tt&gt;$commentdata&lt;/tt&gt; parameter array before processing
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] Calls &lt;tt&gt;'comment_post'&lt;/tt&gt; hook on &lt;tt&gt;$comment_ID&lt;/tt&gt; returned from adding the comment and if the comment was approved.
* Uses: [[Function_Reference/wp_filter_comment|&lt;tt&gt;wp_filter_comment()&lt;/tt&gt;]] Used to filter comment before adding comment.
* Uses: [[Function_Reference/wp_allow_comment|&lt;tt&gt;wp_allow_comment()&lt;/tt&gt;]] checks to see if comment is approved.
* Uses: [[Function_Reference/wp_insert_comment|&lt;tt&gt;wp_insert_comment()&lt;/tt&gt;]] Does the actual comment insertion to the database.
* Uses: [[Function_Reference/wp_notify_moderator|&lt;tt&gt;wp_notify_moderator()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_notify_postauthor|&lt;tt&gt;wp_notify_postauthor()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_get_comment_status|&lt;tt&gt;wp_get_comment_status()&lt;/tt&gt;]]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_new_comment()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_set_comment_status" d:title="wp set comment status">
<d:index d:value="wp set comment status"/>
<h1>wp set comment status</h1>
<p>== Description ==
Sets the status of a comment.
The &lt;tt&gt;'wp_set_comment_status'&lt;/tt&gt; action is called after the comment is handled and will only be called, if the comment status is either &lt;tt&gt;'hold'&lt;/tt&gt;, &lt;tt&gt;'approve'&lt;/tt&gt;, or &lt;tt&gt;'spam'&lt;/tt&gt;. If the comment status is not in the list, then false is returned and if the status is &lt;tt&gt;'delete'&lt;/tt&gt;, then the comment is deleted without calling the action.
== Usage ==
%%%&lt;?php wp_set_comment_status( $comment_id, $comment_status ) ?&gt;%%%
== Parameters ==
{{Parameter|$comment_id|integer|Comment ID.}}
{{Parameter|$comment_status|string|New comment status, either &lt;tt&gt;'hold'&lt;/tt&gt;, &lt;tt&gt;'approve'&lt;/tt&gt;, &lt;tt&gt;'spam'&lt;/tt&gt;, or &lt;tt&gt;'trash'&lt;/tt&gt;.}}
== Return Values ==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : False on failure or deletion and true on success.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/wp_transition_comment_status|&lt;tt&gt;wp_transition_comment_status()&lt;/tt&gt;]] Passes new and old comment status along with &lt;tt&gt;$comment&lt;/tt&gt; object
* Uses: [[Function_Reference/wp_notify_postauthor|&lt;tt&gt;wp_notify_postauthor()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_delete_comment|&lt;tt&gt;wp_delete_comment()&lt;/tt&gt;]]
* Uses: [[Function_Reference/clean_comment_cache|&lt;tt&gt;clean_comment_cache()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_comment|&lt;tt&gt;get_comment()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_transition_comment_status|&lt;tt&gt;wp_transition_comment_status()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_update_comment_count|&lt;tt&gt;wp_update_comment_count()&lt;/tt&gt;]]
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
== Change Log ==
* Since 2.9: $comment_status: the parameter 'delete' was replaced with 'trash'. Comments will be added to the Comment Trash instead of being purged from the database.
* Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_set_comment_status()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&amp;nbsp;
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_update_comment" d:title="wp update comment">
<d:index d:value="wp update comment"/>
<h1>wp update comment</h1>
<p>== Description ==
Updates an existing comment in the database.
Filters the comment and makes sure certain fields are valid before updating.
== Usage ==
%%%&lt;?php wp_update_comment( $commentarr ) ?&gt;%%%
== Parameters ==
{{Parameter|$commentarr|array|Contains information on the comment. See [[Function_Reference/get_comment|&lt;tt&gt;get_comment()&lt;/tt&gt;]] for a list of valid attributes.}}
== Return Values ==
; &lt;tt&gt;(integer)&lt;/tt&gt; : Comment was updated if value is 1, or was not updated if value is 0.
== Examples ==
=== Unapproving a comment ===
&lt;pre&gt;
&lt;?php
$commentarr = array();
$commentarr['comment_ID'] = 123; // This is the only required array key
$commentarr['comment_approved'] = 0;
wp_update_comment( $commentarr );
?&gt;
&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/wp_transition_comment_status|&lt;tt&gt;wp_transition_comment_status()&lt;/tt&gt;]] Passes new and old comment status along with &lt;tt&gt;$comment&lt;/tt&gt; object
* Uses: [[Function_Reference/get_comment|&lt;tt&gt;get_comment()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_filter_comment|&lt;tt&gt;wp_filter_comment()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_gmt_from_date|&lt;tt&gt;get_gmt_from_date()&lt;/tt&gt;]]
* Uses: [[Function_Reference/clean_comment_cache|&lt;tt&gt;clean_comment_cache()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_update_comment_count|&lt;tt&gt;wp_update_comment_count()&lt;/tt&gt;]]
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] on &lt;tt&gt;'edit_comment'&lt;/tt&gt; on &lt;tt&gt;$comment_ID&lt;/tt&gt;.
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_update_comment()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_update_comment_count" d:title="wp update comment count">
<d:index d:value="wp update comment count"/>
<h1>wp update comment count</h1>
<p>== Description ==
Updates the comment count for post(s).
When &lt;tt&gt;$do_deferred&lt;/tt&gt; is &lt;tt&gt;false&lt;/tt&gt; (is by default) and the comments have been set to be deferred, &lt;tt&gt;$post_id&lt;/tt&gt; will be added to a queue, which will be updated at a later date and only updated once per post ID.
If the comments have not be set up to be deferred, then the post will be updated. When &lt;tt&gt;$do_deferred&lt;/tt&gt; is set to true, then all previous deferred post IDs will be updated along with the current &lt;tt&gt;$post_id&lt;/tt&gt;.
== Usage ==
%%%&lt;?php wp_update_comment_count( $post_id, $do_deferred ) ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|Post ID}}
{{Parameter|$do_deferred|boolean|Whether to process previously deferred post comment counts|optional|false}}
== Return Values ==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* See [[Function_Reference/wp_update_comment_count_now|&lt;tt&gt;wp_update_comment_count_now()&lt;/tt&gt;]] for what could cause a false return value
* Uses: [[Function_Reference/wp_update_comment_count_now|&lt;tt&gt;wp_update_comment_count_now()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_defer_comment_counting|&lt;tt&gt;wp_defer_comment_counting()&lt;/tt&gt;]]
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;wp_update_comment_count()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&amp;nbsp;
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="discover_pingback_server_uri" d:title="discover pingback server uri">
<d:index d:value="discover pingback server uri"/>
<h1>discover pingback server uri</h1>
<p>== Description ==
Finds a pingback server URI based on the given URL.
Checks the xhtml for the &lt;tt&gt;rel=&quot;pingback&quot;&lt;/tt&gt; link and x-pingback headers. It does a check for the x-pingback headers first and returns that, if available. The check for the &lt;tt&gt;rel=&quot;pingback&quot;&lt;/tt&gt; has more overhead than just the header.
== Usage ==
%%%&lt;?php discover_pingback_server_uri( $url, $deprecated ) ?&gt;%%%
== Parameters ==
{{Parameter|$url|string|URL to ping.}}
{{Parameter|$deprecated|integer||Not Used.}}
== Return Values ==
; &lt;tt&gt;(boolean&amp;#124;string)&lt;/tt&gt; : False on failure, string containing URI on success.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/wp_remote_get|&lt;tt&gt;wp_remote_get()&lt;/tt&gt;]]
* Uses: [[Function_Reference/is_wp_error|&lt;tt&gt;is_wp_error()&lt;/tt&gt;]]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;discover_pingback_server_uri()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="do_all_pings" d:title="do all pings">
<d:index d:value="do all pings"/>
<h1>do all pings</h1>
<p>== Description ==
Perform all pingbacks, enclosures, trackbacks, and send to pingback services.
== Usage ==
%%%&lt;?php do_all_pings() ?&gt;%%%
== Parameters ==
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* See Reads from the [[Database_Description#Table:_wp_posts|&lt;tt&gt;_posts&lt;/tt&gt; table]] from the database.
* Uses: [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* Uses: [[Function_Reference/pingback|&lt;tt&gt;pingback()&lt;/tt&gt;]]
* Uses: [[Function_Reference/do_enclose|&lt;tt&gt;do_enclose()&lt;/tt&gt;]]
* Uses: [[Function_Reference/do_trackbacks|&lt;tt&gt;do_trackbacks()&lt;/tt&gt;]]
* Uses: [[Function_Reference/generic_ping|&lt;tt&gt;generic_ping()&lt;/tt&gt;]]
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;do_all_pings()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="do_trackbacks" d:title="do trackbacks">
<d:index d:value="do trackbacks"/>
<h1>do trackbacks</h1>
<p>== Description ==
Perform [[Glossary#Trackback|trackbacks]].
== Usage ==
%%%&lt;?php do_trackbacks( $post_id ) ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|Post ID to do trackbacks on.}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* See Reads from and may update the &lt;tt&gt;_posts&lt;/tt&gt; table from the database.
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_to_ping|&lt;tt&gt;get_to_ping()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_pung|&lt;tt&gt;get_pung()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_html_excerpt|&lt;tt&gt;wp_html_excerpt()&lt;/tt&gt;]]
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] on 'the_content' on 'post_content'
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] on 'the_excerpt' on 'post_excerpt'
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] on 'the_title' on 'post_title'
* Uses: [[Function_Reference/trackback|&lt;tt&gt;trackback()&lt;/tt&gt;]]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;do_trackbacks()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="generic_ping" d:title="generic ping">
<d:index d:value="generic ping"/>
<h1>generic ping</h1>
<p>== Description ==
Sends [[Glossary#Ping|pings]] to all of the ping site services.
== Usage ==
%%%&lt;?php generic_ping( $post_id ) ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|Post ID. Only used as a return velue.|optional|0}}
== Return Values ==
; &lt;tt&gt;(integer)&lt;/tt&gt; : Returns &lt;tt&gt;$post_id&lt;/tt&gt; unaltered.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* The &lt;tt&gt;$post_id&lt;/tt&gt; and return values do not &lt;strong&gt;have&lt;/strong&gt; to be an &lt;tt&gt;integer&lt;/tt&gt; data types, but in WordPress &lt;tt&gt;$post_id&lt;/tt&gt; is always an &lt;tt&gt;integer&lt;/tt&gt; data type.
* Uses: [[Function_Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]] to get all ping sites.
* Uses: [[Function_Reference/weblog_ping|&lt;tt&gt;weblog_ping()&lt;/tt&gt;]] for each ping site.
== Change Log ==
Since: 1.2.0
== Source File ==
&lt;tt&gt;generic_ping()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="pingback" d:title="pingback">
<d:index d:value="pingback"/>
<h1>pingback</h1>
<p>== Description ==
[[Glossary#Pingback|Pings back]] the links found in a post.
Includes &lt;tt&gt;wp-include/class-IXR.php&lt;/tt&gt; file if not already included.
== Usage ==
%%%&lt;?php pingback( $content, $post_ID ) ?&gt;%%%
== Parameters ==
{{Parameter|$content|string|Post content to check for links.}}
{{Parameter|$post_ID|integer|Post ID.}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;string&lt;/tt&gt;) &lt;tt&gt;$wp_version&lt;/tt&gt; holds the installed WordPress version number.
* Uses: [[XML-RPC_Support|IXR_Client]] WordPress class.
* Uses: [[Function_Reference/discover_pingback_server_uri|&lt;tt&gt;discover_pingback_server_uri()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_pung|&lt;tt&gt;get_pung()&lt;/tt&gt;]]
* Uses: [[Function_Reference/url_to_postid|&lt;tt&gt;url_to_postid()&lt;/tt&gt;]]
* Uses: [[Function_Reference/is_local_attachment|&lt;tt&gt;is_local_attachment()&lt;/tt&gt;]]
* Uses: [[Function_Reference/do_action_ref_array|&lt;tt&gt;do_action_ref_array()&lt;/tt&gt;]] on &lt;tt&gt;'pre_ping'&lt;/tt&gt; on &lt;tt&gt;'post_links'&lt;/tt&gt; and on [[Function_Reference/pung|&lt;tt&gt;pung()&lt;/tt&gt;]] result.
* Uses: [[Function_Reference/get_permalink|&lt;tt&gt;get_permalink()&lt;/tt&gt;]]
* Uses: [[Function_Reference/add_ping|&lt;tt&gt;add_ping()&lt;/tt&gt;]]
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;pingback()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
[[Function Reference/trackback url|trackback_url]]
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="privacy_ping_filter" d:title="privacy ping filter">
<d:index d:value="privacy ping filter"/>
<h1>privacy ping filter</h1>
<p>== Description ==
Check whether blog is public before returning sites.
== Usage ==
%%%&lt;?php privacy_ping_filter( $sites ) ?&gt;%%%
== Parameters ==
{{Parameter|$sites|mixed|Will return if blog is public, will not return if not public.}}
== Return Values ==
; &lt;tt&gt;(mixed)&lt;/tt&gt; : Returns empty string (&lt;tt&gt;&amp;#39;&amp;#39;&lt;/tt&gt;) if blog is not public. Returns value in &lt;tt&gt;$sites&lt;/tt&gt; if site is public.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]] to check &lt;tt&gt;'blog_public'&lt;/tt&gt; option.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;privacy_ping_filter()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="weblog_ping" d:title="weblog ping">
<d:index d:value="weblog ping"/>
<h1>weblog ping</h1>
<p>== Description ==
Send a [[Glossary#Pingback|pingback]].
== Usage ==
%%%&lt;?php weblog_ping( $server, $path ) ?&gt;%%%
== Parameters ==
{{Parameter|$server|string|Host of blog to connect to.|optional|&amp;#39;&amp;#39;}}
{{Parameter|$path|string|Path to send the ping.|optional|&amp;#39;&amp;#39;}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;string&lt;/tt&gt;) &lt;tt&gt;$wp_version&lt;/tt&gt; holds the installed WordPress version number.
* Uses: [[XML-RPC_Support|IXR_Client]] WordPress class.
* Uses: [[Function_Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]] to retrieve the &lt;tt&gt;'home'&lt;/tt&gt; option.
* Uses: [[Function_Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]] to retrieve the &lt;tt&gt;'blogname'&lt;/tt&gt; option.
* Uses: [[Function_Reference/get_bloginfo|&lt;tt&gt;get_bloginfo()&lt;/tt&gt;]] to retrieve the &lt;tt&gt;'rss2_url'&lt;/tt&gt;.
== Change Log ==
Since: 1.2.0
== Source File ==
&lt;tt&gt;weblog_ping()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="do_enclose" d:title="do enclose">
<d:index d:value="do enclose"/>
<h1>do enclose</h1>
<p>== Description ==
Check content for video and audio links to add as [http://en.wikipedia.org/wiki/RSS_enclosure enclosures].
Will not add enclosures that have already been added.
== Usage ==
%%%&lt;?php do_enclose( $content, $post_ID ) ?&gt;%%%
== Parameters ==
{{Parameter|$content|string|Post Content}}
{{Parameter|$post_ID|integer|Post ID}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] to read and condtionally insert records on [[Database_Description#Table:_wp_postmeta|&lt;tt&gt;_postmeta table&lt;/tt&gt;]] in the database.
* Uses: [[Function_Reference/debug_fopen|&lt;tt&gt;debug_fopen()&lt;/tt&gt;]] to open 'enclosures.log' file.
* Uses: [[Function_Reference/debug_fwrite|&lt;tt&gt;debug_fwrite()&lt;/tt&gt;]] to write to 'enclosures.log' file.
* Uses: [[Function_Reference/get_enclosed|&lt;tt&gt;get_enclosed()&lt;/tt&gt;]]
* Uses: [[Function_Reference/wp_get_http_headers|&lt;tt&gt;wp_get_http_headers()&lt;/tt&gt;]]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;do_enclose()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="add_ping" d:title="add ping">
<d:index d:value="add ping"/>
<h1>add ping</h1>
<p>== Description ==
Add a URL to those already pung.
== Usage ==
%%%&lt;?php add_ping( $post_id, $uri ) ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|Post ID.}}
{{Parameter|$uri|string|Ping URI.}}
== Return Values ==
; (integer) : Count of updated rows.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] to read and to update the [[Database_Description#Table:_wp_posts|&lt;tt&gt;_posts table&lt;/tt&gt;]] in database.
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] on 'add_ping'
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;add_ping()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_enclosed" d:title="get enclosed">
<d:index d:value="get enclosed"/>
<h1>get enclosed</h1>
<p>== Description ==
Retrieve [http://en.wikipedia.org/wiki/RSS_enclosure enclosures] already enclosed for a post.
== Usage ==
%%%&lt;?php get_enclosed( $post_id ) ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|Post ID.}}
== Return Values ==
; (array) : List of enclosures.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_post_custom|&lt;tt&gt;get_post_custom()&lt;/tt&gt;]] on &lt;tt&gt;$post_id&lt;/tt&gt;.
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] on &lt;tt&gt;'get_enclosed'&lt;/tt&gt; on enclosures.
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_enclosed()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_pung" d:title="get pung">
<d:index d:value="get pung"/>
<h1>get pung</h1>
<p>== Description ==
Retrieve URLs already [[Glossary#Ping|pinged]] for a post.
== Usage ==
%%%&lt;?php get_pung( $post_id ) ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|Post ID.}}
== Return Values ==
; (array) : Returns array of pinged URLs.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
&lt;?php
$pinged_posts = get_pung( $post-&gt;ID );
foreach ( $pinged_posts as $pinged_post ) :
if (!empty($pinged_post) ) {
echo 'Incoming Link: &lt;a href=&quot;'.$pinged_post.'&quot; rel=&quot;external&quot;&gt;'.$pinged_post.'&lt;/a&gt;';
}
endforeach;
?&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] to retrieve pinged URLs from the [[Database_Description#Table:_wp_posts|&lt;tt&gt;_posts table&lt;/tt&gt;]] in the database.
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] on &lt;tt&gt;'get_pung'&lt;/tt&gt; on pinged URLs.
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_pung()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_to_ping" d:title="get to ping">
<d:index d:value="get to ping"/>
<h1>get to ping</h1>
<p>== Description ==
Retrieve URLs that need to be [[Glossary#Ping|pinged]].
== Usage ==
%%%&lt;?php get_to_ping( $post_id ) ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|Post ID}}
== Return Values ==
; (array) : Returns array of URLs that need to be pinged.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] to read &lt;tt&gt;'to_ping'&lt;/tt&gt; field from [[Database_Description#Table:_wp_posts|&lt;tt&gt;_posts table&lt;/tt&gt;]] from database.
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] on &lt;tt&gt;'get_to_ping'&lt;/tt&gt; on the URLs that need to be pinged.
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_to_ping()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="trackback_url_list" d:title="trackback url list">
<d:index d:value="trackback url list"/>
<h1>trackback url list</h1>
<p>== Description ==
Do [[Glossary#Trackback|trackbacks]] for a list of URLs.
== Usage ==
%%%&lt;?php trackback_url_list( $tb_list, $post_id ) ?&gt;%%%
== Parameters ==
{{Parameter|$tb_list|string|Comma separated list of URLs}}
{{Parameter|$post_id|integer|Post ID}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/wp_get_single_post|&lt;tt&gt;wp_get_single_post()&lt;/tt&gt;]] on &lt;tt&gt;$post_id&lt;/tt&gt;.
* Uses: [[Function_Reference/trackback|&lt;tt&gt;trackback()&lt;/tt&gt;]] on each trackback url.
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;trackback_url_list()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="trackback" d:title="trackback">
<d:index d:value="trackback"/>
<h1>trackback</h1>
<p>== Description ==
Send a [[Glossary#Trackback|trackback]].
Updates database when sending trackback to prevent duplicates.
== Usage ==
%%%&lt;?php trackback( $trackback_url, $title, $excerpt, $ID ) ?&gt;%%%
== Parameters ==
{{Parameter|$trackback_url|string|URL to send trackbacks.}}
{{Parameter|$title|string|Title of post.}}
{{Parameter|$excerpt|string|Excerpt of post.}}
{{Parameter|$ID|integer|Post ID.}}
== Return Values ==
; (mixed) : Database query from update.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] to update the [[Database_Description#Table:_wp_posts|&lt;tt&gt;_posts table&lt;/tt&gt;]] from the database.
* Uses: [[Function_Reference/get_permalink|&lt;tt&gt;get_permalink()&lt;/tt&gt;]] on &lt;tt&gt;$ID&lt;/tt&gt;.
* Uses: [[Function_Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]] to retrieve the &lt;tt&gt;'blogname'&lt;/tt&gt; option.
* Uses: [[Function_Reference/wp_remote_post|&lt;tt&gt;wp_remote_post()&lt;/tt&gt;]] on &lt;tt&gt;$trackback_url&lt;/tt&gt;.
* Uses: [[Function_Reference/is_wp_error|&lt;tt&gt;is_wp_error()&lt;/tt&gt;]]
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;trackback()&lt;/tt&gt; is located in {{Trac|wp-includes/comment.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_stylesheet" d:title="get stylesheet">
<d:index d:value="get stylesheet"/>
<h1>get stylesheet</h1>
<p>{{Languages|
{{en|Function Reference/get_stylesheet}}
{{it|Riferimento funzioni/get_stylesheet}}
}}
== Description ==
Retrieve name of the current [http://en.wikipedia.org/wiki/Cascading_Style_Sheets stylesheet].
The [[Glossary#Theme|theme]] name that the administrator has currently set the front end theme as.
For all intents and purposes, the template name and the stylesheet name are going to be the same for most cases. In the event that you use a child theme, that is the name that will be returned, rather than the parent.
== Usage ==
%%%&lt;?php get_stylesheet(); ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Stylesheet name.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls 'stylesheet' filter on stylesheet name.
* Uses: [[Function_Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]] to retrieve the 'stylesheet' option.
* In the event a child theme is being used, that is the name that will be returned, not the parent theme name (use [[Function_Reference/get_template_directory|&lt;tt&gt; get_template_directory()&lt;/tt&gt;]] instead if you want the parent directory)
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_stylesheet()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_stylesheet_directory" d:title="get stylesheet directory">
<d:index d:value="get stylesheet directory"/>
<h1>get stylesheet directory</h1>
<p>== Description ==
Retrieve [http://en.wikipedia.org/wiki/Cascading_Style_Sheets stylesheet] directory Path for the current theme/child theme.
&lt;b&gt;Note:&lt;/b&gt; Does not contain a trailing slash.
Returns an absolute server path (eg: /home/user/public_html/wp-content/themes/my_theme), not a URI.
To retrieve the URI of the stylesheet directory use [[Function_Reference/get_stylesheet_directory_uri|get_stylesheet_directory_uri()]] instead.
== Usage ==
%%%&lt;?php get_stylesheet_directory() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
{{Return|uri|string|Stylesheet directory Absolute Path}}.
== Examples ==
&lt;b&gt;Include a PHP file&lt;/b&gt;
&lt;pre&gt;
&lt;?php include( get_stylesheet_directory() . '/includes/myfile.php'); ?&gt;
&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls &lt;tt&gt;'stylesheet_directory'&lt;/tt&gt; filter on stylesheet path and name.
* Uses: [[Function_Reference/get_stylesheet|&lt;tt&gt;get_stylesheet()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_theme_root|&lt;tt&gt;get_theme_root()&lt;/tt&gt;]]
* In the event a child theme is being used, that is the directory that will be returned, not the parent theme directory (use [[Function_Reference/get_template_directory|&lt;tt&gt; get_template_directory()&lt;/tt&gt;]] instead if you want the parent directory)
== Change Log ==
* Since: [[Version 1.5|1.5.0]]
== Source File ==
&lt;tt&gt;get_stylesheet_directory()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
{{Theme Paths}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_stylesheet_directory_uri" d:title="get stylesheet directory uri">
<d:index d:value="get stylesheet directory uri"/>
<h1>get stylesheet directory uri</h1>
<p>== Description ==
Retrieve [http://en.wikipedia.org/wiki/Cascading_Style_Sheets stylesheet] directory URI for the current theme/child theme. Checks for SSL.
&lt;b&gt;Note:&lt;/b&gt; Does not contain a trailing slash.
Note that this returns a properly-formed [http://en.wikipedia.org/wiki/Uniform_Resource_Identifier URI]; in other words, it will be a web-address (starting with http:// or https:// for SSL). As such, it is most appropriately used for links, referencing additional stylesheets, or probably most commonly, images.
In the event a child theme is being used, this function will return the child's theme directory URI.
Use [[Function_Reference/get_template_directory_uri|&lt;tt&gt; get_template_directory_uri()&lt;/tt&gt;]] to avoid being overridden by a child theme.
If you want to include a local file in PHP, use [[Function_Reference/get_stylesheet_directory|get_stylesheet_directory()]] instead.
== Usage ==
'''Use the URI'''
%%%&lt;?php get_stylesheet_directory_uri(); ?&gt;%%%
'''Output the URI'''
%%%&lt;?php echo get_stylesheet_directory_uri(); ?&gt;%%%
== Parameters ==
None.
== Return Values ==
{{Return|uri|string|Stylesheet directory URI}}.
== Examples ==
&lt;b&gt;Image (HTML)&lt;/b&gt;
&lt;pre&gt;
&lt;img src=&quot;&lt;?php echo get_stylesheet_directory_uri() ?&gt;/images/aternus.png&quot; alt=&quot;&quot; title=&quot;&quot; width=&quot;&quot; height=&quot;&quot; /&gt;
&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls &lt;tt&gt;'stylesheet_directory_uri'&lt;/tt&gt; filter on stylesheet path and name.
* Uses: [[Function_Reference/get_stylesheet|&lt;tt&gt;get_stylesheet()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_theme_root|&lt;tt&gt;get_theme_root()&lt;/tt&gt;]]
== Change Log ==
* Since: [[Version 1.5|1.5.0]]
== Source File ==
&lt;tt&gt;get_stylesheet_directory_uri()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
* [[Function Reference/get_stylesheet_uri|&lt;tt&gt;get_stylesheet_uri();&lt;/tt&gt;]]
* [[Function Reference/get_bloginfo|&lt;tt&gt;get_bloginfo( 'stylesheet_directory' );&lt;/tt&gt;]]
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_stylesheet_uri" d:title="get stylesheet uri">
<d:index d:value="get stylesheet uri"/>
<h1>get stylesheet uri</h1>
<p>{{Languages|
{{en|Function Reference/get stylesheet uri}}
{{ja|Function Reference/get stylesheet uri}}
}}
== Description ==
Retrieves the URI of the current [[Glossary#Theme|theme]] [http://en.wikipedia.org/wiki/Cascading_Style_Sheets stylesheet].
The stylesheet file name is &lt;tt&gt;'style.css'&lt;/tt&gt; which is appended to [[Function_Reference/get_stylesheet_directory_uri|&lt;tt&gt;get_stylesheet_directory_uri()&lt;/tt&gt;]] path.
== Usage ==
%%%&lt;?php get_stylesheet_uri(); ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Returns URI of current theme stylesheet.
== Examples ==
To output the URL
%%%&lt;?php echo get_stylesheet_uri(); ?&gt;%%%
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls &lt;tt&gt;'stylesheet_uri'&lt;/tt&gt; filter on stylesheet URI path and stylesheet directory URI.
* Uses: [[Function_Reference/get_stylesheet_directory_uri|&lt;tt&gt;get_stylesheet_directory_uri()&lt;/tt&gt;]]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_stylesheet_uri()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_locale_stylesheet_uri" d:title="get locale stylesheet uri">
<d:index d:value="get locale stylesheet uri"/>
<h1>get locale stylesheet uri</h1>
<p>== Description ==
Retrieve localized stylesheet URI.
The [http://en.wikipedia.org/wiki/Cascading_Style_Sheets stylesheet] directory for the localized stylesheet files are located, by default, in the base [[Glossary#Theme|theme]] directory. The name of the locale file will be the locale followed by &lt;tt&gt;'.css'&lt;/tt&gt;. If that does not exist, then the text direction stylesheet will be checked for existence, for example &lt;tt&gt;'ltr.css'&lt;/tt&gt;.
The theme may change the location of the stylesheet directory by either using the &lt;tt&gt;'stylesheet_directory_uri'&lt;/tt&gt; filter or the &lt;tt&gt;'locale_stylesheet_uri'&lt;/tt&gt; filter. If you want to change the location of the stylesheet files for the entire WordPress workflow, then change the former. If you just have the locale in a separate folder, then change the latter.
== Usage ==
%%%&lt;?php get_locale_stylesheet_uri() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Returns localized stylesheet URI.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) &lt;tt&gt;$wp_locale&lt;/tt&gt; handles the date and time locales.
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls &lt;tt&gt;'locale_stylesheet_uri'&lt;/tt&gt; filter on stylesheet URI path and stylesheet directory URI.
* Uses: [[Function_Reference/get_stylesheet_directory_uri|&lt;tt&gt;get_stylesheet_directory_uri()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_stylesheet_directory|&lt;tt&gt;get_stylesheet_directory()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_locale|&lt;tt&gt;get_locale()&lt;/tt&gt;]]
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;get_locale_stylesheet_uri()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_template" d:title="get template">
<d:index d:value="get template"/>
<h1>get template</h1>
<p>== Description ==
Retrieves the directory name of the current [[Glossary#Theme|theme]], without the trailing slash.
In the case a child theme is being used, the directory name of the parent theme will be returned. Use [[Function Reference/get_stylesheet|&lt;tt&gt;get_stylesheet()&lt;/tt&gt;]] to get the directory name of the child theme.
== Usage ==
%%%&lt;?php get_template() ?&gt;%%%
== Parameters ==
This tag has no parameters.
== Return Values ==
{{Return||string| Directory name of the current theme (without the trailing slash). Its the same as the name of the theme.}}.
== Examples ==
For example, if your current active theme is named 'heli', then:
%%%&lt;?php echo get_template() ?&gt;%%%
will output
%%%heli%%%
== Notes ==
* Uses: [[Function Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]] to retrieve the [[Option_Reference#Themes|template]] option.
* Uses: [[Function Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] to apply the [[Plugin API/Filter Reference/template|template]] filters on the retrieved ''template'' option.
== Change Log ==
Since: [[Version_1.5 | 1.5.0]]
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_template()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}, line 241.
== Related ==
{{Theme Paths}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_template_directory_uri" d:title="get template directory uri">
<d:index d:value="get template directory uri"/>
<h1>get template directory uri</h1>
<p>== Description ==
Retrieve [[Templates|template]] directory URI for the current theme. Checks for SSL.
&lt;b&gt;Note:&lt;/b&gt; Does not return a trailing slash following the directory address.
In the event a [[Child_Themes|child theme]] is being used, the parent theme directory URI will be returned, &lt;tt&gt;get_template_directory_uri()&lt;/tt&gt; should be used for resources that are not intended to be included in/over-ridden by a child theme. Use [[Function_Reference/get_stylesheet_directory_uri|&lt;tt&gt; get_stylesheet_directory_uri()&lt;/tt&gt;]] to include resources that are intended to be included in/over-ridden by the Child Theme.
== Usage ==
'''Use the URI'''
%%%&lt;?php get_template_directory_uri(); ?&gt;%%%
'''Output the URI'''
%%%&lt;?php echo get_template_directory_uri(); ?&gt;%%%
== Parameters ==
None.
== Return Values ==
{{Return|uri|string|Template directory URI}}.
== Examples ==
Using get_template_directory_uri() to enqueue a script with the correct path
&lt;?php
function my_scripts_method() {
wp_enqueue_script(
'custom_script',
get_template_directory_uri() . '/js/custom_script.js',
array('jquery')
);
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
?&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls 'template_directory_uri' filter on template directory URI path and template name.
* Uses: [[Function_Reference/get_template|&lt;tt&gt;get_template()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_theme_root_uri|&lt;tt&gt;get_theme_root_uri()&lt;/tt&gt;]]
== Change Log ==
* Since: [[Version 1.5|1.5.0]]
== Source File ==
&lt;tt&gt;get_template_directory_uri()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_themes" d:title="get themes">
<d:index d:value="get themes"/>
<h1>get themes</h1>
<p>{{Deprecated|new_function()=wp_get_themes}}
== Description ==
Retrieve list of [[Glossary#Theme|themes]] with theme data in theme directory.
The theme is broken if it doesn't have a parent theme and is missing either &lt;tt&gt;style.css&lt;/tt&gt; or &lt;tt&gt;index.php&lt;/tt&gt;. If the theme has a parent theme, it is broken if it is missing &lt;tt&gt;style.css&lt;/tt&gt;; &lt;tt&gt;index.php&lt;/tt&gt; is optional. The broken theme list is saved in the &lt;tt&gt;$wp_broken_themes&lt;/tt&gt; global, which is displayed on the theme list in the administration panels.
== Usage ==
%%%&lt;?php get_themes() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (array) : Theme list with theme data.
== Notes ==
* Uses global: (&lt;tt&gt;array&lt;/tt&gt;) &lt;tt&gt;$wp_themes&lt;/tt&gt; holds working themes list.
== Change Log ==
Since: 1.5.0. Deprecated since 3.4.0.
== Source File ==
&lt;tt&gt;get_themes()&lt;/tt&gt; is located in {{Trac|wp-includes/deprecated.php}}.
== Related ==
* [[Function_Reference/get_theme]]
* [[Function_Reference/wp_get_theme]]
* [[Function_Reference/wp_get_themes]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_theme" d:title="get theme">
<d:index d:value="get theme"/>
<h1>get theme</h1>
<p>{{Deprecated|new_function()=wp_get_theme}}
== Description ==
Retrieve [[Glossary#Theme|theme]] data.
== Usage ==
%%%&lt;?php get_theme( $theme ) ?&gt;%%%
== Parameters ==
{{Parameter|$theme|string|Theme name.}}
== Return Values ==
; (array&amp;#124;null) : Null, if theme name does not exist. Theme data, if exists.
== Notes ==
* Uses: [[Function_Reference/get_themes|&lt;tt&gt;get_themes()&lt;/tt&gt;]]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_theme()&lt;/tt&gt; is located in {{Trac|wp-includes/deprecated.php}}.
== Related ==
* [[Function_Reference/get_themes]]
* [[Function_Reference/wp_get_theme]]
* [[Function_Reference/wp_get_themes]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_theme_root" d:title="get theme root">
<d:index d:value="get theme root"/>
<h1>get theme root</h1>
<p>{{Languages|
{{en|Function Reference/get theme root}}
{{ja|Function Reference/get theme root}}
}}
== Description ==
Retrieves the absolute path to the [[Glossary#Theme|themes]] directory, without the trailing slash.
== Usage ==
%%%&lt;?php get_theme_root(); ?&gt;%%%
== Parameters ==
{{Parameter|$stylesheet_or_template|string|The stylesheet or template name of the theme.}}
== Return Values ==
{{Return||string|Absolute path to the [[Glossary#Theme|themes]] directory (without the trailing slash)}}.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
===Number of Subdirectories in Themes Directory===
The function below informs about the number of subdirectories in the themes directory. Note that this doesn't necessarily match the number of [[Theme Development#Theme_Stylesheet|themes recognized]] by WordPress.
&lt;pre&gt;&lt;?php
function display_themes_subdirs_count_info()
$theme_root = get_theme_root();
$files_array = glob(&quot;$theme_root/*&quot;, GLOB_ONLYDIR);
echo &quot;There are &quot; . count($files_array) . &quot; subdirectories in the &quot; . $theme_root &quot; directory&quot;;
}
?&gt;&lt;/pre&gt;
Example output:
&lt;div style=&quot;border:1px solid blue; margin: 20px 0; padding:20px&quot;&gt;There are 5 subdirectories in the /home/user/public_html/wp-content/themes directory.&lt;/div&gt;
== Notes ==
* Uses: [[Function Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] to apply the [[Plugin API/Filter Reference/theme_root|theme_root]] filters on the retrieved path.
== Change Log ==
Since: [[Version 1.5|1.5.0]]
== Source File ==
&lt;tt&gt;get_theme_root()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
{{Theme Paths}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_theme_root_uri" d:title="get theme root uri">
<d:index d:value="get theme root uri"/>
<h1>get theme root uri</h1>
<p>== Description ==
Retrieve URI for [[Glossary#Theme|themes]] directory.
Does not have trailing slash.
== Usage ==
%%%&lt;?php get_theme_root_uri(); ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Themes URI. For example: &lt;pre&gt;http://www.wordpress.org/wp-content/themes&lt;/pre&gt;
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls &lt;tt&gt;'theme_root_uri'&lt;/tt&gt; filter on uri.
* Uses: [[Function_Reference/content_url|&lt;tt&gt;content_url()&lt;/tt&gt;]] to retrieve the &lt;tt&gt;'themes'&lt;/tt&gt; uri.
* Uses: [[Function_Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]] to retrieve &lt;tt&gt;'siteurl'&lt;/tt&gt; option.
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_theme_root_uri()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_query_template" d:title="get query template">
<d:index d:value="get query template"/>
<h1>get query template</h1>
<p>{{Languages|
{{en|Function Reference/get_query_template}}
{{it|Riferimento funzioni/get_query_template}}
}}
== Description ==
Retrieve path to file without the use of extension.
Used to quickly retrieve the path of file without including the file extension. It will also check the parent template, if the file exists, with the use of [[Function_Reference/locate_template|&lt;tt&gt;locate_template()&lt;/tt&gt;]]. Allows for more generic file location without the use of the other &lt;tt&gt;get_*_template()&lt;/tt&gt; functions.
Can be used with [http://us3.php.net/manual/en/function.include.php &lt;tt&gt;include()&lt;/tt&gt;] or [http://us3.php.net/manual/en/function.require.php &lt;tt&gt;require()&lt;/tt&gt;] to retrieve path.
&lt;code&gt;
if ( &amp;#39;&amp;#39; != get_query_template( '404' ) )
include( get_query_template( '404' ) );
&lt;/code&gt;
or the same can be accomplished with
&lt;code&gt;
if ( &amp;#39;&amp;#39; != get_404_template() )
include( get_404_template() );
&lt;/code&gt;
== Usage ==
%%%&lt;?php get_query_template( $type, $templates ); ?&gt;%%%
== Parameters ==
{{Parameter|$type|string|Filename without extension.}}
{{Parameter|$templates|array|An optional list of template candidates|optional|array()}}
== Return Values ==
; (string) : Full path to file.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] on &lt;tt&gt;[[Filter_Reference/type_template|{$type}_template]]&lt;/tt&gt; on result from [[Function_Reference/locate_template|&lt;tt&gt;locate_template()&lt;/tt&gt;]].
* Uses: [[Function_Reference/locate_template|&lt;tt&gt;locate_template()&lt;/tt&gt;]] on &quot;{&lt;tt&gt;$type&lt;/tt&gt;}.php&quot;.
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_query_template()&lt;/tt&gt; is located in {{Trac|wp-includes/template.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_404_template" d:title="get 404 template">
<d:index d:value="get 404 template"/>
<h1>get 404 template</h1>
<p>{{Languages|
{{en|Function Reference/get_404_template}}
{{it|Riferimento funzioni/get_404_template}}
}}
== Description ==
Retrieve path of 404 template in current or parent template.
== Usage ==
%%%&lt;?php get_404_template(); ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Returns result from [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template('404')&lt;/tt&gt;]].
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template()&lt;/tt&gt;]]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_404_template()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}} (if v3.x {{Trac|wp-includes/template.php}}).
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_archive_template" d:title="get archive template">
<d:index d:value="get archive template"/>
<h1>get archive template</h1>
<p>{{Languages|
{{en|Function Reference/get_archive_template}}
{{it|Riferimento funzioni/get_archive_template}}
}}
== Description ==
Retrieve path of archive template in current or parent template.
== Usage ==
%%%&lt;?php get_archive_template(); ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Returns result from [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template('archive')&lt;/tt&gt;]]
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template()&lt;/tt&gt;]]
=== Filters ===
* Calls &lt;b&gt;&lt;tt&gt;'archive_template'&lt;/tt&gt;&lt;/b&gt; filter on found path: &lt;br /&gt;&lt;tt&gt;apply_filters('archive_template', $template)&lt;/tt&gt;
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_archive_template()&lt;/tt&gt; is located in {{Trac|wp-includes/template.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_author_template" d:title="get author template">
<d:index d:value="get author template"/>
<h1>get author template</h1>
<p>{{Languages|
{{en|Function Reference/get_author_template}}
{{it|Riferimento funzioni/get_author_template}}
}}
== Description ==
Retrieve path of author template in current or parent template.
== Usage ==
%%%&lt;?php get_author_template() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Returns result from [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template('author')&lt;/tt&gt;]]
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template()&lt;/tt&gt;]];
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_author_template()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&amp;nbsp;
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_category_template" d:title="get category template">
<d:index d:value="get category template"/>
<h1>get category template</h1>
<p>== Description ==
Retrieve path of category template in current or parent [[Templates|template]].
Works by retrieving the current category ID, for example &lt;tt&gt;'category-1.php'&lt;/tt&gt; and will fallback to &lt;tt&gt;category.php&lt;/tt&gt; template, if the category ID file doesn't exist.
== Usage ==
%%%&lt;?php get_category_template() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Returns path of category template in current or parent template.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls &lt;tt&gt;'category_template'&lt;/tt&gt; on file path of category template.
* Uses: [[Function_Reference/locate_template|&lt;tt&gt;locate_template()&lt;/tt&gt;]]
* Uses: [[Function_Reference/get_query_var|&lt;tt&gt;get_query_var()&lt;/tt&gt;]] on &lt;tt&gt;'cat'&lt;/tt&gt;.
=== Filters ===
* Calls &lt;b&gt;&lt;tt&gt;'category_template'&lt;/tt&gt;&lt;/b&gt; filter on found path: &lt;br /&gt;&lt;tt&gt;apply_filters('category_template', $template)&lt;/tt&gt;
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_category_template()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_date_template" d:title="get date template">
<d:index d:value="get date template"/>
<h1>get date template</h1>
<p>{{Languages|
{{en|Function Reference/get_date_template}}
{{it|Riferimento funzioni/get_date_template}}
}}
== Description ==
Retrieve path of date template in current or parent template.
== Usage ==
%%%&lt;?php get_date_template() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Result of [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template('date')&lt;/tt&gt;]].
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template()&lt;/tt&gt;]]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_date_template()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_home_template" d:title="get home template">
<d:index d:value="get home template"/>
<h1>get home template</h1>
<p>{{Languages|
{{en|Function Reference/get_home_template}}
{{it|Riferimento funzioni/get_home_template}}
}}
== Description ==
Retrieve path of home template in current or parent template.
Attempts to locate &lt;tt&gt;'home.php'&lt;/tt&gt; first before falling back to &lt;tt&gt;'index.php'&lt;/tt&gt;.
== Usage ==
%%%&lt;?php get_home_template() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Returns path of home template in current or parent template.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls &lt;tt&gt;'home_template'&lt;/tt&gt; on file path of home template.
* Uses: [[Function_Reference/locate_template|&lt;tt&gt;locate_template()&lt;/tt&gt;]] on &lt;tt&gt;'home.php'&lt;/tt&gt; and &lt;tt&gt;'index.php'&lt;/tt&gt;.
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_home_template()&lt;/tt&gt; is located in {{Trac|wp-includes/template.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_page_template" d:title="get page template">
<d:index d:value="get page template"/>
<h1>get page template</h1>
<p>== Description ==
Retrieve path of [[Page_Templates|page template]] in current or parent template.
First attempt is to look for the file in the &lt;tt&gt;'_wp_page_template'&lt;/tt&gt; page meta data. The second attempt, if the first has a file and is not empty, is to look for &lt;tt&gt;'page.php'&lt;/tt&gt;.
== Usage ==
%%%&lt;?php get_page_template(); ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Returns path of page template in current or parent template.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
Displays the filename of the page template used to render a Page (printed within an HTML comment, in this example) :
&lt;pre&gt;&lt;?php echo '&lt;!-- ' . basename( get_page_template() ) . ' --&gt;'; ?&gt;&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/get_post_meta|&lt;tt&gt;get_post_meta()&lt;/tt&gt;]]
* Uses: [[Function_Reference/validate_file|&lt;tt&gt;validate_file()&lt;/tt&gt;]]
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] on 'page_template' on result of [[Function_Reference/locate_template|&lt;tt&gt;locate_template()&lt;/tt&gt;]].
* Uses: [[Function_Reference/locate_template|&lt;tt&gt;locate_template()&lt;/tt&gt;]]
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class_Reference/WP_Query|&lt;tt&gt;$wp_query&lt;/tt&gt;]]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_page_template()&lt;/tt&gt; is located in {{Trac|wp-includes/template.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_paged_template" d:title="get paged template">
<d:index d:value="get paged template"/>
<h1>get paged template</h1>
<p>== Description ==
Retrieve path of paged [[Templates|template]] in current or parent template.
== Usage ==
%%%&lt;?php get_paged_template() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Result of [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template('paged')&lt;/tt&gt;]].
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template()&lt;/tt&gt;]]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_paged_template()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_search_template" d:title="get search template">
<d:index d:value="get search template"/>
<h1>get search template</h1>
<p>{{Languages|
{{en|Function Reference/get_search_template}}
{{it|Riferimento funzioni/get_search_template}}
}}
== Description ==
Retrieve path of search template in current or parent template.
== Usage ==
%%%&lt;?php get_search_template() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Result of [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template('search')&lt;/tt&gt;]].
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template()&lt;/tt&gt;]]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_search_template()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_single_template" d:title="get single template">
<d:index d:value="get single template"/>
<h1>get single template</h1>
<p>== Description ==
Retrieve path of [[Templates|single template]] in current or parent template.
== Usage ==
%%%&lt;?php get_single_template() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Result of &lt;tt&gt;get_query_template('single')&lt;/tt&gt;.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template()&lt;/tt&gt;]]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_single_template()&lt;/tt&gt; is located in {{Trac|wp-includes/template.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_attachment_template" d:title="get attachment template">
<d:index d:value="get attachment template"/>
<h1>get attachment template</h1>
<p>== Description ==
Retrieve path of [[Templates|attachment template]] in current or parent template.
The attachment path first checks if the first part of the mime type exists. The second check is for the second part of the mime type. The last check is for both types separated by an underscore. If neither are found then the file &lt;tt&gt;'attachment.php'&lt;/tt&gt; is checked and returned.
Some examples for the &lt;tt&gt;'text/plain'&lt;/tt&gt; mime type are &lt;tt&gt;'text.php'&lt;/tt&gt;, &lt;tt&gt;'plain.php'&lt;/tt&gt;, and finally &lt;tt&gt;'text_plain.php'&lt;/tt&gt;.
== Usage ==
%%%&lt;?php get_attachment_template() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Returns path of attachment template in current or parent template.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_query_template|&lt;tt&gt;get_query_template()&lt;/tt&gt;]]
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) &lt;tt&gt;$posts&lt;/tt&gt; a property of the [[Class_Reference/WP_Query|&lt;tt&gt;WP_Query&lt;/tt&gt;]] object.
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;tt&gt;get_attachment_template()&lt;/tt&gt; is located in {{Trac|wp-includes/template.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="User:Chrisbliss18/wp_cache_add" d:title="User:Chrisbliss18/wp cache add">
<d:index d:value="User:Chrisbliss18/wp cache add"/>
<h1>User:Chrisbliss18/wp cache add</h1>
<p>{{Draft}}
== Description ==
&lt;span style=&quot;background-color:#F5F5F5; border:1px solid #DADADA; margin:0px 0px 22px 0px; padding:11px; display:block;&quot;&gt;&lt;tt&gt;bool wp_cache_add ( int|string $key, mixed $data [, string $flag [, int $expire ]] )&lt;/tt&gt;&lt;/span&gt;
__TOC__
This function is part of the [[Function Reference/WP Cache|WP Cache]] system. Its function is to add data to the cache, if the cache key doesn't already exist.
For examples of how to use this function, see the [[User:Chrisbliss18/wp_cache_add#Examples|Examples section]] below.
== Parameters ==
This function uses [[Template Tags/How to Pass Tag Parameters#Tags with PHP function-style parameters|PHP function style parameters]].
&lt;dl style=&quot;background-color:#F5F5F5; border:1px solid #DADADA; margin:0px 0px 22px 0px; padding:11px 11px 0px 11px;&quot;&gt;
&lt;dt style=&quot;font-weight:normal; font-style:italic;&quot;&gt;
key
&lt;dd style=&quot;background-color:#FAFAFA; border:1px solid #DADADA; margin:0px 0px 22px 22px; padding:11px; font-weight:normal;&quot;&gt;
The cache ID to use for retrieval later. This is a required parameter.
&lt;dt style=&quot;font-weight:normal; font-style:italic;&quot;&gt;
data
&lt;dd style=&quot;background-color:#FAFAFA; border:1px solid #DADADA; margin:0px 0px 22px 22px; padding:11px; font-weight:normal;&quot;&gt;
The data to add to the cache store. This is a required parameter.
&lt;dt style=&quot;font-weight:normal; font-style:italic;&quot;&gt;
flag
&lt;dd style=&quot;background-color:#FAFAFA; border:1px solid #DADADA; margin:0px 0px 22px 22px; padding:11px; font-weight:normal;&quot;&gt;
The group to add the cache to. Default value is an empty string.&lt;br /&gt;
&lt;br /&gt;
It should be noted that the default value for this parameter in both &lt;tt&gt;WP_Object_Cache::add()&lt;/tt&gt; and &lt;tt&gt;WP_Object_Cache::set()&lt;/tt&gt; is &lt;tt&gt;default&lt;/tt&gt; rather than an empty string. This editor does not know if this difference was an oversight or intentional.
&lt;dt style=&quot;font-weight:normal; font-style:italic;&quot;&gt;
expire
&lt;dd style=&quot;background-color:#FAFAFA; border:1px solid #DADADA; margin:0px 0px 22px 22px; padding:22px; font-weight:normal;&quot;&gt;
When the cache data should expire. Default value is &lt;tt&gt;0&lt;/tt&gt;.&lt;br /&gt;
&lt;br /&gt;
Tracing this variable through the resulting call to &lt;tt&gt;WP_Object_Cache::set()&lt;/tt&gt;, it can be seen that this parameter is not used. This may just be a placeholder for future functionality.&lt;/dl&gt;
== Return Values ==
The function returns &lt;tt&gt;true&lt;/tt&gt; on success and &lt;tt&gt;false&lt;/tt&gt; if the cache ID and group already exists.
== Errors/Exceptions ==
Placeholder section that would be used with functions that return [[Function Reference/WP Error|WP Error]] objects.
== ChangeLog ==
&lt;table&gt;
&lt;tr&gt;
&lt;th style=&quot;padding-right:10px; font-weight:bold;&quot;&gt;Version&lt;/th&gt;
&lt;th style=&quot;font-weight:bold;&quot;&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;padding-right:10px;&quot;&gt;2.5&lt;/td&gt;
&lt;td&gt;&lt;tt&gt;$data&lt;/tt&gt; filtering is removed.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;padding-right:10px;&gt;2.1.1&lt;/td&gt;
&lt;td&gt;&lt;tt&gt;$data&lt;/tt&gt; is filtered through first &lt;tt&gt;serialize()&lt;/tt&gt; and then &lt;tt&gt;unserialize()&lt;/tt&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;padding-right:10px;&quot;&gt;2.0.0&lt;/td&gt;
&lt;td&gt;Added to WordPress core.&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
== Examples ==
There are many examples throughout WordPress' core that use this function. Below are a couple of code selections.
=== Retrieving All Category IDs ===
The [[Function Reference/Category API]] shows a very good example of using &lt;tt&gt;wp_cache_add()&lt;/tt&gt; in combination with &lt;tt&gt;[[Function Reference/wp_cache_get|wp_cache_get()]]&lt;/tt&gt; to ensure that the expensive queries and data processing to gather all the category IDs only occur once.
''Note: The following code was taken from wp-includes/category.php version 2.7.''
&lt;span style=&quot;background-color:#F5F5F5; border:1px solid #DADADA; margin:0px; padding:0px 11px 0px 11px; display:block;&quot;&gt;%%%&lt;?php
function get_all_category_ids() {
if ( ! $cat_ids = wp_cache_get( 'all_category_ids', 'category' ) ) {
$cat_ids = get_terms( 'category', 'fields=ids&amp;get=all' );
wp_cache_add( 'all_category_ids', $cat_ids, 'category' );
}
return $cat_ids;
}
?&gt;%%%&lt;/span&gt;
=== Display Recent Entries Widget ===
The code that displays the Recent Entries widget provides a good example of how much code can be skipped by using caching.
''Note: The following code was taken from wp-includes/widgets.php version 2.7.''
&lt;span style=&quot;background-color:#F5F5F5; border:1px solid #DADADA; margin:0px; padding:0px 11px 0px 11px; display:block;&quot;&gt;%%%&lt;?php
function wp_widget_recent_entries($args) {
if ( '%BEG_OF_TITLE%' != $args['before_title'] ) {
if ( $output = wp_cache_get('widget_recent_entries', 'widget') )
return print($output);
ob_start();
}
extract($args);
$options = get_option('widget_recent_entries');
$title = empty($options['title']) ? __('Recent Posts') :
apply_filters('widget_title', $options['title']);
if ( !$number = (int) $options['number'] )
$number = 10;
else if ( $number &lt; 1 )
$number = 1;
else if ( $number &gt; 15 )
$number = 15;
$r = new WP_Query(array('showposts' =&gt; $number, 'what_to_show' =&gt; 'posts',
'nopaging' =&gt; 0, 'post_status' =&gt; 'publish', 'caller_get_posts' =&gt; 1));
if ($r-&gt;have_posts()) :
?&gt;
&lt;?php echo $before_widget; ?&gt;
&lt;?php if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?&gt;
&lt;ul&gt;
&lt;?php while ($r-&gt;have_posts()) : $r-&gt;the_post(); ?&gt;
&lt;li&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot;&gt;
&lt;?php if ( get_the_title() ) the_title(); else the_ID(); ?&gt;
&lt;/a&gt;&lt;/li&gt;
&lt;?php endwhile; ?&gt;
&lt;/ul&gt;
&lt;?php echo $after_widget; ?&gt;
&lt;?php
wp_reset_query(); // Restore global post data stomped by the_post().
endif;
if ( '%BEG_OF_TITLE%' != $args['before_title'] )
wp_cache_add('widget_recent_entries', ob_get_flush(), 'widget');
}
?&gt;%%%&lt;/span&gt;
== Notes ==
* This function uses [[Template Tags/How to Pass Tag Parameters#Tags with PHP function-style parameters|PHP function style parameters]].
* &lt;tt&gt;wp_cache_add()&lt;/tt&gt; is a wrapper that calls &lt;tt&gt;$wp_object_cache-&gt;add(...)&lt;/tt&gt;. See the &lt;tt&gt;WP_Object_Cache::add()&lt;/tt&gt; function code for details on how this code operates.
== See Also ==
* [[Function Reference/WP Cache|WP Cache Reference]]
* [http://dougal.gunters.org/blog/2006/07/21/using-the-wordpress-object-cache Using the WordPress Object Cache]
* [http://perishablepress.com/press/2007/12/26/how-to-enable-the-default-wordpress-object-cache/|How to Enable the Default WordPress Object Cache]
[[Category:Functions]]
== Limitations While Creating This Document ==
* A rule in the Codex's CSS prevents DIVs from being styled. I worked around this by using SPANs with a display of block.
* The CSS rules don't have any padding for table elements. The only way to work around this (due to not being able to define CSS rules other than via individual style declarations) is by either using cellspacing and cellpadding (not desirable) or adding style information to every TH and TD element (also not desirable).
* Lack of styling for DD and DT elements. I solved this by manually applying style information to each element.
* The &lt;tt&gt;&amp;lt;/dd&amp;gt;&lt;/tt&gt; and &lt;tt&gt;&amp;lt;/dt&amp;gt;&lt;/tt&gt; elements are not supported, thus breaking standards.
* The &amp;#37;&amp;#37;&amp;#37; directive makes very nicely-colored PHP code output, but it has limitations.
** To get the output to be have syntax highlighting, it needs to be wrapped in &lt;?php ?&gt; tags. This adds unnecessary lines since the presence of these tags can be assumed in most instances. It would be nice if there could be an option to force highlighting without the use of the tags.
** The output contains large amounts of whitespace at the top and bottom.
** The output is not contained in a box like as the CSS styles the PRE. This type of container is helpful as it clearly sets the code apart from the rest of the documentation. I manually applied this look using the styled SPAN that I used for the function structure.</p>
</d:entry>
<d:entry id="get_comments_popup_template" d:title="get comments popup template">
<d:index d:value="get comments popup template"/>
<h1>get comments popup template</h1>
<p>== Description ==
Retrieve path of comment popup template in current or parent template.
Checks for comment popup template file &lt;tt&gt;comments-popup.php&lt;/tt&gt; in the current template, if it exists there, or in the parent template. If that fails, it may look for a deprecated default file in {{Trac|wp-includes/theme-compat}}.
== Usage ==
%%%&lt;?php get_comments_popup_template() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Returns the template path.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls &lt;tt&gt;'comments_popup_template'&lt;/tt&gt; filter on path.
* Uses: [[Function_Reference/locate_template|&lt;tt&gt;locate_template()&lt;/tt&gt;]] to locate &lt;tt&gt;'comments-popup.php'&lt;/tt&gt; file.
== Change Log ==
Since: 1.5.0. After 3.0: Default file deprecated.
== Source File ==
&lt;tt&gt;get_comments_popup_template()&lt;/tt&gt; is located in {{Trac|wp-includes/template.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="load_template" d:title="load template">
<d:index d:value="load template"/>
<h1>load template</h1>
<p>{{Languages|
{{en|Function Reference/load_template}}
{{it|Riferimento funzioni/load_template}}
}}
== Description ==
Require once the template file with WordPress environment.
The globals are set up for the template file to ensure that the WordPress environment is available from within the function. The query variables are also available.
== Usage ==
%%%&lt;?php load_template( $_template_file, $require_once ) ?&gt;%%%
== Parameters ==
{{Parameter|$_template_file|string|Path to template file.}}
{{Parameter|$require_once |bool|Whether to require_once or require.|optional|true}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
===Loading a template in a plugin, but allowing theme and child theme to override template===
&lt;tt&gt;
if ( $overridden_template = locate_template( 'some-template.php' ) ) {
// locate_template() returns path to file
// if either the child theme or the parent theme have overridden the template
load_template( $overridden_template );
} else {
// If neither the child nor parent theme have overridden the template,
// we load the template from the 'templates' sub-directory of the directory this file is in
load_template( dirname( __FILE__ ) . '/templates/some-template.php' );
}
&lt;/tt&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class_Reference/WP_Query|&lt;tt&gt;$wp_query&lt;/tt&gt;]] to extract [http://us.php.net/manual/en/function.extract.php &lt;tt&gt;extract()&lt;/tt&gt;] global variables returned by the &lt;tt&gt;query_vars&lt;/tt&gt; method while protecting the current values in these global variables:
** (&lt;tt&gt;unknown type&lt;/tt&gt;) &lt;tt&gt;$posts&lt;/tt&gt;
** (&lt;tt&gt;unknown type&lt;/tt&gt;) &lt;tt&gt;$post&lt;/tt&gt;
** (&lt;tt&gt;boolean&lt;/tt&gt;) &lt;tt&gt;$wp_did_header&lt;/tt&gt; Returns &lt;tt&gt;true&lt;/tt&gt; if the WordPress header was already loaded. See the &lt;tt&gt;/wp-blog-header.php&lt;/tt&gt; file for details.
** (&lt;tt&gt;boolean&lt;/tt&gt;) &lt;tt&gt;$wp_did_template_redirect&lt;/tt&gt;
** (&lt;tt&gt;object&lt;/tt&gt;) &lt;tt&gt;$wp_rewrite&lt;/tt&gt;
** (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
** (&lt;tt&gt;string&lt;/tt&gt;) &lt;tt&gt;$wp_version&lt;/tt&gt; holds the installed WordPress version number.
** (&lt;tt&gt;string&lt;/tt&gt;) &lt;tt&gt;$wp&lt;/tt&gt;
** (&lt;tt&gt;string&lt;/tt&gt;) &lt;tt&gt;$id&lt;/tt&gt;
** (&lt;tt&gt;string&lt;/tt&gt;) &lt;tt&gt;$comment&lt;/tt&gt;
** (&lt;tt&gt;string&lt;/tt&gt;) &lt;tt&gt;$user_ID&lt;/tt&gt;
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;load_template()&lt;/tt&gt; is located in {{Trac|wp-includes/template.php}}.
== Related ==
{{Template_Functions}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="locale_stylesheet" d:title="locale stylesheet">
<d:index d:value="locale stylesheet"/>
<h1>locale stylesheet</h1>
<p>== Description ==
Display localized stylesheet link element.
If [[Function_Reference/get_locale_stylesheet_uri|&lt;tt&gt;get_locale_stylesheet_uri()&lt;/tt&gt;]] returns a value, locale_stylesheet will echo a valid xhtml &lt;tt&gt;&amp;lt;link&amp;gt;&lt;/tt&gt; tag like this:&lt;br&gt;
&lt;pre&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;path_to_stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
&lt;/pre&gt;
If [[Function_Reference/get_locale_stylesheet_uri|&lt;tt&gt;get_locale_stylesheet_uri()&lt;/tt&gt;]] does not return a value then the function exits immediately.
== Usage ==
%%%&lt;?php locale_stylesheet() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
Uses [[Function_Reference/get_locale_stylesheet_uri|&lt;tt&gt;get_locale_stylesheet_uri()&lt;/tt&gt;]].
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;locale_stylesheet()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="preview_theme" d:title="preview theme">
<d:index d:value="preview theme"/>
<h1>preview theme</h1>
<p>{{Languages|
{{en|Function Reference/preview_theme}}
{{it|Riferimento funzioni/preview_theme}}
}}
== Description ==
Start preview theme output buffer.
Will only perform task if the user has permissions and '&lt;tt&gt;template&lt;/tt&gt;' and '&lt;tt&gt;preview&lt;/tt&gt;' query variables exist. Will add '&lt;tt&gt;stylesheet&lt;/tt&gt;' filter if '&lt;tt&gt;stylesheet&lt;/tt&gt;' query variable exists.
== Usage ==
%%%&lt;?php preview_theme() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 2.5.0
== Source File ==
&lt;tt&gt;preview_theme()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="preview_theme_ob_filter" d:title="preview theme ob filter">
<d:index d:value="preview theme ob filter"/>
<h1>preview theme ob filter</h1>
<p>{{Languages|
{{en|Function Reference/preview_theme_ob_filter}}
{{it|Riferimento funzioni/preview_theme_ob_filter}}
}}
{{Private}}
== Description ==
Callback function for [http://us2.php.net/manual/en/function.ob-start.php &lt;tt&gt;ob_start()&lt;/tt&gt;] to capture all links in the theme.
== Usage ==
%%%&lt;?php preview_theme_ob_filter( $content ) ?&gt;%%%
== Parameters ==
{{Parameter|$content|string|}}
== Return Values ==
; (string) :
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Change Log ==
Since: unknown
== Source File ==
&lt;tt&gt;preview_theme_ob_filter()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="preview_theme_ob_filter_callback" d:title="preview theme ob filter callback">
<d:index d:value="preview theme ob filter callback"/>
<h1>preview theme ob filter callback</h1>
<p>{{Languages|
{{en|Function Reference/preview_theme_ob_filter_callback}}
{{it|Riferimento funzioni/preview_theme_ob_filter_callback}}
}}
{{Private}}
== Description ==
Manipulates preview theme links in order to control and maintain location.
Callback function for [http://us2.php.net/manual/en/function.preg-replace-callback.php &lt;tt&gt;preg_replace_callback()&lt;/tt&gt;] to accept and filter matches.
== Usage ==
%%%&lt;?php preview_theme_ob_filter_callback( $matches ) ?&gt;%%%
== Parameters ==
{{Parameter|$matches|array|}}
== Return Values ==
; (string) :
== Change Log ==
Since: unknown
== Source File ==
&lt;tt&gt;preview_theme_ob_filter_callback()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="validate_current_theme" d:title="validate current theme">
<d:index d:value="validate current theme"/>
<h1>validate current theme</h1>
<p>{{Languages|
{{en|Function Reference/validate_current_theme}}
{{it|Riferimento funzioni/validate_current_theme}}
}}
== Description ==
Checks that current theme files '&lt;tt&gt;index.php&lt;/tt&gt;' and '&lt;tt&gt;style.css&lt;/tt&gt;' exists.
Does not check the '&lt;tt&gt;default&lt;/tt&gt;' theme. The '&lt;tt&gt;default&lt;/tt&gt;' theme should always exist or should have another theme renamed to that template name and directory path. Will switch theme to default if current theme does not validate. You can use the '&lt;tt&gt;validate_current_theme&lt;/tt&gt;' filter to return &lt;tt&gt;false&lt;/tt&gt; to disable this functionality.
== Usage ==
%%%&lt;?php validate_current_theme() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (boolean) :
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;validate_current_theme()&lt;/tt&gt; is located in &lt;tt&gt;wp-includes/theme.php&lt;/tt&gt;.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="switch_theme" d:title="switch theme">
<d:index d:value="switch theme"/>
<h1>switch theme</h1>
<p>{{Languages|
{{en|Function Reference/switch_theme}}
{{it|Riferimento funzioni/switch_theme}}
}}
== Description ==
Switches current theme to new template and stylesheet names.
&lt;br /&gt;Accepts one argument: $stylesheet of the theme. ($stylesheet is the name of your folder slug. It's the same value that you'd use for a child theme, something like `twentythirteen`.) It also accepts an additional function signature of two arguments: $template then $stylesheet. This is for backwards compatibility.
== Usage ==
%%%&lt;?php switch_theme( $stylesheet ) ?&gt;%%%
Optional usage for backwards compatibility:
%%%&lt;?php switch_theme( $template, $stylesheet ) ?&gt;%%%
== Parameters ==
===Current Parameters===
{{Parameter|$stylesheet|string|Stylesheet name.}}
===Alternate Function Signature Parameters for Backwards Compatibility ===
{{Parameter|$template|string|Template name.}}
{{Parameter|$stylesheet|string|Stylesheet name.}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] Calls '&lt;tt&gt;switch_theme&lt;/tt&gt;' action on updated theme display name.
== Change Log ==
Since: 2.5.0
&lt;br /&gt;Altered 4/23 to define default/alternate function signature and parameters
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;switch_theme()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_theme_mod" d:title="get theme mod">
<d:index d:value="get theme mod"/>
<h1>get theme mod</h1>
<p>== Description ==
Retrieves a modification setting for the current theme. Along with [[set_theme_mod|set_theme_mod()]] this function can sometimes offer theme developers a simpler alternative to the [[Settings API]] when there is a need to handle basic theme-specific settings.
If the modification name does not exist, then the &lt;tt&gt;$default&lt;/tt&gt; will be passed through [http://us2.php.net/manual/en/function.sprintf.php &lt;tt&gt;sprintf()&lt;/tt&gt;] with the first string the template directory URI and the second string the stylesheet directory URI.
== Usage ==
%%%&lt;?php get_theme_mod( $name, $default ); ?&gt;%%%
== Parameters ==
{{Parameter|$name|string|Theme modification name.}}
{{Parameter|$default|boolean&amp;#124;string||optional|false}}
== Return Values ==
; (string) :
== Examples ==
===Calling the Custom Background Color===
This example could be used to add the custom background color as a border on the top of the footer. It would be css inserted in the header:
&lt;pre&gt;
.footer {
border-top: solid 1px #&lt;?php echo get_theme_mod( 'background_color' ); ?&gt;;
}
&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls &lt;tt&gt;[[Plugin_API/Filter_Reference/theme_mod_$name|'theme_mod_$name']]&lt;/tt&gt; filter on the value.
== Change Log ==
Since: [[Version 2.1|2.1.0]]
== Source File ==
&lt;tt&gt;get_theme_mod()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
[[Function Reference/background_color|background_color()]],
{{Theme Mod Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]
[[Category:Theme Modification API]]</p>
</d:entry>
<d:entry id="set_theme_mod" d:title="set theme mod">
<d:index d:value="set theme mod"/>
<h1>set theme mod</h1>
<p>== Description ==
Creates or updates a modification setting for the current theme. Along with [[get_theme_mod|get_theme_mod()]] this function sometimes offers theme developers a simpler alternative to the [[Settings API]] when there is a need to handle basic theme-specific settings.
== Usage ==
%%%&lt;?php set_theme_mod( $name, $value ); ?&gt;%%%
== Parameters ==
{{Parameter|$name|string|Theme modification name.}}
{{Parameter|$value|string|Theme modification value.}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls &lt;tt&gt;[[Plugin_API/Filter_Reference/theme_mod_$name|'pre_set_theme_mod_$name']]&lt;/tt&gt; filter on the value.
== Change Log ==
Since: [[Version 2.1|2.1.0]]
== Source File ==
&lt;tt&gt;set_theme_mod()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}
== Related ==
{{Theme Mod Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]
[[Category:Theme Modification API]]</p>
</d:entry>
<d:entry id="get_header_textcolor" d:title="get header textcolor">
<d:index d:value="get header textcolor"/>
<h1>get header textcolor</h1>
<p>{{Languages|
{{en|Function Reference/get_header_textcolor}}
{{it|Riferimento funzioni/get_header_textcolor}}
}}
== Description ==
Retrieves the color value of the text inside the header.
== Usage ==
%%%&lt;?php get_header_textcolor() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) :
Gets and stores the color value of the text inside the header.
== Examples ==
The example below gets the color of the text inside the header, stores it in a variable and then prints it within the echo statement.
&lt;pre&gt;
&lt;?php
$header_text_color = get_header_textcolor();
echo &quot;The color of the text inside the header is #&quot;. $header_text_color . &quot;.&quot;;
?&gt;
&lt;/pre&gt;
== Notes ==
* Uses: &lt;tt&gt;HEADER_TEXTCOLOR&lt;/tt&gt;
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;get_header_textcolor()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
%%%&lt;?php header_textcolor(); ?&gt;%%%
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_header_image" d:title="get header image">
<d:index d:value="get header image"/>
<h1>get header image</h1>
<p>{{Languages|
{{en|Function Reference/get_header_image}}
{{it|Riferimento funzioni/get_header_image}}
}}
== Description ==
Retrieve header image for custom header.
== Usage ==
%%%&lt;?php get_header_image() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Returns header image URL.
An empty string will be returned if:
* The current theme does NOT support header images. (Learn how to enable it in [[Custom Headers]] page).
* The current theme DOES support header images. However, the user has selected the &quot;Remove Header Image&quot; option from the Appearance -&gt; Header screen.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: &lt;tt&gt;HEADER_IMAGE&lt;/tt&gt;
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;get_header_image()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
*Function: [[header_image]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="header_image" d:title="header image">
<d:index d:value="header image"/>
<h1>header image</h1>
<p>{{Languages|
{{en|Function Reference/header_image}}
{{it|Riferimento funzioni/header_image}}
}}
== Description ==
Display header image path.
== Usage ==
%%%&lt;?php header_image() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : This function return an absolute url of header image without escaping the entities.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;header_image()&lt;/tt&gt; is located in &lt;tt&gt;[http://core.trac.wordpress.org/browser/trunk/wp-includes/theme.php wp-includes/theme.php]&lt;/tt&gt;.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
*Function: [[get_header_image]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="add_custom_image_header" d:title="add custom image header">
<d:index d:value="add custom image header"/>
<h1>add custom image header</h1>
<p>{{Deprecated|new_function()=add_theme_support}}
== Description ==
Add callbacks for image header display.
The parameter &lt;tt&gt;$header_callback&lt;/tt&gt; callback will be required to display the content for the '&lt;tt&gt;wp_head&lt;/tt&gt;' action. The parameter &lt;tt&gt;$admin_header_callback&lt;/tt&gt; callback will be added to &lt;tt&gt;Custom_Image_Header&lt;/tt&gt; class and that will be added to the '&lt;tt&gt;admin_menu&lt;/tt&gt;' action.
== Replace With ==
[[Function Reference/add theme support|add_theme_support( 'custom-header' )]]
== Usage ==
%%%&lt;?php add_custom_image_header( $header_callback, $admin_header_callback, $admin_image_div_callback ) ?&gt;%%%
== Parameters ==
{{Parameter|$header_callback|callback|Call on '&lt;tt&gt;wp_head&lt;/tt&gt;' action.}}
{{Parameter|$admin_header_callback|callback|Call on custom header administration screen.}}
{{Parameter|$admin_image_div_callback|callback|Output a custom header image div on the custom header administration screen. Optional.}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
Edit the file &lt;tt&gt;functions.php&lt;/tt&gt; inside your theme and add the following code.
Four constants must be defined in order for the custom image header to work:
&lt;pre&gt;define('HEADER_TEXTCOLOR', 'ffffff');
define('HEADER_IMAGE', '%s/images/default_header.jpg'); // %s is the template dir uri
define('HEADER_IMAGE_WIDTH', 775); // use width and height appropriate for your theme
define('HEADER_IMAGE_HEIGHT', 200);&lt;/pre&gt;
If you don't want to allow changing the header text color, add:
&lt;pre&gt;define('NO_HEADER_TEXT', true );&lt;/pre&gt;
Then change the first definition to:
&lt;pre&gt;define('HEADER_TEXTCOLOR', '');&lt;/pre&gt;
If you intend to create child themes use:
&lt;pre&gt;define('HEADER_IMAGE', trailingslashit( get_stylesheet_directory_uri() ).'images/banner.jpg');&lt;/pre&gt;
Otherwise, you'll pick up the header image for the parent theme rather than the child.
Next you need to write two functions. One will be included in the site header. The second will be included in the admin header. Both of these functions are required. The smallest possible amount of code would be something like this, although you can do anything you need.
&lt;pre&gt;// gets included in the site header
function header_style() {
?&gt;&lt;style type=&quot;text/css&quot;&gt;
#header {
background: url(&lt;?php header_image(); ?&gt;);
}
&lt;/style&gt;&lt;?php
}&lt;/pre&gt;
&lt;pre&gt;// gets included in the admin header
function admin_header_style() {
?&gt;&lt;style type=&quot;text/css&quot;&gt;
#headimg {
width: &lt;?php echo HEADER_IMAGE_WIDTH; ?&gt;px;
height: &lt;?php echo HEADER_IMAGE_HEIGHT; ?&gt;px;
background: no-repeat;
}
&lt;/style&gt;&lt;?php
}&lt;/pre&gt;
Finish with calling the add_custom_image_header function with the two earlier function names as parameters:
&lt;pre&gt;add_custom_image_header('header_style', 'admin_header_style');&lt;/pre&gt;
Taking this last step will make the Custom Header item appear in the Appearance menu. WordPress takes care of everything else.
== Notes ==
* Uses: &lt;tt&gt;Custom_Image_Header&lt;/tt&gt;. Sets up for &lt;tt&gt;$admin_header_callback&lt;/tt&gt; for [[Administration_Panels|administration panel]] display.
== Change Log ==
* Deprecated: [[Version 3.4|3.4.0]]
* Since: [[Version 2.1|2.1.0]]
== Source File ==
&lt;tt&gt;add_custom_image_header()&lt;/tt&gt; is located in {{Trac|wp-includes/theme.php}}.
== Related ==
{{Custom Headers}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_gmt_from_date" d:title="get gmt from date">
<d:index d:value="get gmt from date"/>
<h1>get gmt from date</h1>
<p>== Description ==
Returns a date in the GMT equivalent.
Requires and returns a date in the &lt;tt&gt;Y-m-d H:i:s&lt;/tt&gt; format. Simply subtracts the value of the '&lt;tt&gt;gmt_offset&lt;/tt&gt;' option.
== Usage ==
%%%&lt;?php get_gmt_from_date( $string ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|The date to be converted.}}
== Return Values ==
; (string) : GMT version of the date provided.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]] to retrieve the value of the 'gmt_offset' option.
== Change Log ==
Since: 1.2.0
== Source File ==
&lt;tt&gt;get_gmt_from_date()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_date_from_gmt" d:title="get date from gmt">
<d:index d:value="get date from gmt"/>
<h1>get date from gmt</h1>
<p>== Description ==
Converts a GMT date into the correct format for the blog.
Requires and returns in the &lt;tt&gt;Y-m-d H:i:s&lt;/tt&gt; format. Simply adds the value of the '&lt;tt&gt;gmt_offset&lt;/tt&gt;' option.
== Usage ==
%%%&lt;?php get_date_from_gmt( $string, $format ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|The date to be converted.}}
{{Parameter|$format|string|The format string for the returned date|false|Y-m-d H:i:s}}
== Return Values ==
; (string) : Formatted date relative to the GMT offset.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]] to retrieve the value of &lt;tt&gt;'gmt_offset&lt;/tt&gt;'.
== Change Log ==
Since: 1.2.0
==Source File==
&lt;tt&gt;get_date_from_gmt()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="iso8601_timezone_to_offset" d:title="iso8601 timezone to offset">
<d:index d:value="iso8601 timezone to offset"/>
<h1>iso8601 timezone to offset</h1>
<p>== Description ==
Computes an offset in seconds from an ISO 8601 timezone.
== Usage ==
%%%&lt;?php iso8601_timezone_to_offset( $timezone ) ?&gt;%%%
== Parameters ==
{{Parameter|$timezone|string|Either 'Z' for 0 offset or '&Acirc;&plusmn;hhmm'.}}
== Return Values ==
; (integer&amp;#124;float) : The offset in seconds.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* See Also: [http://en.wikipedia.org/wiki/ISO_8601 ISO 8601]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;iso8601_timezone_to_offset()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="iso8601_to_datetime" d:title="iso8601 to datetime">
<d:index d:value="iso8601 to datetime"/>
<h1>iso8601 to datetime</h1>
<p>== Description ==
Converts an iso8601 date to [http://dev.mysql.com/doc/refman/4.1/en/datetime.html MySQL DATETIME] format used by &lt;tt&gt;post_date[_gmt]&lt;/tt&gt;.
== Usage ==
%%%&lt;?php iso8601_to_datetime( $date_string, $timezone ) ?&gt;%%%
== Parameters ==
{{Parameter|$date_string|string|Date and time in ISO 8601 format.}}
{{Parameter|$timezone|string|If set to GMT returns the time minus gmt_offset. Default is '&lt;tt&gt;user&lt;/tt&gt;'.|optional|'user'}}
== Return Values ==
; (string) : The date and time in [http://dev.mysql.com/doc/refman/4.1/en/datetime.html MySQL DATETIME] format - &lt;tt&gt;Y-m-d H:i:s&lt;/tt&gt;.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* See Also: [http://en.wikipedia.org/wiki/ISO_8601 ISO 8601]
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;iso8601_to_datetime()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="human_time_diff" d:title="human time diff">
<d:index d:value="human time diff"/>
<h1>human time diff</h1>
<p>== Description ==
Determines the difference between two timestamps.
The difference is returned in a human readable format such as &quot;1 hour&quot;, &quot;5 mins&quot;, &quot;2 days&quot;.
== Usage ==
%%%&lt;?php human_time_diff( $from, $to ); ?&gt;%%%
== Parameters ==
{{Parameter|$from|integer|Unix timestamp from which the difference begins.}}
{{Parameter|$to|integer|Unix timestamp to end the time difference. Default becomes [http://us2.php.net/manual/en/function.time.php &lt;tt&gt;time()&lt;/tt&gt;] if not set.|optional|&amp;#39;&amp;#39;}}
== Return Values ==
; (string) : Human readable time difference.
== Examples ==
To print an entry's time (&quot;2 days ago&quot;):
%%%&lt;?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?&gt;%%%
For comments:
%%%&lt;?php echo human_time_diff( get_comment_time('U'), current_time('timestamp') ) . ' ago'; ?&gt;%%%
== Notes ==
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;code&gt;human_time_diff()&lt;/code&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
{{Time Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="date_i18n" d:title="date i18n">
<d:index d:value="date i18n"/>
<h1>date i18n</h1>
<p>{{Languages|
{{en|Function Reference/date_i18n}}
{{ja|関数リファレンス/date_i18n}}
}}
== Description ==
Retrieve the date in localized format, based on timestamp.
If the locale specifies the locale month and weekday, then the locale will take over the format for the date. If it isn't, then the date format string will be used instead.
[[Wikipedia:i18n|&lt;tt&gt;i18n&lt;/tt&gt;]] is an abbreviation for Internationalization. (There are 18 letters between the first &quot;i&quot; and last &quot;n&quot;.)
== Usage ==
%%%&lt;?php echo date_i18n( $dateformatstring, $unixtimestamp, $gmt ) ?&gt;%%%
== Parameters ==
{{Parameter|$dateformatstring|string|Format to display the date.}}
{{Parameter|$unixtimestamp|integer|Unix timestamp.|optional|false}}
{{Parameter|$gmt|boolean|Whether to convert to GMT for time.|optional|false}}
== Return Values ==
; (string) : The date, translated if locale specifies it.
== Examples ==
Depending on your blog settings you will see the date displayed in your local format, for example: 15. november 1976.
&lt;?php echo date_i18n( get_option( 'date_format' ), strtotime( '11/15-1976' ) ); ?&gt;
== Notes ==
* See Also: [[Formatting Date and Time]]
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) &lt;tt&gt;$wp_locale&lt;/tt&gt; handles the date and time locales.
== Change Log ==
* Since: 0.71
== Source File ==
&lt;tt&gt;date_i18n()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
* &lt;tt&gt;[[Function_Reference/number_format_i18n | number_format_i18n()]]&lt;/tt&gt;
{{L10n}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_weekstartend" d:title="get weekstartend">
<d:index d:value="get weekstartend"/>
<h1>get weekstartend</h1>
<p>== Description ==
Get the week start and end from the [http://dev.mysql.com/doc/refman/4.1/en/datetime.html MySQL DATETIME] or date string.
== Usage ==
%%%&lt;?php get_weekstartend( $mysqlstring, $start_of_week ) ?&gt;%%%
== Parameters ==
{{Parameter|$mysqlstring|string|Date or [http://dev.mysql.com/doc/refman/4.1/en/datetime.html MySQL DATETIME] field type.}}
{{Parameter|$start_of_week|integer|Start of the week as an integer.|optional|&amp;#39;&amp;#39;}}
== Return Values ==
; (array) : Keys are '&lt;tt&gt;start&lt;/tt&gt;' and '&lt;tt&gt;end&lt;/tt&gt;'.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_option|&lt;tt&gt;get_option()&lt;/tt&gt;]] to retrieve the '&lt;tt&gt;start_of_week&lt;/tt&gt;' option if &lt;tt&gt;$start_of_week&lt;/tt&gt; is not numeric.
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;get_weekstartend()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_lastpostdate" d:title="get lastpostdate">
<d:index d:value="get lastpostdate"/>
<h1>get lastpostdate</h1>
<p>== Description ==
Retrieve the date the the last post was published.
The server timezone is the default and is the difference between [[Glossary#GMT|GMT]] and server time. The '&lt;tt&gt;blog&lt;/tt&gt;' value is the date when the last post was posted. The '&lt;tt&gt;gmt&lt;/tt&gt;' is when the last post was posted in [[Glossary#GMT|GMT]] formatted date.
== Usage ==
%%%&lt;?php get_lastpostdate( $timezone ) ?&gt;%%%
== Parameters ==
{{Parameter|$timezone|string|The location to get the time. Can be '&lt;tt&gt;gmt&lt;/tt&gt;', '&lt;tt&gt;blog&lt;/tt&gt;', or '&lt;tt&gt;server&lt;/tt&gt;'.|optional|'server'}}
== Return Values ==
; (string) : The date of the last post.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;get_lastpostdate&lt;/tt&gt;' filter
* Uses global: (&lt;tt&gt;mixed&lt;/tt&gt;) &lt;tt&gt;$cache_lastpostdate&lt;/tt&gt; Stores the date the last post.
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* Uses global: (&lt;tt&gt;integer&lt;/tt&gt;) &lt;tt&gt;$blog_id&lt;/tt&gt; The Blog ID.
== Change Log ==
Since: 0.71
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_lastpostdate()&lt;/tt&gt; is located in &lt;tt&gt;wp-includes/post.php&lt;/tt&gt;.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_lastpostmodified" d:title="get lastpostmodified">
<d:index d:value="get lastpostmodified"/>
<h1>get lastpostmodified</h1>
<p>== Description ==
Retrieve last post modified date depending on timezone.
The server timezone is the default and is the difference between [[Glossary#GMT|GMT]] and server time. The '&lt;tt&gt;blog&lt;/tt&gt;' value is just when the last post was modified. The '&lt;tt&gt;gmt&lt;/tt&gt;' is when the last post was modified in [[Glossary#GMT|GMT]] time.
== Usage ==
%%%&lt;?php get_lastpostmodified( $timezone ); ?&gt;%%%
== Parameters ==
{{Parameter|$timezone|string|The location to get the time. Can be '&lt;tt&gt;gmt&lt;/tt&gt;', '&lt;tt&gt;blog&lt;/tt&gt;', or '&lt;tt&gt;server&lt;/tt&gt;'.|optional|'server'}}
== Return Values ==
; (string) : The date the post was last modified.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;get_lastpostmodified&lt;/tt&gt;' filter
* Uses global: (&lt;tt&gt;mixed&lt;/tt&gt;) &lt;tt&gt;$cache_lastpostmodified&lt;/tt&gt; Stores the date the last post was last modified.
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* Uses global: (&lt;tt&gt;integer&lt;/tt&gt;) &lt;tt&gt;$blog_id&lt;/tt&gt; The Blog ID.
== Change Log ==
Since: 1.2.0
== Source File ==
&lt;tt&gt;get_lastpostmodified()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="is_new_day" d:title="is new day">
<d:index d:value="is new day"/>
<h1>is new day</h1>
<p>==Description==
This [[Conditional Tags|Conditional Tag]] checks if today is a new day. This is a boolean function, meaning it returns TRUE when new day or FALSE if not a new day.
==Usage==
%%%&lt;?php is_new_day(); ?&gt;%%%
==Parameters==
This tag does not accept any parameters.
==Return Values==
; (boolean) : TRUE (1) when new day, FALSE (0) if not a new day.
==Examples==
==Notes==
* Uses global: (&lt;tt&gt;string&lt;/tt&gt;) &lt;tt&gt;$day&lt;/tt&gt; Holds the date of the day of the current post during [[The_Loop]].
* Uses global: (&lt;tt&gt;string&lt;/tt&gt;) &lt;tt&gt;$previousday&lt;/tt&gt; Holds the date of the day of the previous post (if any) during [[The_Loop]].
==Change Log==
Since: 0.71
==Source File==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_new_day()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_comments_popup" d:title="is comments popup">
<d:index d:value="is comments popup"/>
<h1>is comments popup</h1>
<p>==Description==
This [[Conditional Tags|Conditional Tag]] checks when in Comments Popup window. This is a boolean function, meaning it returns either TRUE or FALSE.
==Usage==
%%%&lt;?php is_comments_popup(); ?&gt;%%%
==Parameters==
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
==Notes==
==Change Log==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_comments_popup()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_plugin_page" d:title="is plugin page">
<d:index d:value="is plugin page"/>
<h1>is plugin page</h1>
<p>&lt;big&gt;'''Notice: ''is_plugin_page'' is deprecated since version 3.1 with no alternative available.'''&lt;/big&gt;
==Description==
Returns true when the current request is for a plugin page in the administration panel. For example, if the request is for &quot;http://www.example.com/wp-admin/edit.php?page=some_plugin.php&quot;, this will return true.
As of version 2.6, this appears to key off of the &quot;page&quot; URL parameter and is based on the variable $plugin_page, set in wp-admin/admin.php.
==Usage==
%%%&lt;?php is_plugin_page(); ?&gt;%%%
==Parameters==
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
==Notes==
==Change Log==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_plugin_page()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
As of version 2.6, this is defined in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_category_by_path" d:title="get category by path">
<d:index d:value="get category by path"/>
<h1>get category by path</h1>
<p>== Description ==
Retrieve category based on URL containing the category slug.
Breaks the &lt;tt&gt;$category_path&lt;/tt&gt; parameter up to get the category slug.
Tries to find the child path and will return it. If it doesn't find a match, then it will return the first category matching slug, if &lt;tt&gt;$full_match&lt;/tt&gt;, is set to false. If it does not, then it will return null.
It is also possible that it will return a &lt;tt&gt;WP_Error&lt;/tt&gt; object on failure. Check for it when using this function.
== Usage ==
%%%&lt;?php get_category_by_path( $category_path, $full_match, $output ) ?&gt;%%%
== Parameters ==
{{Parameter|$category_path|string|URL containing category slugs.}}
{{Parameter|$full_match|boolean|Whether should match full path or not.|optional|true}}
{{Parameter|$output|string|Constant OBJECT, ARRAY_A, or ARRAY_N|optional|OBJECT}}
== Return Values ==
; (null&amp;#124;object&amp;#124;array) : Null on failure. Type is based on &lt;tt&gt;$output&lt;/tt&gt; value.
== Examples ==
=== Default usage ===
&lt;pre&gt;
&lt;?php
$categ = get_category_by_path('uncategorized');
echo &quot;Category &quot;.$categ-&gt;name;
?&gt;
&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_category_by_path()&lt;/tt&gt; is located in &lt;tt&gt;{{Trac|wp-includes/category.php}}&lt;/tt&gt;.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_tags" d:title="get tags">
<d:index d:value="get tags"/>
<h1>get tags</h1>
<p>{{Languages|
{{en|Function Reference/get tags}}
{{ja|関数リファレンス/get tags}}
}}
== Description ==
Retrieve an array of objects for each term in post_tag taxonomy.
== Usage ==
%%% &lt;?php $tags_array = get_tags( $args ); ?&gt; %%%
== Parameters ==
Retrieves a list of post tags based on the criteria provided in $args. The list of arguments that $args can contain, which will overwrite the defaults:
;orderby :Default is 'name'. Can be name, count, or nothing (will use term_id).
;order :Default is ASC. Can use DESC.
;hide_empty :Default is true. Will not return empty terms, which means terms whose count is 0 according to the given taxonomy.
;exclude :Default is an empty string. A comma- or space-delimited string of term ids to exclude from the return array. If 'include' is non-empty, 'exclude' is ignored.
;include :Default is an empty string. A comma- or space-delimited string of term ids to include in the return array.
;number :The maximum number of terms to return. Default is empty.
;offset :The number by which to offset the terms query.
;fields :Default is 'all', which returns an array of term objects. If 'fields' is 'ids' or 'names', returns an array of integers or strings, respectively.
;slug :Returns terms whose &quot;slug&quot; matches this value. Default is empty string.
;hierarchical :Whether to include terms that have non-empty descendants (even if 'hide_empty' is set to true).
;search :Returned terms' names will contain the value of 'search', case-insensitive. Default is an empty string.
;name__like :Returned terms' names will contain the value of 'name__like', case-sensitive. Default is empty string.
;description__like :Returned terms' descriptions will contain the value of 'description__like', case-insensitive. Default is empty string.
;pad_counts :If set to true will include the quantity of a term's children in the quantity of each term's &quot;count&quot; object variable.
;get :If set to 'all' instead of its default empty string, returns terms regardless of ancestry or whether the terms are empty.
;child_of :When used, should be set to the integer of a term ID. Its default is 0. If set to a non-zero value, all returned terms will be descendants of that term according to the given taxonomy. Hence 'child_of' is set to 0 if more than one taxonomy is passed in $taxonomies, because multiple taxonomies make term ancestry ambiguous.
;parent :When used, should be set to the integer of a term ID. Its default is the empty string, which has a different meaning from the integer 0. If set to an integer value, all returned terms will have as an immediate ancestor the term whose ID is specified by that integer according to the given taxonomy. The 'parent' argument is different from 'child_of' in that a term X is considered a 'parent' of term Y only if term X is the father of term Y, not its grandfather or great-grandfather, etc.
== Returns ==
Returns either an array of objects or an empty array. Each returned object has the following properties:
;term_id : (''string'')
;name : (''string'')
;slug : (''string'')
;term_group : (''string'')
;term_taxonomy_id : (''string'')
;taxonomy : (''string'')
;description : (''string'')
;parent : (''string'')
;count : (''string'')
== Example ==
Displays a list of tags with links to each one and a specific class for each tag:
&lt;pre&gt;
$tags = get_tags();
$html = '&lt;div class=&quot;post_tags&quot;&gt;';
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag-&gt;term_id );
$html .= &quot;&lt;a href='{$tag_link}' title='{$tag-&gt;name} Tag' class='{$tag-&gt;slug}'&gt;&quot;;
$html .= &quot;{$tag-&gt;name}&lt;/a&gt;&quot;;
}
$html .= '&lt;/div&gt;';
echo $html;
&lt;/pre&gt;
== Source File ==
&lt;tt&gt;get_tags()&lt;/tt&gt; is located in {{Trac|wp-includes/category.php}}.
== Related ==
{{Tag Tags}}
{{Tag Footer}}
[[Category:Functions]]
{{copyedit}}</p>
</d:entry>
<d:entry id="get_cat_name" d:title="get cat name">
<d:index d:value="get cat name"/>
<h1>get cat name</h1>
<p>{{Languages|
{{en|Function Reference/get_cat_name}}
{{it|Riferimento funzioni/get_cat_name}}
}}
== Description ==
Retrieve the name of a category from its ID.
== Usage ==
%%%&lt;?php get_cat_name( $cat_id ) ?&gt;%%%
== Parameters ==
{{Parameter|$cat_id|integer|Category ID}}
== Return Values ==
; (string) : Category name
== Examples ==
&lt;pre&gt;&lt;?php echo get_cat_name(4);?&gt;&lt;/pre&gt;
returns the name for the category with the id '4'.
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;get_cat_name()&lt;/tt&gt; is located in {{Trac|wp-includes/category.php}}.
== Related ==
{{Category Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_tag" d:title="get tag">
<d:index d:value="get tag"/>
<h1>get tag</h1>
<p>{{Languages|
{{en|Function Reference/get tag}}
{{it|Riferimento funzioni/get tag}}
{{ja|関数リファレンス/get tag}}
}}
== Description ==
Retrieve post tag by tag ID or tag object.
If you pass the &lt;tt&gt;$tag&lt;/tt&gt; parameter an object, which is assumed to be the tag row object retrieved the database. It will cache the tag data.
If you pass &lt;tt&gt;$tag&lt;/tt&gt; an integer of the tag ID, then that tag will be retrieved from the database, if it isn't already cached, and pass it back.
If you look at [[Function_Reference/get_term|&lt;tt&gt;get_term()&lt;/tt&gt;]], then both types will be passed through several filters and finally sanitized based on the &lt;tt&gt;$filter&lt;/tt&gt; parameter value.
== Usage ==
%%%&lt;?php &amp;get_tag( $tag, $output, $filter ) ?&gt;%%%
== Parameters ==
{{Parameter|$tag|integer&amp;#124;object|}}
{{Parameter|$output|string|Constant OBJECT, ARRAY_A, or ARRAY_N|optional|OBJECT}}
{{Parameter|$filter|string|Default is raw or no WordPress defined filter will applied.|optional|'raw'}}
== Return Values ==
; (object&amp;#124;array) : Return type based on &lt;tt&gt;$output&lt;/tt&gt; value.
== Examples ==
== Notes ==
* Uses: [[Function_Reference/get_term|get_term()]] Used to get the tag data from the taxonomy.
== Change Log ==
Since: [[Version 2.3|2.3.0]]
== Source File ==
&lt;tt&gt;&amp;get_tag()&lt;/tt&gt; is located in {{Trac|wp-includes/category.php}}.
== Related ==
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_taxonomy_hierarchical" d:title="is taxonomy hierarchical">
<d:index d:value="is taxonomy hierarchical"/>
<h1>is taxonomy hierarchical</h1>
<p>{{Languages|
{{en|Function Reference/is_taxonomy_hierarchical}}
{{it|Riferimento_funzioni/is_taxonomy_hierarchical}}
{{ja|関数リファレンス/is_taxonomy_hierarchical}}
}}
==Description==
This [[Conditional Tags|Conditional Tag]] checks if the taxonomy object is hierarchical. This is a boolean function uses a global, meaning it returns either TRUE or FALSE (A false return value might also mean that the taxonomy does not exist).
checks to make sure that the taxonomy is an object first. Then gets the object, and finally returns the hierarchical value in the object.
==Usage==
%%%&lt;?php is_taxonomy_hierarchical( $taxonomy ) ?&gt;%%%
==Parameters==
{{Parameter|$taxonomy|string|Name of taxonomy object}}
==Return Values==
; (boolean) : Whether the taxonomy is hierarchical
==Examples==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
==Notes==
* See Also: [[WordPress_Taxonomy|WordPress Taxonomy]].
* Uses: [[Function_Reference/taxonomy_exists|&lt;tt&gt;taxonomy_exists()&lt;/tt&gt;]] Checks whether taxonomy exists.
* Uses: [[Function_Reference/get_taxonomy|&lt;tt&gt;get_taxonomy()&lt;/tt&gt;]] Used to get the taxonomy object.
==Change Log==
Since: 2.3.0
==Source File==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_taxonomy_hierarchical()&lt;/tt&gt; is located in {{Trac|wp-includes/taxonomy.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_term_by" d:title="get term by">
<d:index d:value="get term by"/>
<h1>get term by</h1>
<p>{{Languages|
{{en|Function Reference/get term by}}
{{ja|関数リファレンス/get term by}}
}}
== Description ==
Get all &lt;tt&gt;Term&lt;/tt&gt; data from database by &lt;tt&gt;Term&lt;/tt&gt; field and data.
Warning: &lt;tt&gt;$value&lt;/tt&gt; is not HTML-escaped for the '&lt;tt&gt;name&lt;/tt&gt;' &lt;tt&gt;$field&lt;/tt&gt;. You must do it yourself, if required.
The default &lt;tt&gt;$field&lt;/tt&gt; is '&lt;tt&gt;id&lt;/tt&gt;', therefore it is possible to also use null for field, but not recommended that you do so.
If &lt;tt&gt;$value&lt;/tt&gt; does not exist, the return value will be false. If &lt;tt&gt;$taxonomy&lt;/tt&gt; exists and &lt;tt&gt;$field&lt;/tt&gt; and &lt;tt&gt;$value&lt;/tt&gt; combinations exist, the Term will be returned.
== Usage ==
%%%&lt;?php get_term_by( $field, $value, $taxonomy, $output, $filter ) ?&gt;%%%
== Parameters ==
{{Parameter|$field|string|Either '&lt;tt&gt;id&lt;/tt&gt;', '&lt;tt&gt;slug&lt;/tt&gt;', '&lt;tt&gt;name&lt;/tt&gt;', or '&lt;tt&gt;term_taxonomy_id&lt;/tt&gt;'|required|'id'}}
{{Parameter|$value|string&amp;#124;integer|Search for this term value}}
{{Parameter|$taxonomy|string|Taxonomy Name &lt;tt&gt;category&lt;/tt&gt;, &lt;tt&gt;post_tag&lt;/tt&gt;, &lt;tt&gt;link_category&lt;/tt&gt; or something custom}}
{{Parameter|$output|string|Constant OBJECT, ARRAY_A, or ARRAY_N|optional|OBJECT}}
{{Parameter|$filter|string|default is raw or no WordPress defined filter will applied.|optional|'raw'}}
== Return Values ==
; (mixed) : Term Row (object or array) from database. Will return false if &lt;tt&gt;$taxonomy&lt;/tt&gt; does not exist or &lt;tt&gt;$term&lt;/tt&gt; was not found. Othewise returns object (by default) or array of fields depending on &lt;tt&gt;$output&lt;/tt&gt; parameter.
The fields returned are:
* &lt;tt&gt;term_id (See warning below)&lt;/tt&gt;
* &lt;tt&gt;name&lt;/tt&gt;
* &lt;tt&gt;slug&lt;/tt&gt;
* &lt;tt&gt;term_group&lt;/tt&gt;
* &lt;tt&gt;term_taxonomy_id&lt;/tt&gt;
* &lt;tt&gt;taxonomy&lt;/tt&gt;
* &lt;tt&gt;description&lt;/tt&gt;
* &lt;tt&gt;parent&lt;/tt&gt;
* &lt;tt&gt;count&lt;/tt&gt;
'''Warning: string vs integer confusion!''' Field values, including &lt;tt&gt;term_id&lt;/tt&gt; are returned in string format. Before further use, typecast numeric values to actual integers, otherwise WordPress will mix up term_ids and slugs which happen to have only numeric characters!
== Examples ==
Taxonomy_name is the name of taxonomy, not the term_name and is required; the id (term_id) is the ID of the term, not post_id;...
Remember:&lt;br /&gt;
&amp;darr; Taxonomy type (e.g. post_tag)&lt;br /&gt;
Terms in this taxonomy:&lt;br /&gt;
&amp;rarr; news&lt;br /&gt;
&amp;rarr; webdev&lt;br /&gt;
&amp;rarr; ...
Examples to get terms by name and taxonomy ''type'' (taxonomy_name as category, post_tag or custom taxonomy).
&lt;pre&gt;
// Get term by name ''news'' in Categories taxonomy.
get_term_by('name', 'news', 'category')
// Get term by name ''news'' in Tags taxonomy.
get_term_by('name', 'news', 'post_tag')
// Get term by name ''news'' in Custom taxonomy.
get_term_by('name', 'news', 'my_custom_taxonomy')
&lt;/pre&gt;
By id (term_id, not post_id):
&lt;pre&gt;
// Get term by id (''term_id'') in Categories taxonomy.
get_term_by('id', 12, 'category')
...
&lt;/pre&gt;
=== Wrong example in this page history ===
Warning: the example below '''is wrong''' (see in this page history):
&lt;pre&gt;get_term_by('id', (int)$post-&gt;ID, 'taxonomy_name'); // return null&lt;/pre&gt;
This example try to get a term with ID (term_id) as post_id and in the taxonomy ''taxonomy_name''. This taxonomy not exists and the term_id is wrong.
This is the correct version of this example:
&lt;pre&gt;
// get_term_by('id', category_id, 'category')
$postCategories = get_the_category($post-&gt;ID);
foreach ( $postCategories as $postCategory ) {
$myCategories[] = get_term_by('id', $postCategory-&gt;cat_ID, 'category');
}
// OR:
$myCategory = get_term_by('id', $postCategories[0]-&gt;cat_ID, 'category');
&lt;/pre&gt;
== Notes ==
* Warning: &lt;tt&gt;$value&lt;/tt&gt; is not escaped for '&lt;tt&gt;name&lt;/tt&gt;' &lt;tt&gt;$field&lt;/tt&gt;. You must do it yourself, if required.
* See [[Function_Reference/sanitize_term_field|&lt;tt&gt;sanitize_term_field()&lt;/tt&gt;]] The &lt;tt&gt;$context&lt;/tt&gt; param lists the available values for '&lt;tt&gt;get_term_by&lt;/tt&gt;' &lt;tt&gt;$filter&lt;/tt&gt; param.
* Uses: [[Function_Reference/sanitize_term|&lt;tt&gt;sanitize_term()&lt;/tt&gt;]] Cleanses the term based on &lt;tt&gt;$filter&lt;/tt&gt; context before returning.
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
== Change Log ==
Since: 2.3.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_term_by()&lt;/tt&gt; is located in {{Trac|wp-includes/taxonomy.php}}.
== Related ==
{{Term Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="is_term" d:title="is term">
<d:index d:value="is term"/>
<h1>is term</h1>
<p>{{Deprecated}}
== Description ==
Check if &lt;tt&gt;Term&lt;/tt&gt; exists.
Returns the index of a defined term, or &lt;tt&gt;0&lt;/tt&gt; (&lt;tt&gt;false&lt;/tt&gt;) if the term doesn't exist.
== Replace With ==
[[Function Reference/term_exists|term_exists]] for check that term exists or [[Function Reference/is_tax|is_tax]] with optional $term argument for check that you are in term archive.
== Usage ==
%%%&lt;?php is_term( $term, $taxonomy ) ?&gt;%%%
== Parameters ==
{{Parameter|$term|integer&amp;#124;string|The term to check}}
{{Parameter|$taxonomy|string|The taxonomy name to use|optional|&amp;#39;&amp;#39;}}
== Return Values ==
; (mixed) : Get the term id or &lt;tt&gt;Term Object&lt;/tt&gt;, if exists.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) &lt;tt&gt;$term&lt;/tt&gt;
== Change Log ==
* Since: [[Version 2.3|2.3]]
* Deprecated: [[Version 3.0|3.0]]
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_term()&lt;/tt&gt; is located in {{Trac|wp-includes/taxonomy.php}}.
== Related ==
{{Conditional Tags}}
{{Term Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:Conditional Tags]]</p>
</d:entry>
<d:entry id="wp_get_object_terms" d:title="wp get object terms">
<d:index d:value="wp get object terms"/>
<h1>wp get object terms</h1>
<p>{{Languages|
{{en|Function Reference/wp get object terms}}
{{ja|関数リファレンス/wp get object terms}}
}}
== Description ==
Retrieves the terms associated with the given object(s), in the supplied taxonomies.
== Usage ==
%%%&lt;?php wp_get_object_terms( $object_ids, $taxonomies, $args ) ?&gt;%%%
== Parameters ==
{{Parameter|$object_ids|string&amp;#124;array|The id's of objects to retrieve terms from.}}
{{Parameter|$taxonomies|string&amp;#124;array|The [[Taxonomies|taxonomies]] to retrieve terms from. For example: 'category', 'post_tag', 'taxonomy slug'}}
{{Parameter|$args|array&amp;#124;string|Change what is returned|optional|array}}
=== Default Arguments ===
$args = array('orderby' =&gt; 'name', 'order' =&gt; 'ASC', 'fields' =&gt; 'all');
=== Argument Options ===
The following information has to do the &lt;tt&gt;$args&lt;/tt&gt; parameter and for what can be contained in the string or array of that parameter, if it exists.
; order : (''string'')
:* &lt;tt&gt;ASC&lt;/tt&gt; - Default
:* &lt;tt&gt;DESC&lt;/tt&gt;
; orderby : (''string'')
:* &lt;tt&gt;name&lt;/tt&gt; - Default
:* &lt;tt&gt;count&lt;/tt&gt;
:* &lt;tt&gt;slug&lt;/tt&gt;
:* &lt;tt&gt;term_group&lt;/tt&gt;
:* &lt;tt&gt;term_order&lt;/tt&gt;
:* &lt;tt&gt;term_id&lt;/tt&gt;
:* &lt;tt&gt;none&lt;/tt&gt;
; fields : (''string'')
:* &lt;tt&gt;all&lt;/tt&gt; - Default : all matching terms objects will be returned.
:* &lt;tt&gt;ids&lt;/tt&gt; : terms ids will be returned
:* &lt;tt&gt;names&lt;/tt&gt; : terms names will be returned
:* &lt;tt&gt;slugs&lt;/tt&gt; : terms slugs will be returned
:* &lt;tt&gt;all_with_object_id&lt;/tt&gt; : all matching terms objects will be returned.
:* &lt;tt&gt;tt_ids&lt;/tt&gt; : terms taxonomies ids will be returned
'''NOTE''': Arguments are passed in the format used by [[Function_Reference/wp_parse_args|wp_parse_args()]]. e.g.
== Return Values ==
; (array&amp;#124;WP_Error) : Array of requested term objects or empty array if no terms found. WP_Error if &lt;tt&gt;$taxonomy&lt;/tt&gt; does not exist. See [[Function_Reference/is_wp_error|is_wp_error()]] for more information.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
Return a list of all 'product' taxonomy terms which are applied to &lt;tt&gt;$post&lt;/tt&gt;:
&lt;pre&gt;$product_terms = wp_get_object_terms($post-&gt;ID, 'product');
if(!empty($product_terms)){
if(!is_wp_error( $product_terms )){
echo '&lt;ul&gt;';
foreach($product_terms as $term){
echo '&lt;li&gt;&lt;a href=&quot;'.get_term_link($term-&gt;slug, 'product').'&quot;&gt;'.$term-&gt;name.'&lt;/a&gt;&lt;/li&gt;';
}
echo '&lt;/ul&gt;';
}
}&lt;/pre&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* May return [[Function_Reference/WP_Error|&lt;tt&gt;WP_Error&lt;/tt&gt;]] object.
== Change Log ==
Since: 2.3.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_get_object_terms()&lt;/tt&gt; is located in {{Trac|wp-includes/taxonomy.php}}.
== Related ==
{{Term Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="do_feed" d:title="do feed">
<d:index d:value="do feed"/>
<h1>do feed</h1>
<p>== Description ==
Loads the feed template from the use of an action hook.
If the feed action does not have a hook, then the function will die with a message telling the visitor that the feed is not valid.
It is better to only have one hook for each feed.
== Usage ==
%%%&lt;?php do_feed() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_query_var|get_query_var()]] to get '&lt;tt&gt;feed&lt;/tt&gt;' from [[Class_Reference/WP_Query|&lt;tt&gt;$wp_query&lt;/tt&gt;]].
* Uses: [[Function_Reference/do_action|&lt;tt&gt;do_action()&lt;/tt&gt;]] Calls '&lt;tt&gt;do_feed_$feed&lt;/tt&gt;' hook, if a hook exists for the feed where &lt;tt&gt;$feed&lt;/tt&gt; is the '&lt;tt&gt;feed&lt;/tt&gt;' property from [[Class_Reference/WP_Query|&lt;tt&gt;$wp_query&lt;/tt&gt;]].
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class_Reference/WP_Query|&lt;tt&gt;$wp_query&lt;/tt&gt;]] Used to tell if the use a comment feed.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;do_feed()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="do_feed_rdf" d:title="do feed rdf">
<d:index d:value="do feed rdf"/>
<h1>do feed rdf</h1>
<p>== Description ==
Load the [[wikipedia:Resource_Description_Framework|RDF]] [[wikipedia:Rss|RSS]] 0.91 Feed template.
== Usage ==
%%%&lt;?php do_feed_rdf() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/load_template|&lt;tt&gt;load_template()&lt;/tt&gt;]] to load feed template.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;do_feed_rdf()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="do_feed_rss" d:title="do feed rss">
<d:index d:value="do feed rss"/>
<h1>do feed rss</h1>
<p>== Description ==
Load the [[wikipedia:Resource_Description_Framework|RDF]] [[wikipedia:Rss|RSS]] 1.0 Feed template.
== Usage ==
%%%&lt;?php do_feed_rss() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/load_template|&lt;tt&gt;load_template()&lt;/tt&gt;]] to load feed template.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;do_feed_rss()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="do_feed_rss2" d:title="do feed rss2">
<d:index d:value="do feed rss2"/>
<h1>do feed rss2</h1>
<p>== Description ==
Load either the RSS2 comment feed or the RSS2 posts feed.
== Usage ==
%%%&lt;?php do_feed_rss2( $for_comments ) ?&gt;%%%
== Parameters ==
{{Parameter|$for_comments|boolean|&lt;tt&gt;true&lt;/tt&gt; for the comment feed, &lt;tt&gt;false&lt;/tt&gt; for normal feed.}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/load_template|&lt;tt&gt;load_template()&lt;/tt&gt;]] to load feed template.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;do_feed_rss2()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="do_feed_atom" d:title="do feed atom">
<d:index d:value="do feed atom"/>
<h1>do feed atom</h1>
<p>== Description ==
Load either [[wikipedia:Atom_(standard)|Atom]] comment feed or [[wikipedia:Atom_(standard)|Atom]] posts feed.
== Usage ==
%%%&lt;?php do_feed_atom( $for_comments ) ?&gt;%%%
== Parameters ==
{{Parameter|$for_comments|boolean|&lt;tt&gt;true&lt;/tt&gt; for the comment feed, &lt;tt&gt;false&lt;/tt&gt; for normal feed.}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/load_template|&lt;tt&gt;load_template()&lt;/tt&gt;]] to load feed templates.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;do_feed_atom()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_bloginfo_rss" d:title="get bloginfo rss">
<d:index d:value="get bloginfo rss"/>
<h1>get bloginfo rss</h1>
<p>{{Languages|
{{en|Function Reference/get_bloginfo_rss}}
{{ja|テンプレートタグ/get_bloginfo_rss}}
}}
== Description ==
[[wikipedia:Rss|RSS]] container for the bloginfo function.
You can retrieve anything that you can using the [[Function Reference/get_bloginfo|&lt;tt&gt;get_bloginfo()&lt;/tt&gt;]] function. Everything will be stripped of tags and characters converted, when the values are retrieved for use in the feeds.
== Usage ==
%%%&lt;?php get_bloginfo_rss( $show ) ?&gt;%%%
== Parameters ==
{{Parameter|$show|string|Informational detail about your blog. Valid values:|optional|&amp;#39;&amp;#39;}}
:* &lt;tt&gt;'name'&lt;/tt&gt; - Weblog title; set in General Options. (Default)
:* &lt;tt&gt;'description'&lt;/tt&gt; - Tagline for your blog; set in General Options.
:* &lt;tt&gt;'url'&lt;/tt&gt; - [[Glossary#URI and URL|URL]] for your blog's web site address.
:* &lt;tt&gt;'rdf_url'&lt;/tt&gt; - URL for [[Glossary#RDF|RDF]]/RSS 1.0 feed.
:* &lt;tt&gt;'rss_url'&lt;/tt&gt; - URL for [[Glossary#RSS|RSS]] 0.92 feed.
:* &lt;tt&gt;'rss2_url'&lt;/tt&gt; - URL for RSS 2.0 feed.
:* &lt;tt&gt;'atom_url'&lt;/tt&gt; - URL for [[Glossary#Atom|Atom]] feed.
:* &lt;tt&gt;'comments_rss2_url'&lt;/tt&gt; - URL for comments RSS 2.0 feed.
:* &lt;tt&gt;'pingback_url'&lt;/tt&gt; - URL for [[Glossary#PingBack|Pingback]] (XML-RPC file).
:* &lt;tt&gt;'admin_email'&lt;/tt&gt; - Administrator's email address; set in General Options.
:* &lt;tt&gt;'charset'&lt;/tt&gt; - Character encoding for your blog; set in Reading Options.
:* &lt;tt&gt;'version'&lt;/tt&gt; - Version of WordPress your blog uses.
: '''The following work in WordPress version 1.5 or after:'''
:* &lt;tt&gt;'html_type'&lt;/tt&gt; - &quot;Content-type&quot; for your blog.
:* &lt;tt&gt;'wpurl'&lt;/tt&gt; - URL for WordPress installation.
:* &lt;tt&gt;'template_url'&lt;/tt&gt; - URL for template in use.
:* &lt;tt&gt;'template_directory'&lt;/tt&gt; - URL for template's directory.
:* &lt;tt&gt;'stylesheet_url'&lt;/tt&gt; - URL for primary [[Glossary#CSS|CSS]] file.
:* &lt;tt&gt;'stylesheet_directory'&lt;/tt&gt; - URL for stylesheet directory.
== Return Values ==
; (string) :
== Examples ==
=== RSS2 URL ===
Assigns the URL of your blog's RSS2 feed to the variable $rss2_url.
&lt;?php $rss2_url = get_bloginfo_rss('rss2_url'); ?&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;get_bloginfo_rss&lt;/tt&gt;' hook with two parameters.
== Change Log ==
Since: 1.5.1
== Source File ==
&lt;tt&gt;get_bloginfo_rss()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="bloginfo_rss" d:title="bloginfo rss">
<d:index d:value="bloginfo rss"/>
<h1>bloginfo rss</h1>
<p>== Description ==
Display [[wikipedia:Rss|RSS]] container for the bloginfo function.
You can retrieve anything that you can using the [[Function Reference/get_bloginfo|&lt;tt&gt;get_bloginfo()&lt;/tt&gt;]] function. Everything will be stripped of tags and characters converted, when the values are retrieved for use in the feeds.
== Usage ==
%%%&lt;?php bloginfo_rss( $show ) ?&gt;%%%
== Parameters ==
{{Parameter|$show|string|See [[Function Reference/get_bloginfo|&lt;tt&gt;get_bloginfo()&lt;/tt&gt;]] for possible values.|optional|&amp;#39;&amp;#39;}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* See [[Function Reference/get_bloginfo|&lt;tt&gt;get_bloginfo()&lt;/tt&gt;]] For the list of possible values to display.
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;bloginfo_rss&lt;/tt&gt;' hook with two parameters.
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;bloginfo_rss()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_the_title_rss" d:title="get the title rss">
<d:index d:value="get the title rss"/>
<h1>get the title rss</h1>
<p>{{Languages|
{{en|Function Reference/get_the_title_rss}}
{{it|Riferimento funzioni/get_the_title_rss}}
}}
== Description ==
Retrieve the current post title for the feed.
== Usage ==
%%%&lt;?php get_the_title_rss() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Current post title.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;the_title_rss&lt;/tt&gt;' on the post title.
* Uses: [[Function_Reference/get_the_title|get_the_title()]] to get the post title.
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;tt&gt;get_the_title_rss()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="the_title_rss" d:title="the title rss">
<d:index d:value="the title rss"/>
<h1>the title rss</h1>
<p>== Description ==
Display the post title in the feed.
== Usage ==
%%%&lt;?php the_title_rss() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_the_title_rss|&lt;tt&gt;get_the_title_rss()&lt;/tt&gt;]] Used to retrieve current post title.
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;the_title_rss()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="the_content_rss" d:title="the content rss">
<d:index d:value="the content rss"/>
<h1>the content rss</h1>
<p>{{Deprecated|new_function=the_content_feed}}
== Description ==
Display the post content for the feed.
For encoding the html or the &lt;tt&gt;$encode_html&lt;/tt&gt; parameter, there are three possible values. '&lt;tt&gt;0&lt;/tt&gt;' will make urls footnotes and use [[Function_Reference/make_url_footnote|&lt;tt&gt;make_url_footnote()&lt;/tt&gt;]]. '&lt;tt&gt;1&lt;/tt&gt;' will encode special characters and automatically display all of the content. The value of '&lt;tt&gt;2&lt;/tt&gt;' will strip all HTML tags from the content.
Also note that you cannot set the amount of words and not set the html encoding. If that is the case, then the html encoding will default to &lt;tt&gt;2&lt;/tt&gt;, which will strip all HTML tags.
To restrict the amount of words of the content, you can use the cut parameter. If the content is less than the amount, then there won't be any dots added to the end. If there is content left over, then dots will be added and the rest of the content will be removed.
== Usage ==
%%%&lt;?php the_content_rss( $more_link_text, $stripteaser, $more_file, $cut, $encode_html ) ?&gt;%%%
== Parameters ==
{{Parameter|$more_link_text|string|Text to display when more content is available but not displayed.|optional|'more...'}}
{{Parameter|$stripteaser|integer&amp;#124;boolean|Default is 0.|optional|0}}
{{Parameter|$more_file|string|Optional.|optional|&amp;#39;&amp;#39;}}
{{Parameter|$cut|integer|Amount of words to keep for the content.|optional|0}}
{{Parameter|$encode_html|integer|How to encode the content.|optional|0}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* See [[Function_Reference/get_the_content|&lt;tt&gt;get_the_content()&lt;/tt&gt;]] For the &lt;tt&gt;$more_link_text&lt;/tt&gt;, &lt;tt&gt;$stripteaser&lt;/tt&gt;, and &lt;tt&gt;$more_file&lt;/tt&gt; parameters.
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;the_content_rss&lt;/tt&gt;' on the content before processing.
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;the_content_rss()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="the_excerpt_rss" d:title="the excerpt rss">
<d:index d:value="the excerpt rss"/>
<h1>the excerpt rss</h1>
<p>{{Languages|
{{en|Function Reference/get pages}}
{{ja|Function Reference/the excerpt rss}}
}}
== Description ==
Display the post excerpt for the feed.
== Usage ==
%%%&lt;?php the_excerpt_rss() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
To create a custom feed that takes a GET parameter on a URL (e.g. http://www.example.com/?feed=myfeed&amp;type=excerpt), place something like the following in your particular feed file to send an excerpt (&lt;code&gt;the_excerpt_rss()&lt;/code&gt;) instead of the full content (&lt;code&gt;the_content()&lt;/code&gt;):
&lt;pre&gt;
&lt;?php
if isset($_GET['type'])) { $typewanted = $_GET['type']; }
if ($typewantd=='excerpt') {
// Wrap the Excerpt in a span tag for CSS styling
echo '&lt;span class=&quot;excerpt&quot;&gt;';
the_excerpt_rss();
echo '&lt;/span&gt;';
} else {
// Otherwise they want the full content so wrap it in another span
echo '&lt;span class=&quot;content&quot;&gt;';
the_content();
echo '&lt;/span&gt;';
}
?&gt;
&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;the_excerpt_rss&lt;/tt&gt;' hook on the excerpt.
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;the_excerpt_rss()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
[[Function_Reference/wp_trim_excerpt|wp_trim_excerpt()]]&lt;br/&gt;
[[Function_Reference/the_content|the_content()]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:Feeds]]</p>
</d:entry>
<d:entry id="comment_link" d:title="comment link">
<d:index d:value="comment link"/>
<h1>comment link</h1>
<p>== Description ==
Display the full, anchored URL to a single comment. This function must be used within the comments loop.
If you want to link to all of the comments for an entry, use the function [[Function_Reference/comments_link | comments_link()]] instead.
== Usage ==
%%%&lt;?php comment_link() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
Create an anchored permalink to a single comment:
&lt;a href=&quot;&lt;?php comment_link(); ?&gt;&quot;&gt;Permalink to this comment&lt;/a&gt;
The code shown above will result (depending on your permalink settings) in something like this:
&lt;a href=&quot;http://example.com/2009/07/15/example-post/comment-page-1/#comment-3&quot;&gt;Permalink to this comment&lt;/a&gt;
== Notes ==
* Echos the return value of [[Function_Reference/get_comment_link|&lt;tt&gt;get_comment_link()&lt;/tt&gt;]].
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;comment_link()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_comment_link" d:title="get comment link">
<d:index d:value="get comment link"/>
<h1>get comment link</h1>
<p>== Description ==
Retrieve the link to a given comment.
== Usage ==
%%%&lt;?php get_comment_link( $comment, $args ) ?&gt;%%%
== Parameters ==
{{Parameter|$comment|object&amp;#124;string&amp;#124;integer|Comment to retrieve.|optional|null}}
{{Parameter|$args|mixed|Optional arguments (see [[Function_Reference/get_comment_link#Default_Arguments|Default Arguments]].)|optional|array (see [[Function_Reference/get_comment_link#Default_Arguments|Default Arguments]])}}
== Return Values ==
; (string) : The permalink to the current comment
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Default Arguments ==
The following default arguments are used unless found in the optional &lt;tt&gt;$args&lt;/tt&gt; argument:
;page : The zero-based index for the page where the comment should appear. Defaults to &lt;tt&gt;0&lt;/tt&gt;. '''Note''': for backward compatibility the entire &lt;tt&gt;$args&lt;/tt&gt; argument is treated as an integer and used for this argument if it is not found to be an array.
;type : The type of comment (not used directly). Defaults to &lt;tt&gt;'all'&lt;/tt&gt;.
;per_page : Number of comments per page. Defaults to &lt;tt&gt;0&lt;/tt&gt;.
;max_depth : Maximum depth to be considered for comments, when threaded (not used directly). Defaults to &lt;tt&gt;&lt;nowiki&gt;''&lt;/nowiki&gt;&lt;/tt&gt;
== Filters ==
* &lt;tt&gt;get_comment_link&lt;/tt&gt;
== Notes ==
* Uses: [[Function_Reference/get_comment|&lt;tt&gt;get_comment()&lt;/tt&gt;]] to retrieve &lt;tt&gt;$comment&lt;/tt&gt;.
* Uses global: (&lt;tt&gt;unknown&lt;/tt&gt;) &lt;tt&gt;$wp_rewrite&lt;/tt&gt;
* Uses global: (&lt;tt&gt;unknown&lt;/tt&gt;) &lt;tt&gt;$in_comment_loop&lt;/tt&gt;
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_comment_link()&lt;/tt&gt; is located in {{Trac|wp-includes/comment-template.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_comment_author_rss" d:title="get comment author rss">
<d:index d:value="get comment author rss"/>
<h1>get comment author rss</h1>
<p>== Description ==
Retrieve the current comment author for use in the feeds.
== Usage ==
%%%&lt;?php get_comment_author_rss() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : Comment Author
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;comment_author_rss&lt;/tt&gt;' hook on comment author.
* Uses: [[Function_Reference/get_comment_author|&lt;tt&gt;get_comment_author()&lt;/tt&gt;]]
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;tt&gt;get_comment_author_rss()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="comment_author_rss" d:title="comment author rss">
<d:index d:value="comment author rss"/>
<h1>comment author rss</h1>
<p>== Description ==
Display the current comment author in the feed.
== Usage ==
%%%&lt;?php comment_author_rss() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Echos the return from [[Function_Reference/get_comment_author_rss|&lt;tt&gt;get_comment_author_rss()&lt;/tt&gt;]].
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;comment_author_rss()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="comment_text_rss" d:title="comment text rss">
<d:index d:value="comment text rss"/>
<h1>comment text rss</h1>
<p>== Description ==
Display the current comment content for use in the feeds.
== Usage ==
%%%&lt;?php comment_text_rss() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;comment_text_rss&lt;/tt&gt;' filter on comment content.
* Uses: [[Function_Reference/get_comment_text|&lt;tt&gt;get_comment_text()&lt;/tt&gt;]]
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;comment_text_rss()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_post_comments_feed_link" d:title="get post comments feed link">
<d:index d:value="get post comments feed link"/>
<h1>get post comments feed link</h1>
<p>{{Languages|
{{en|Function Reference/get_post_comments_feed_link}}
{{it|Riferimento funzioni/get_post_comments_feed_link}}
}}
== Description ==
Retrieve the permalink for the post comments feed.
== Usage ==
%%%&lt;?php get_post_comments_feed_link( $post_id, $feed ) ?&gt;%%%
== Parameters ==
{{Parameter|$post_id|integer|Post ID.|optional|&amp;#39;&amp;#39;}}
{{Parameter|$feed|string|Feed type.|optional|&amp;#39;&amp;#39;}}
== Return Values ==
; (string) :
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;integer&lt;/tt&gt;) &lt;tt&gt;$id&lt;/tt&gt;
== Change Log ==
Since: 2.2.0
== Source File ==
&lt;tt&gt;get_post_comments_feed_link()&lt;/tt&gt; is located in {{Trac|wp-includes/link-template.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_the_category_rss" d:title="get the category rss">
<d:index d:value="get the category rss"/>
<h1>get the category rss</h1>
<p>{{Languages|
{{en|Function Reference/get_the_category_rss}}
{{it|Riferimento funzioni/get_the_category_rss}}
}}
== Description ==
Retrieve all of the post categories, formatted for use in feeds.
All of the categories for the current post in the feed loop, will be retrieved and have feed markup added, so that they can easily be added to the RSS2, Atom, or RSS1 and RSS0.91 RDF feeds.
== Usage ==
%%%&lt;?php get_the_category_rss( $type ); ?&gt;%%%
== Parameters ==
{{Parameter|$type|string|default is '&lt;tt&gt;rss&lt;/tt&gt;'. Either '&lt;tt&gt;rss&lt;/tt&gt;', '&lt;tt&gt;atom&lt;/tt&gt;', or '&lt;tt&gt;rdf&lt;/tt&gt;'.|optional|'rss'}}
== Return Values ==
; (string) : All of the post categories for displaying in the feed.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]]
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;get_the_category_rss()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="the_category_rss" d:title="the category rss">
<d:index d:value="the category rss"/>
<h1>the category rss</h1>
<p>== Description ==
Display the post categories in the feed.
== Usage ==
%%%&lt;?php the_category_rss( $type ) ?&gt;%%%
== Parameters ==
{{Parameter|$type|string|Either '&lt;tt&gt;rss&lt;/tt&gt;', '&lt;tt&gt;atom&lt;/tt&gt;', or '&lt;tt&gt;rdf&lt;/tt&gt;'.|optional|'rss'}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* See [[Function_Reference/get_the_category_rss|&lt;tt&gt;get_the_category_rss()&lt;/tt&gt;]] for better explanation.
* Echos the return from [[Function_Reference/get_the_category_rss|&lt;tt&gt;get_the_category_rss()&lt;/tt&gt;]].
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;the_category_rss()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
{{Category Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="rss_enclosure" d:title="rss enclosure">
<d:index d:value="rss enclosure"/>
<h1>rss enclosure</h1>
<p>{{Languages|
{{en|Function Reference/rss_enclosure}}
{{ja|テンプレートタグ/rss_enclosure}}
}}
== Description ==
Display the rss enclosure for the current post.
Uses the global &lt;tt&gt;$post&lt;/tt&gt; to check whether the post requires a password and if the user has the password for the post. If not then it will return before displaying.
Also uses the function [[Function_Reference/get_post_custom|&lt;tt&gt;get_post_custom()&lt;/tt&gt;]] to get the post's '&lt;tt&gt;enclosure&lt;/tt&gt;' metadata field and parses the value to display the enclosure(s). The enclosure(s) consist of enclosure HTML tag(s) with a URI and other attributes.
== Usage ==
%%%&lt;?php rss_enclosure() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;rss_enclosure&lt;/tt&gt;' hook on rss enclosure.
* Uses: [[Function_Reference/get_post_custom|&lt;tt&gt;get_post_custom()&lt;/tt&gt;]] To get the current post enclosure metadata.
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;rss_enclosure()&lt;/tt&gt; is located in {{Trac|wp-includes/feed.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_search_feed_link" d:title="get search feed link">
<d:index d:value="get search feed link"/>
<h1>get search feed link</h1>
<p>== Description ==
Retrieve the permalink for the feed of the search results.
== Usage ==
%%%&lt;?php echo get_search_feed_link( $search_query, $feed ) ?&gt;%%%
If you don't echo the function you're simply going to get a permalink to the page with no RSS feed for the search results.
== Parameters ==
{{Parameter|$search_query|string|URL search query.|optional|&amp;#39;&amp;#39;}}
{{Parameter|$feed|string|Feed type.|optional|&amp;#39;&amp;#39;}}
== Return Values ==
; (string) : Returns a url after the '&lt;tt&gt;search_feed_link&lt;/tt&gt;' filters have been applied.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_search_query|&lt;tt&gt;get_search_query()&lt;/tt&gt;]] if no query supplied.
== Change Log ==
Since: 2.5.0
== Source File ==
&lt;tt&gt;get_search_feed_link()&lt;/tt&gt; is located in {{Trac|wp-includes/link-template.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_search_comments_feed_link" d:title="get search comments feed link">
<d:index d:value="get search comments feed link"/>
<h1>get search comments feed link</h1>
<p>== Description ==
Retrieve the permalink for the comments feed of the search results.
== Usage ==
%%%&lt;?php get_search_comments_feed_link( $search_query, $feed ) ?&gt;%%%
== Parameters ==
{{Parameter|$search_query|string|Url search query.|optional|&amp;#39;&amp;#39;}}
{{Parameter|$feed|string|Feed type.|optional|&amp;#39;&amp;#39;}}
== Return Values ==
; (string) :
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/get_search_query|&lt;tt&gt;get_search_query()&lt;/tt&gt;]] if no query supplied.
== Change Log ==
Since: 2.5.0
== Source File ==
&lt;tt&gt;get_search_comments_feed_link()&lt;/tt&gt; is located in {{Trac|wp-includes/link-template.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="clean_pre" d:title="clean pre">
<d:index d:value="clean pre"/>
<h1>clean pre</h1>
<p>== Description ==
Accepts matches &lt;tt&gt;array&lt;/tt&gt; from [http://us.php.net/manual/en/function.preg-replace-callback.php preg_replace_callback] in [[Function_Reference/wpautop|&lt;tt&gt;wpautop()&lt;/tt&gt;]] or a string.
Ensures that the contents of a &lt;nowiki&gt;&lt;pre&gt;...&lt;/pre&gt;&lt;/nowiki&gt; HTML block are not converted into paragraphs or line-breaks.
== Usage ==
%%%&lt;?php clean_pre( $matches ) ?&gt;%%%
== Parameters ==
{{Parameter|$matches|array&amp;#124;string|The array or string}}
== Return Values ==
; (string) : The pre block without paragraph/line-break conversion.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Note: If $matches is an &lt;tt&gt;array&lt;/tt&gt; the array values are concatenated into a string.
== Change Log ==
Since: 1.2.0
== Source File ==
&lt;tt&gt;clean_pre()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="seems_utf8" d:title="seems utf8">
<d:index d:value="seems utf8"/>
<h1>seems utf8</h1>
<p>== Description ==
Checks to see if a string is utf8 encoded.
== Usage ==
%%%&lt;?php seems_utf8( $str ); ?&gt;%%%
== Parameters ==
{{Parameter|$str|string|The string to be checked}}
== Return Values ==
; (boolean) : True if &lt;tt&gt;$str&lt;/tt&gt; fits a UTF-8 model, false otherwise.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.2.1
== Source File ==
&lt;tt&gt;seems_utf8()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_specialchars" d:title="wp specialchars">
<d:index d:value="wp specialchars"/>
<h1>wp specialchars</h1>
<p>== Description ==
'''This function is deprecated as of WordPress 2.8.0. Please use [[Function Reference/esc_html|esc_html]] instead.'''
Converts a number of special characters into their HTML entities.
Differs from [http://us.php.net/manual/en/function.htmlspecialchars.php &lt;tt&gt;htmlspecialchars&lt;/tt&gt;] as existing HTML entities will not be encoded. Specifically changes: &lt;tt&gt;&amp;amp;&lt;/tt&gt; to &lt;tt&gt;&amp;amp;#038;&lt;/tt&gt;, &lt;tt&gt;&amp;lt;&lt;/tt&gt; to &lt;tt&gt;&amp;amp;lt;&lt;/tt&gt; and &lt;tt&gt;&amp;gt;&lt;/tt&gt; to &lt;tt&gt;&amp;amp;gt;&lt;/tt&gt;.
&lt;tt&gt;$quotes&lt;/tt&gt; can be set to '&lt;tt&gt;single&lt;/tt&gt;' to encode &lt;tt&gt;'&lt;/tt&gt; to &lt;tt&gt;&amp;amp;#039;&lt;/tt&gt;, '&lt;tt&gt;double&lt;/tt&gt;' to encode &lt;tt&gt;&quot;&lt;/tt&gt; to &lt;tt&gt;&amp;amp;quot;&lt;/tt&gt;, or '&lt;tt&gt;1&lt;/tt&gt;' to do both. Default is &lt;tt&gt;0&lt;/tt&gt; where no quotes are encoded.
== Usage ==
%%%&lt;?php wp_specialchars( $text, $quotes ) ?&gt;%%%
== Parameters ==
{{Parameter|$text|string|The text which is to be encoded.}}
{{Parameter|$quotes|mixed|Converts single quotes if set to '&lt;tt&gt;single&lt;/tt&gt;', double if set to '&lt;tt&gt;double&lt;/tt&gt;' or both if otherwise set.|optional|0}}
== Return Values ==
; (string) : The encoded text with HTML entities.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* [http://us.php.net/manual/en/function.htmlspecialchars.php &lt;tt&gt;htmlspecialchars&lt;/tt&gt;] (noted in the description) is a PHP built-in function.
== Change Log ==
Since: 1.2.2
== Source File ==
&lt;tt&gt;wp_specialchars()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="utf8_uri_encode" d:title="utf8 uri encode">
<d:index d:value="utf8 uri encode"/>
<h1>utf8 uri encode</h1>
<p>== Description ==
Only alphanumerics and some special characters may be used in a URL (or URI, more on that difference elsewhere). This function will convert other characters to their Unicode values.
== Usage ==
%%%&lt;?php utf8_uri_encode( $utf8_string, $length ) ?&gt;%%%
== Parameters ==
{{Parameter|$utf8_string|string|}}
{{Parameter|$length|integer|Max length of the string|optional|0}}
== Return Values ==
; (string) : String with Unicode encoded for URI.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;utf8_uri_encode()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="is_sticky" d:title="is sticky">
<d:index d:value="is sticky"/>
<h1>is sticky</h1>
<p>{{Languages|
{{en|Function Reference/is_sticky}}
{{ja|関数リファレンス/is_sticky}}
}}
==Description==
This [[Conditional Tags|Conditional Tag]] checks if the current post is a [[Sticky_Posts | Sticky Post ]] meaning the &quot;Stick this post to the front page&quot; check box has been checked for the post. This is a boolean function, meaning it returns either TRUE or FALSE.
==Usage==
%%%&lt;?php is_sticky($post_ID); ?&gt;%%%
==Parameters==
{{Parameter|$post_ID|string|The post ID|optional}}
==Return Values==
; &lt;tt&gt;(boolean)&lt;/tt&gt; : True on success, false on failure.
==Examples==
is_sticky();
// When any Sticky Post page is being displayed.
is_sticky('17');
// When Sticky Post 17 (ID) is being displayed.
==Notes==
==Change Log==
Since: [[Version 2.7|2.7.0]]
==Source File==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_sticky()&lt;/tt&gt; is located in {{Trac|wp-includes/post.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="is_singular" d:title="is singular">
<d:index d:value="is singular"/>
<h1>is singular</h1>
<p>{{Languages|
{{en|Function_Reference/is_singular}}
{{tr|Fonksiyon_Listesi/is_singular}}
{{ja|関数リファレンス/is_singular}}
}}
==Description==
This [[Conditional Tags|conditional tag]] checks if a singular post is being displayed, which is the case when one of the following returns ''true'': &lt;tt&gt;[[Function Reference/is single|is_single()]]&lt;/tt&gt;, &lt;tt&gt;[[Function Reference/is page|is_page()]]&lt;/tt&gt; or &lt;tt&gt;[[Function Reference/is attachment|is_attachment()]]&lt;/tt&gt;. If the &lt;tt&gt;$post_types&lt;/tt&gt; parameter is specified, the function will additionally check if the [[Glossary#Query|query]] is for one of the post types specified.
==Usage==
%%%&lt;?php is_singular( $post_types ); ?&gt;%%%
==Parameters==
{{Parameter|$post_types|string/array|Post type or types to check in current query.|optional}}
==Return Values==
{{Return||boolean|''True'' on success, ''false'' on failure}}.
==Examples==
===Different Sidebar Ads in Singular Page===
&lt;?php
if ( is_singular() ) {
// show adv. #1
} else {
// show adv. #2
}
?&gt;
===Default Post Type===
True when viewing a regular [[Post Types|post]].
is_singular('post');
===Custom Post Types===
When any of the following return true: &lt;tt&gt;is_single()&lt;/tt&gt;, &lt;tt&gt;is_page()&lt;/tt&gt; or &lt;tt&gt;is_attachment()&lt;/tt&gt;.
is_singular();
True when viewing a post of the [[Post Types|Custom Post Type]] book.
is_singular('book');
True when viewing a post of the [[Post Types|Custom Post Type]] newspaper or book.
is_singular(array( 'newspaper', 'book' ));
==Notes==
==Change Log==
* Since: [[Version 1.5|1.5.0]]
* [[Version 3.0|3.0.0]]: &lt;tt&gt;$post_types&lt;/tt&gt; parameter was added.
==Source File==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;is_singular()&lt;/tt&gt; is located in {{Trac|wp-includes/query.php}}.
==Related==
{{Conditional Tags}}
{{Tag Footer}}
[[Category:Conditional Tags]]
[[Category:Functions]]</p>
</d:entry>
<d:entry id="remove_accents" d:title="remove accents">
<d:index d:value="remove accents"/>
<h1>remove accents</h1>
<p>{{Languages|
{{en|Function Reference/remove accents}}
{{ja|Function Reference/remove accents}}
}}
== Description ==
Converts all accent characters to [[wikipedia:ASCII|ASCII]] characters.
If there are no accent characters, then the string given is just returned.
== Usage ==
%%%&lt;?php remove_accents( $string ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|Text that might have accent characters}}
== Return Values ==
; (string) : Filtered string with replaced &quot;nice&quot; characters.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
&lt;pre&gt;
&lt;?php
$text = &quot;Hoy ser&aacute; un gran d&iacute;a&quot;;
echo remove_accents ( $text );
?&gt;
&lt;/pre&gt;
Echo result: Hoy sera un gran dia
== Notes ==
== Change Log ==
Since: 1.2.1
== Source File ==
&lt;tt&gt;remove_accents()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="sanitize_file_name" d:title="sanitize file name">
<d:index d:value="sanitize file name"/>
<h1>sanitize file name</h1>
<p>== Description ==
Sanitizes a filename replacing whitespace with dashes
Removes special characters that are illegal in filenames on certain operating systems and special characters requiring special escaping to manipulate at the command line. Replaces spaces and consecutive dashes with a single dash. Trim period, dash and underscore from beginning and end of filename.
The special characters are passed through the [[Plugin API/Filter Reference/sanitize_file_name_chars|sanitize_file_name_chars]] filter before removing them from the file name, allowing plugins to change which characters are considered invalid. After &lt;code&gt;sanitize_file_name()&lt;/code&gt; has done its work, it passes the sanitized file name through the [[Plugin API/Filter Reference/sanitize_file_name|sanitize_file_name]] filter.
== Usage ==
%%%&lt;?php sanitize_file_name( $name ) ?&gt;%%%
== Parameters ==
{{Parameter|$name|string|The file name}}
== Return Values ==
; (string) : Sanitized file name
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: [[Version 2.1|2.1]]
== Source File ==
&lt;code&gt;sanitize_file_name()&lt;/code&gt; is located in {{Trac|wp-includes/formatting.php}}
== Related ==
=== Functions ===
{{sanitize functions|sanitize_file_name()}}
=== Filters ===
{{sanitize filters|sanitize_file_name}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="sanitize_user" d:title="sanitize user">
<d:index d:value="sanitize user"/>
<h1>sanitize user</h1>
<p>== Description ==
Sanitize username stripping out unsafe characters.
If &lt;tt&gt;$strict&lt;/tt&gt; is true, only alphanumeric characters plus these: &lt;tt&gt;_&lt;/tt&gt;, space, &lt;tt&gt;.&lt;/tt&gt;, &lt;tt&gt;-&lt;/tt&gt;, &lt;tt&gt;*&lt;/tt&gt;, and &lt;tt&gt;@&lt;/tt&gt; are returned.
Removes tags, octets, entities, and if strict is enabled, will remove all non-[[wikipedia:ASCII|ASCII]] characters. After sanitizing, it passes the username, raw username (the username in the parameter), and the strict parameter as parameters for the [[Plugin API/Filter Reference/sanitize_user|sanitize_user]] filter.
== Usage ==
%%%&lt;?php sanitize_user( $username, $strict ) ?&gt;%%%
== Parameters ==
{{Parameter|$username|string|The username to be sanitized.}}
{{Parameter|$strict|boolean|If set limits &lt;tt&gt;$username&lt;/tt&gt; to specific characters.|optional|false}}
== Return Values ==
; (string) : The sanitized username, after passing through filters.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;sanitize_user&lt;/tt&gt;' hook on username, raw username, and &lt;tt&gt;$strict&lt;/tt&gt; parameter.
== Change Log ==
* Since: [[Version 2.0|2.0.0]]
* Originally defined in {{Trac|wp-includes/functions-formatting.php|tags/2.0|268}}
* &lt;code&gt;$strict&lt;/code&gt; parameter and &lt;tt&gt;sanitize_user&lt;/tt&gt; filter added in [[Version 2.0.1|2.0.1]]
* File renamed to {{Trac|wp-includes/formatting.php|tags/2.1|316}} in [[Version 2.1|2.1]]
== Source File ==
&lt;code&gt;sanitize_user()&lt;/code&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
=== Functions ===
{{sanitize functions|sanitize_user()}}
=== Filters ===
{{sanitize filters|sanitize_user}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="sanitize_title_with_dashes" d:title="sanitize title with dashes">
<d:index d:value="sanitize title with dashes"/>
<h1>sanitize title with dashes</h1>
<p>== Description ==
Sanitizes title, replacing whitespace with dashes.
Limits the output to alphanumeric characters, underscore (&lt;tt&gt;_&lt;/tt&gt;) and dash (&lt;tt&gt;-&lt;/tt&gt;). Whitespace becomes a dash.
Note that &lt;b&gt;it does not replace special accented characters&lt;/b&gt; (see plugins such as [https://github.com/toscho/Germanix-WordPress-Plugin] to fix that).
== Usage ==
%%%&lt;?php sanitize_title_with_dashes( $title, $unused, $context = 'display' ) ?&gt;%%%
== Parameters ==
{{Parameter|$title|string|The title to be sanitized.}}
{{Parameter|$unused|string|Used to be the &lt;tt&gt;$raw_title&lt;/tt&gt;, but is now unused.|optional}}
{{Parameter|$context|string|The context for the sanitation. When set to &lt;tt&gt;'save'&lt;/tt&gt;, additional entities are converted to hyphens or stripped entirely.|optional|'display'}}
== Return Values ==
; (string) : The sanitized title.
== Examples ==
===Default usage===
&lt;pre&gt;
&lt;?php
echo sanitize_title_with_dashes(&quot;I'm in LOVE with WordPress!!!1&quot;);
// this will print: im-in-love-with-wordpress1
?&gt;
&lt;/pre&gt;
== Notes ==
Does not apply the &lt;tt&gt;[[Plugin API/Filter Reference/sanitize_title|sanitize_title]]&lt;/tt&gt; filter to the title.
== Change Log ==
Since: 1.2.0
== Source File ==
&lt;code&gt;sanitize_title_with_dashes()&lt;/code&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
=== Functions ===
{{sanitize functions| sanitize_title_with_dashes()}}
=== Filters ===
{{sanitize filters}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="convert_chars" d:title="convert chars">
<d:index d:value="convert chars"/>
<h1>convert chars</h1>
<p>{{Languages|
{{en|Function Reference/convert_chars}}
{{it|Riferimento funzioni/convert_chars}}
}}
== Description ==
Converts a number of characters from a string.
Metadata tags &lt;nowiki&gt;&lt;title&gt;&lt;/nowiki&gt; and &lt;nowiki&gt;&lt;category&gt;&lt;/nowiki&gt; are removed, &lt;nowiki&gt;&lt;br&gt;&lt;/nowiki&gt; and &lt;nowiki&gt;&lt;hr&gt;&lt;/nowiki&gt; are converted into correct [[wikipedia:XHTML|XHTML]] and [[wikipedia:Unicode|Unicode]] characters are converted to the valid range.
== Usage ==
%%%&lt;?php convert_chars( $content, $deprecated ) ?&gt;%%%
== Parameters ==
{{Parameter|$content|string|String of characters to be converted.}}
{{Parameter|$deprecated|string|Not used.|optional|&amp;#39;&amp;#39;}}
== Return Values ==
; (string) : Converted string.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;convert_chars()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="balanceTags" d:title="balanceTags">
<d:index d:value="balanceTags"/>
<h1>balanceTags</h1>
<p>{{Languages|
{{en|Function Reference/balanceTags}}
{{it|Riferimento funzioni/balanceTags}}
}}
== Description ==
Will balance the tags if forced to or the option is set to balance tags.
The option '&lt;tt&gt;use_balanceTags&lt;/tt&gt;' is used for whether the tags will be balanced. Either the &lt;tt&gt;$force&lt;/tt&gt; parameter or '&lt;tt&gt;use_balanceTags&lt;/tt&gt;' option need to be true before the tags will be balanced.
== Usage ==
%%%&lt;?php balanceTags( $text, $force ); ?&gt;%%%
== Parameters ==
{{Parameter|$text|string|Text to be balanced}}
{{Parameter|$force|boolean|Forces balancing, ignoring the value of the option.|optional|false}}
== Return Values ==
; (string) : Balanced text
== Examples ==
=== Unclosed LI tags ===
&lt;pre&gt;
&lt;?php
$html = '&lt;ul&gt;
&lt;li&gt;this
&lt;li&gt;is
&lt;li&gt;a
&lt;li&gt;list
&lt;/ul&gt;';
echo balanceTags($html, true);
?&gt;
&lt;/pre&gt;
Will output this HTML:
&lt;pre&gt;
&lt;ul&gt;
&lt;li&gt;this
&lt;/li&gt;&lt;li&gt;is
&lt;/li&gt;&lt;li&gt;a
&lt;/li&gt;&lt;li&gt;list
&lt;/li&gt;&lt;/ul&gt;
&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;balanceTags()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="format_to_edit" d:title="format to edit">
<d:index d:value="format to edit"/>
<h1>format to edit</h1>
<p>== Description ==
Acts on text which is about to be edited.
Unless &lt;tt&gt;$richedit&lt;/tt&gt; is set, it is simply a holder for the '&lt;tt&gt;format_to_edit&lt;/tt&gt;' filter. If &lt;tt&gt;$richedit&lt;/tt&gt; is set true [http://us3.php.net/manual/en/function.htmlspecialchars.php &lt;tt&gt;htmlspecialchars&lt;/tt&gt;] will be run on the content, converting special characters to [[wikipedia:HTML|HTML]] entities.
== Usage ==
%%%&lt;?php format_to_edit( $content, $richedit ) ?&gt;%%%
== Parameters ==
{{Parameter|$content|string|The text about to be edited.}}
{{Parameter|$richedit|boolean|Whether or not the &lt;tt&gt;$content&lt;/tt&gt; should pass through [http://us3.php.net/manual/en/function.htmlspecialchars.php &lt;tt&gt;htmlspecialchars&lt;/tt&gt;].|optional|false}}
== Return Values ==
; (string) : The text after the filter (and possibly [http://us3.php.net/manual/en/function.htmlspecialchars.php &lt;tt&gt;htmlspecialchars&lt;/tt&gt;].) has been run.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;format_to_edit()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="zeroise" d:title="zeroise">
<d:index d:value="zeroise"/>
<h1>zeroise</h1>
<p>{{Languages|
{{en|Function Reference/zeroise}}
{{it|Riferimento funzioni/zeroise}}
}}
== Description ==
Add leading zeros when necessary.
If you set the threshold to '&lt;tt&gt;4&lt;/tt&gt;' and the number is '&lt;tt&gt;10&lt;/tt&gt;', then you will get back '&lt;tt&gt;0010&lt;/tt&gt;'. If you set the threshold to '&lt;tt&gt;4&lt;/tt&gt;' and the number is '&lt;tt&gt;5000&lt;/tt&gt;', then you will get back '&lt;tt&gt;5000&lt;/tt&gt;'.
Uses [http://www.php.net/manual/en/function.sprintf.php sprintf] to append the amount of zeros based on the &lt;tt&gt;$threshold&lt;/tt&gt; parameter and the size of the number. If the number is large enough, then no zeros will be appended.
== Usage ==
%%%&lt;?php zeroise( $number, $threshold ); ?&gt;%%%
== Parameters ==
{{Parameter|$number|mixed|Number to append zeros to if not greater than threshold.}}
{{Parameter|$threshold|integer|Digit places number needs to be to not have zeros added.}}
== Return Values ==
; (string) : Adds leading zeros to number if needed.
== Examples ==
===Leading Zeros on Number of Comments===
This example allows you to add leading zeros to the number of comments (used within the loop). In the particular example shown below, the threshold is set to 2, so single digit numbers will have a zero added, and numbers in the tens and higher will not. For example, 1 will be displayed as 01.
&lt;pre&gt;
&lt;?php
$comno = get_comments_number();
echo zeroise($comno, 2);
?&gt;
&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;zeroise()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php|tags/3.4|1289}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="backslashit" d:title="backslashit">
<d:index d:value="backslashit"/>
<h1>backslashit</h1>
<p>{{Languages|
{{en|Function Reference/backslashit}}
{{it|Riferimento funzioni/backslashit}}
{{ja|Function Reference/backslashit}}
}}
== Description ==
Adds backslashes before letters and before a number at the start of a string.
== Usage ==
%%%&lt;?php backslashit( $string ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|Value to which backslashes will be added.}}
== Return Values ==
; (string) : String with backslashes inserted.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* This: '&lt;tt&gt;\&lt;/tt&gt;' is a backslash.
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;backslashit()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="trailingslashit" d:title="trailingslashit">
<d:index d:value="trailingslashit"/>
<h1>trailingslashit</h1>
<p>== Description ==
Appends a trailing slash.
Will remove trailing slash if it exists already before adding a trailing slash. This prevents double slashing a string or path.
The primary use of this is for paths and thus should be used for paths. It is not restricted to paths and offers no specific path support.
== Usage ==
%%%&lt;?php trailingslashit( $string ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|What to add the trailing slash to.}}
== Return Values ==
; (string) : String with trailing slash added.
== Examples ==
&lt;pre&gt;
&lt;?php
$path = trailingslashit( '/home/julien/bin/dotfiles' );
?&gt;
&lt;/pre&gt;
$path will now contain: %%%/home/julien/bin/dotfiles/%%%
(Notice the trailing slash)
== Notes ==
* Uses: [[Function_Reference/untrailingslashit|&lt;tt&gt;untrailingslashit()&lt;/tt&gt;]] Unslashes string if it was slashed already.
* This: '&lt;tt&gt;/&lt;/tt&gt;' is a slash.
== Change Log ==
Since: 1.2.0
== Source File ==
&lt;tt&gt;trailingslashit()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
[[Function_Reference/untrailingslashit|&lt;tt&gt;untrailingslashit()&lt;/tt&gt;]]
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="untrailingslashit" d:title="untrailingslashit">
<d:index d:value="untrailingslashit"/>
<h1>untrailingslashit</h1>
<p>== Description ==
Removes trailing slash if it exists.
The primary use of this is for paths and thus should be used for paths. It is not restricted to paths and offers no specific path support.
== Usage ==
%%%&lt;?php untrailingslashit( $string ); ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|What to remove the trailing slash from.}}
== Return Values ==
; (string) : String without the trailing slash.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* This: '&lt;tt&gt;/&lt;/tt&gt;' is a slash.
== Change Log ==
Since: 2.2.0
== Source File ==
&lt;tt&gt;untrailingslashit()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
[[Function_Reference/trailingslashit|&lt;tt&gt;trailingslashit()&lt;/tt&gt;]]
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="addslashes_gpc" d:title="addslashes gpc">
<d:index d:value="addslashes gpc"/>
<h1>addslashes gpc</h1>
<p>{{Languages|
{{en|Function Reference/addslashes_gpc}}
{{it|Riferimento funzioni/addslashes_gpc}}
}}
== Description ==
Adds slashes to escape strings.
Slashes will first be removed if [http://php.net/manual/en/info.configuration.php#ini.magic-quotes-gpc magic-quotes-gpc] is set, see [http://php.net/manual/en/security.magicquotes.php magic_quotes] for more details.
== Usage ==
%%%&lt;?php addslashes_gpc( $gpc ) ?&gt;%%%
== Parameters ==
{{Parameter|$gpc|string|The string returned from HTTP request data.}}
== Return Values ==
; (string) : Returns a string escaped with slashes.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* In this context, this: '&lt;tt&gt;\&lt;/tt&gt;' is a slash.
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;addslashes_gpc()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="antispambot" d:title="antispambot">
<d:index d:value="antispambot"/>
<h1>antispambot</h1>
<p>{{Languages|
{{en|Function Reference/antispambot}}
{{it|Riferimento funzioni/antispambot}}
{{pt-br|Refer&ecirc;ncia de Fun&ccedil;&atilde;o/antispambot}}
}}
== Description ==
Converts email addresses characters to [[wikipedia:HTML_entities|HTML entities]] to block spam bots.
== Usage ==
%%%&lt;?php antispambot( $emailaddy, $hex_encoding ) ?&gt;%%%
== Parameters ==
{{Parameter|$emailaddy|string|Email address.}}
{{Parameter|$hex_encoding|integer|0 or 1. Use 0 to only allow decimal encoding (&amp;amp;#123;) and 1 to also allow hex encoding (&amp;amp;x7B;).|optional|0}}
== Return Values ==
; (string) : Converted email address.
== Examples ==
&lt;pre&gt;
/**
* Hide email from Spam Bots using a shortcode.
*
* @param array $atts Shortcode attributes. Not used.
* @param string $content The shortcode content. Should be an email address.
*
* @return string The obfuscated email address.
*/
function wpcodex_hide_email_shortcode( $atts , $content = null ) {
if ( ! is_email( $content ) ) {
return;
}
return '&lt;a href=&quot;mailto:' . antispambot( $content ) . '&quot;&gt;' . antispambot( $content ) . '&lt;/a&gt;';
}
add_shortcode( 'email', 'wpcodex_hide_email_shortcode' );
&lt;/pre&gt;
To use this in your WordPress Content area all you have to do it wrap it in a short code.
&lt;pre&gt;
[email]john.doe@mysite.com[/email]
&lt;/pre&gt;
You can also use this in a plain text widget if you add this filter to your function file as well.
&lt;pre&gt;
add_filter( 'widget_text', 'shortcode_unautop' );
add_filter( 'widget_text', 'do_shortcode' );
&lt;/pre&gt;
=== Default Usage ===
&lt;pre&gt;
&lt;?php
echo antispambot( 'john.doe@mysite.com' );
?&gt;
&lt;/pre&gt;
This will output the email like this in the HTML:
&lt;pre&gt;
&amp;amp;#106;&amp;amp;#111;h&amp;amp;#110;&amp;amp;#46;&amp;amp;#100;&amp;amp;#111;&amp;amp;#101;&amp;amp;#64;mysit&amp;amp;#101;.&amp;amp;#99;&amp;amp;#111;&amp;amp;#109;
&lt;/pre&gt;
But it will appear as a normal email address to anyone using a web browser:
&lt;pre&gt;
john.doe@mysite.com
&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;antispambot()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="make_clickable" d:title="make clickable">
<d:index d:value="make clickable"/>
<h1>make clickable</h1>
<p>== Description ==
Convert plain text [[wikipedia:URI|URI]] to [[wikipedia:HTML|HTML]] links.
Converts URI, www, FTP, and email addresses. Finishes by fixing links within links.
== Usage ==
%%%&lt;?php make_clickable( $ret ) ?&gt;%%%
== Parameters ==
{{Parameter|$ret|string|Content to convert URIs.}}
== Return Values ==
; (string) : Content with converted URIs.
== Examples ==
===Display all URLs in clickable links===
&lt;pre&gt;
&lt;?php
$string = &quot;This is a long text that contains some links like http://www.wordpress.org and http://www.wordpress.com .&quot;;
echo make_clickable($string);
?&gt;
&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: 0.71
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;make_clickable()&lt;/tt&gt; is located in
{{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_rel_nofollow" d:title="wp rel nofollow">
<d:index d:value="wp rel nofollow"/>
<h1>wp rel nofollow</h1>
<p>== Description ==
Adds&lt;tt&gt; rel=&quot;nofollow&quot;&lt;/tt&gt; string to all [[wikipedia:HTML_entities|HTML entities]] &lt;tt&gt;A&lt;/tt&gt; elements in content and escapes the content using &lt;tt&gt;esc_sql()&lt;/tt&gt;.
Note: this is not appropriate for escaping HTML for output: this function is for adding &lt;tt&gt;nofollow&lt;/tt&gt; to content being added to the database.
== Usage ==
%%%&lt;?php wp_rel_nofollow( $text ) ?&gt;%%%
== Parameters ==
{{Parameter|$text|string|Content that may contain HTML &lt;tt&gt;A&lt;/tt&gt; elements.}}
== Return Values ==
; (string) : Converted content, escaped using [[Function Reference/esc_sql|&lt;tt&gt;esc_sql()&lt;/tt&gt;]]
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] to escape text.
== Change Log ==
* Since: 1.5.0
== Source File ==
&lt;tt&gt;wp_rel_nofollow()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="convert_smilies" d:title="convert smilies">
<d:index d:value="convert smilies"/>
<h1>convert smilies</h1>
<p>== Description ==
Convert text equivalent of smilies to images.
Will only convert smilies if the option '&lt;tt&gt;use_smilies&lt;/tt&gt;' is &lt;tt&gt;true&lt;/tt&gt; and the globals used in the function aren't empty.
== Usage ==
%%%&lt;?php convert_smilies( $text ) ?&gt;%%%
== Parameters ==
{{Parameter|$text|string|Content to convert smilies from text.}}
== Return Values ==
; (string) : Converted content with text smilies replaced with images.
== Examples ==
&lt;pre&gt;
echo convert_smilies(&quot;This smiley is going to show as an image... :) &quot;);
&lt;/pre&gt;
== Notes ==
* Uses: &lt;tt&gt;$wp_smiliessearch&lt;/tt&gt;, &lt;tt&gt;$wp_smiliesreplace&lt;/tt&gt; Smiley replacement arrays.
* Uses global: (&lt;tt&gt;array&lt;/tt&gt;) &lt;tt&gt;$wp_smiliessearch&lt;/tt&gt;
* Uses global: (&lt;tt&gt;array&lt;/tt&gt;) &lt;tt&gt;$wp_smiliesreplace&lt;/tt&gt;
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;convert_smilies()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
* [[Using_Smilies]]
* [[Glossary#Smileys|Glossary: Smileys]]
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_iso_descrambler" d:title="wp iso descrambler">
<d:index d:value="wp iso descrambler"/>
<h1>wp iso descrambler</h1>
<p>{{Languages|
{{en|Function Reference/wp_iso_descrambler}}
{{it|Riferimento funzioni/wp_iso_descrambler}}
}}
== Description ==
Converts an email subject to [[wikipedia:ASCII|ASCII]].
== Usage ==
%%%&lt;?php wp_iso_descrambler( $string ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|Subject line}}
== Return Values ==
; (string) : Converted string to ASCII
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* &quot;iso&quot; seems to refer to the iso-8859-1 character set.
* There is a somewhat related [https://core.trac.wordpress.org/ticket/6788 discussion on WordPress trac] about Swedish encoding.
== Change Log ==
Since: [[Version_1.2 | 1.2.0]]
== Source File ==
&lt;tt&gt;wp_iso_descrambler()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="popuplinks" d:title="popuplinks">
<d:index d:value="popuplinks"/>
<h1>popuplinks</h1>
<p>== Description ==
Adds &lt;tt&gt; target='_blank' and rel='external'&lt;/tt&gt; to all HTML &lt;tt&gt;Anchor&lt;/tt&gt; tags to open links in new windows.
Comment text in popup windows should be filtered through this. Right now it's a moderately dumb function, ideally it would detect whether a target or rel attribute was already there and adjust its actions accordingly.
== Usage ==
%%%&lt;?php popuplinks( $text ) ?&gt;%%%
== Parameters ==
{{Parameter|$text|string|Content to replace links to open in a new window.}}
== Return Values ==
; (string) : Content that has filtered links.
== Examples ==
=== Default usage===
&lt;pre&gt;
&lt;?php
echo popuplinks('Please visit &lt;a href=&quot;http://www.wordpress.com&quot;&gt;WordPress.com&lt;/a&gt;.');
?&gt;
&lt;/pre&gt;
Will output:
&lt;pre&gt;
Please visit &lt;a href=&quot;http://www.wordpress.com&quot; target='_blank' rel='external'&gt;WordPress.com&lt;/a&gt;
&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;popuplinks()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="sanitize_email" d:title="sanitize email">
<d:index d:value="sanitize email"/>
<h1>sanitize email</h1>
<p>== Description ==
Strips out all characters that are not allowable in an email address.
After &lt;code&gt;sanitize_email()&lt;/code&gt; has done its work, it passes the sanitized e-mail address through the [[Plugin API/Filter Reference/sanitize_email|sanitize_email]] filter.
== Usage ==
%%%&lt;?php sanitize_email( $email ) ?&gt;%%%
== Parameters ==
{{Parameter|$email|string|Email address to filter.}}
== Return Values ==
; (string) : Filtered email address.
== Examples ==
&lt;pre&gt;
&lt;?php
$sanitized_email = sanitize_email(' admin@example.com! ');
echo $sanitized_email; // will output: 'admin@example.com'
?&gt;
&lt;/pre&gt;
== Notes ==
* This function uses a smaller allowable character set than the set defined by [http://tools.ietf.org/html/rfc5322 RFC 5322]. Some legal email addresses may be changed.
* Allowed character regular expression: &lt;code&gt;/[^a-z0-9+_.@-]/i&lt;/code&gt;.
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;code&gt;sanitize_email()&lt;/code&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
=== Functions ===
{{sanitize functions|sanitize_email()}}
=== Filters ===
{{sanitize filters|sanitize_email}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="ent2ncr" d:title="ent2ncr">
<d:index d:value="ent2ncr"/>
<h1>ent2ncr</h1>
<p>== Description ==
Converts named entities into numbered entities.
== Usage ==
%%%&lt;?php ent2ncr( $text ) ?&gt;%%%
== Parameters ==
{{Parameter|$text|string|The text within which entities will be converted.}}
== Return Values ==
; (string) : Text with converted entities.
== Examples ==
&lt;pre&gt;
&lt;?php
echo ent2ncr(&quot;C&amp;amp;rsquo;est la f&amp;amp;ecirc;te!&quot;);
// this will output: C&amp;amp;#8217;est la f&amp;amp;#234;te!
?&gt;
&lt;/pre&gt;
And you will see:
&lt;pre&gt;
C'est la f&ecirc;te!
&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: 1.5.1
== Source File ==
&lt;tt&gt;ent2ncr()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_richedit_pre" d:title="wp richedit pre">
<d:index d:value="wp richedit pre"/>
<h1>wp richedit pre</h1>
<p>{{Languages|
{{en|Function Reference/wp_richedit_pre}}
{{it|Riferimento funzioni/wp_richedit_pre}}
}}
== Description ==
Formats text for the rich text editor.
The filter '&lt;tt&gt;richedit_pre&lt;/tt&gt;' is applied here. If &lt;tt&gt;$text&lt;/tt&gt; is empty the filter will be applied to an empty string.
== Usage ==
%%%&lt;?php wp_richedit_pre( $text ) ?&gt;%%%
== Parameters ==
{{Parameter|$text|string|The text to be formatted.}}
== Return Values ==
; (string) : The formatted text after filter is applied.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;tt&gt;wp_richedit_pre()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="clean_url" d:title="clean url">
<d:index d:value="clean url"/>
<h1>clean url</h1>
<p>{{Deprecated}}
Use [[Function_Reference/esc_url|esc_url()]] instead. Usage is described [[Data_Validation#URLs|here]].
== Description ==
Checks and cleans a URL.
A number of characters are removed from the URL. If the URL is for displaying (the default behaviour) ampersands (&lt;tt&gt;&amp;&lt;/tt&gt;) are also replaced. The '&lt;tt&gt;clean_url&lt;/tt&gt;' filter is applied to the returned cleaned URL.
== Usage ==
%%%&lt;?php clean_url( $url, $protocols, $context ) ?&gt;%%%
== Parameters ==
{{Parameter|$url|string|The URL to be cleaned.}}
{{Parameter|$protocols|array|An array of acceptable protocols. Defaults to '&lt;tt&gt;http&lt;/tt&gt;', '&lt;tt&gt;https&lt;/tt&gt;', '&lt;tt&gt;ftp&lt;/tt&gt;', '&lt;tt&gt;ftps&lt;/tt&gt;', '&lt;tt&gt;mailto&lt;/tt&gt;', '&lt;tt&gt;news&lt;/tt&gt;', '&lt;tt&gt;irc&lt;/tt&gt;', '&lt;tt&gt;gopher&lt;/tt&gt;', '&lt;tt&gt;nntp&lt;/tt&gt;', '&lt;tt&gt;feed&lt;/tt&gt;', '&lt;tt&gt;telnet&lt;/tt&gt;' if not set.|optional|null}}
{{Parameter|$context|string|How the URL will be used. Default is '&lt;tt&gt;display&lt;/tt&gt;'.|optional|'display'}}
== Return Values ==
; (string) : The cleaned &lt;tt&gt;$url&lt;/tt&gt; after the '&lt;tt&gt;cleaned_url&lt;/tt&gt;' filter is applied.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/wp_kses_bad_protocol|&lt;tt&gt;wp_kses_bad_protocol()&lt;/tt&gt;]] to only permit protocols in the URL set via &lt;tt&gt;$protocols&lt;/tt&gt; or the common ones set in the function.
== Changelog ==
* Deprecated: [[Version 3.0|3.0.0]] use [[Function_Reference/esc_url|esc_url()]]
* Since: 1.2.0
== Source File ==
&lt;tt&gt;clean_url()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
* [[Data Validation]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="htmlentities2" d:title="htmlentities2">
<d:index d:value="htmlentities2"/>
<h1>htmlentities2</h1>
<p>== Description ==
Convert entities, while preserving already-encoded entities.
== Usage ==
%%%&lt;?php htmlentities2( $myHTML ) ?&gt;%%%
== Parameters ==
{{Parameter|$myHTML|string|The text to be converted.}}
== Return Values ==
; (string) : Converted text.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* See Also: [http://www.php.net/htmlentities Borrowed from the PHP Manual user notes.]
== Change Log ==
Since: 1.2.2
== Source File ==
&lt;tt&gt;htmlentities2()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="js_escape" d:title="js escape">
<d:index d:value="js escape"/>
<h1>js escape</h1>
<p>{{Deprecated}}
== Description ==
Escape single quotes. Convert double quotes. Fix line endings.
The filter '&lt;tt&gt;js_escape&lt;/tt&gt;' is also applied here.
&lt;tt&gt;js_escape&lt;/tt&gt; has been deprecated since 2.8. Use &lt;tt&gt;[[Data_Validation#JavaScript|esc_js]]&lt;/tt&gt; instead.
== Usage ==
%%%&lt;?php js_escape( $text ) ?&gt;%%%
== Parameters ==
{{Parameter|$text|string|The text to be escaped.}}
== Return Values ==
; (string) : Escaped text.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/wp_specialchars|&lt;tt&gt;wp_specialchars()&lt;/tt&gt;]] for double quote conversion.
== Change Log ==
Since: 2.0.4
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;js_escape()&lt;/tt&gt; is located in &lt;tt&gt;wp-includes/formatting.php&lt;/tt&gt;.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_make_link_relative" d:title="wp make link relative">
<d:index d:value="wp make link relative"/>
<h1>wp make link relative</h1>
<p>{{Languages|
{{en|Function Reference/wp_make_link_relative}}
{{it|Riferimento funzioni/wp_make_link_relative}}
}}
== Description ==
Convert full URL paths to relative paths.
Removes the http or https protocols and the domain. Keeps the path '/' at the beginning, so it isn't a true relative link, but from the web root base.
== Usage ==
%%%&lt;?php wp_make_link_relative( $link ) ?&gt;%%%
== Parameters ==
{{Parameter|$link|string|Full URL path.}}
== Return Values ==
; (string) : Absolute path.
== Examples ==
===Default usage===
&lt;pre&gt;
&lt;?php
echo wp_make_link_relative('http://localhost/wp_test/sample-page/');
?&gt;
&lt;/pre&gt;
This should output the following URL:
&lt;pre&gt;
/wp_test/sample-page/
&lt;/pre&gt;
== Notes ==
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;wp_make_link_relative()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php|tags/3.4|2695}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="add_magic_quotes" d:title="add magic quotes">
<d:index d:value="add magic quotes"/>
<h1>add magic quotes</h1>
<p>{{Languages|
{{en|Function Reference/add_magic_quotes}}
{{it|Riferimento funzioni/add_magic_quotes}}
}}
== Description ==
Walks an array while sanitizing the contents.
== Usage ==
%%%&lt;?php add_magic_quotes( $array ) ?&gt;%%%
== Parameters ==
{{Parameter|$array|array|Array to walk while sanitizing contents.}}
== Return Values ==
{{it:Return||array|Sanitized &lt;tt&gt;$array&lt;/tt&gt;.}}
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] to sanitize values
== Change Log ==
Since: 0.71
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;add_magic_quotes()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_hook" d:title="wp kses hook">
<d:index d:value="wp kses hook"/>
<h1>wp kses hook</h1>
<p>== Description ==
You add any [http://sourceforge.net/projects/kses &lt;tt&gt;kses&lt;/tt&gt;] hooks here.
There is currently only one [http://sourceforge.net/projects/kses &lt;tt&gt;kses&lt;/tt&gt;] WordPress hook and it is called here. All parameters are passed to the hooks and expected to recieve a string.
== Usage ==
%%%&lt;?php wp_kses_hook( $string, $allowed_html, $allowed_protocols ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|Content to filter through [http://sourceforge.net/projects/kses &lt;tt&gt;kses&lt;/tt&gt;]}}
{{Parameter|$allowed_html|array|List of allowed HTML elements}}
{{Parameter|$allowed_protocols|array|Allowed protocol in links}}
== Return Values ==
; (string) : Filtered content through '&lt;tt&gt;pre_kses&lt;/tt&gt;' hook
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_hook()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_split" d:title="wp kses split">
<d:index d:value="wp kses split"/>
<h1>wp kses split</h1>
<p>== Description ==
Searches for HTML tags, no matter how malformed.
It also matches stray &quot;&gt;&quot; characters.
== Usage ==
%%%&lt;?php wp_kses_split( $string, $allowed_html, $allowed_protocols ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|Content to filter}}
{{Parameter|$allowed_html|array|Allowed HTML elements}}
{{Parameter|$allowed_protocols|array|Allowed protocols to keep}}
== Return Values ==
; (string) : Content with fixed HTML tags
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/wp_kses_split2|&lt;tt&gt;wp_kses_split2()&lt;/tt&gt;]] as a callback to do much of the work.
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_split()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_split2" d:title="wp kses split2">
<d:index d:value="wp kses split2"/>
<h1>wp kses split2</h1>
<p>== Description ==
Callback for [[Function_Reference/wp_kses_split|&lt;tt&gt;wp_kses_split()&lt;/tt&gt;]] for fixing malformed HTML tags.
This function does a lot of work. It rejects some very malformed things like &lt;tt&gt;&lt;nowiki&gt;&lt;:::&gt;&lt;/nowiki&gt;&lt;/tt&gt;. It returns an empty string, if the element isn't allowed (look ma, no &lt;tt&gt;strip_tags()&lt;/tt&gt;!). Otherwise it splits the tag into an element and an attribute list.
After the tag is split into an element and an attribute list, it is run through another filter which will remove illegal attributes and once that is completed, will be returned.
== Usage ==
%%%&lt;?php wp_kses_split2( $string, $allowed_html, $allowed_protocols ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|Content to filter}}
{{Parameter|$allowed_html|array|Allowed HTML elements}}
{{Parameter|$allowed_protocols|array|Allowed protocols to keep}}
== Return Values ==
; (string) : Fixed HTML element
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* &lt;strong&gt;This is a private function. It should not be called directly. It is listed in the Codex for completeness.&lt;/strong&gt;
* Uses: [[Function_Reference/wp_kses_attr|&lt;tt&gt;wp_kses_attr()&lt;/tt&gt;]]
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_split2()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_attr" d:title="wp kses attr">
<d:index d:value="wp kses attr"/>
<h1>wp kses attr</h1>
<p>== Description ==
Removes all attributes, if none are allowed for this element.
If some are allowed it calls [[Function_Reference/wp_kses_hair|&lt;tt&gt;wp_kses_hair()&lt;/tt&gt;]] to split them further, and then it builds up new [[wikipedia:HTML|HTML]] code from the data that [[Function_Reference/wp_kses_hair|&lt;tt&gt;wp_kses_hair()&lt;/tt&gt;]] returns. It also removes '&lt;tt&gt;&amp;lt;&lt;/tt&gt;' and '&lt;tt&gt;&amp;gt;&lt;/tt&gt;' characters, if there are any left. One more thing it does is to check if the tag has a closing XHTML slash, and if it does, it puts one in the returned code as well.
== Usage ==
%%%&lt;?php wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) ?&gt;%%%
== Parameters ==
{{Parameter|$element|string|[[wikipedia:HTML|HTML]] element/tag}}
{{Parameter|$attr|string|[[wikipedia:HTML|HTML]] attributes from HTML element to closing HTML element tag}}
{{Parameter|$allowed_html|array|Allowed [[wikipedia:HTML|HTML]] elements}}
{{Parameter|$allowed_protocols|array|Allowed protocols to keep}}
== Return Values ==
; (string) : Sanitized [[wikipedia:HTML|HTML]] element
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_attr()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_hair" d:title="wp kses hair">
<d:index d:value="wp kses hair"/>
<h1>wp kses hair</h1>
<p>== Description ==
Builds an attribute list from string containing attributes.
This function does a lot of work. It parses an attribute list into an array with attribute data, and tries to do the right thing even if it gets weird input. It will add quotes around attribute values that don't have any quotes or apostrophes around them, to make it easier to produce [[wikipedia:HTML|HTML]] code that will conform to W3C's HTML specification. It will also remove bad URL protocols from attribute values. It also reduces duplicate attributes by using the attribute defined first (foo='&lt;tt&gt;bar&lt;/tt&gt;' foo='&lt;tt&gt;baz&lt;/tt&gt;' will result in foo='&lt;tt&gt;bar&lt;/tt&gt;').
== Usage ==
%%%&lt;?php wp_kses_hair( $attr, $allowed_protocols ) ?&gt;%%%
== Parameters ==
{{Parameter|$attr|string|Attribute list from [[wikipedia:HTML|HTML]] element to closing HTML element tag}}
{{Parameter|$allowed_protocols|array|Allowed protocols to keep}}
== Return Values ==
; (array) : List of attributes after parsing
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_hair()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_check_attr_val" d:title="wp kses check attr val">
<d:index d:value="wp kses check attr val"/>
<h1>wp kses check attr val</h1>
<p>== Description ==
Performs different checks for attribute values.
The currently implemented checks are '&lt;tt&gt;maxlen&lt;/tt&gt;', '&lt;tt&gt;minlen&lt;/tt&gt;', '&lt;tt&gt;maxval&lt;/tt&gt;', '&lt;tt&gt;minval&lt;/tt&gt;' and '&lt;tt&gt;valueless&lt;/tt&gt;' with even more checks to come soon.
== Usage ==
%%%&lt;?php wp_kses_check_attr_val( $value, $vless, $checkname, $checkvalue ) ?&gt;%%%
== Parameters ==
{{Parameter|$value|string|Attribute value}}
{{Parameter|$vless|string|Whether the value is valueless or not. Use '&lt;tt&gt;y&lt;/tt&gt;' or '&lt;tt&gt;n&lt;/tt&gt;'}}
{{Parameter|$checkname|string|What &lt;tt&gt;$checkvalue&lt;/tt&gt; is checking for.}}
{{Parameter|$checkvalue|mixed|What constraint the value should pass}}
== Return Values ==
; (boolean) : Whether check passes (true) or not (false)
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_check_attr_val()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_bad_protocol" d:title="wp kses bad protocol">
<d:index d:value="wp kses bad protocol"/>
<h1>wp kses bad protocol</h1>
<p>== Description ==
Sanitize string from bad protocols.
This function removes all non-allowed protocols from the beginning of &lt;tt&gt;$string&lt;/tt&gt;. It ignores whitespace and the case of the letters, and it does understand [[wikipedia:HTML|HTML]] entities. It does its work in a while loop, so it won't be fooled by a string like '&lt;tt&gt;javascript:javascript:alert(57)&lt;/tt&gt;'.
== Usage ==
%%%&lt;?php wp_kses_bad_protocol( $string, $allowed_protocols ); ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|Content to filter bad protocols from}}
{{Parameter|$allowed_protocols|array|Allowed protocols to keep}}
== Return Values ==
; (string) : Filtered content
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_bad_protocol()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_no_null" d:title="wp kses no null">
<d:index d:value="wp kses no null"/>
<h1>wp kses no null</h1>
<p>== Description ==
Removes any NULL characters in &lt;tt&gt;$string&lt;/tt&gt;.
== Usage ==
%%%&lt;?php wp_kses_no_null( $string ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|}}
== Return Values ==
; (string) :
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_no_null()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_stripslashes" d:title="wp kses stripslashes">
<d:index d:value="wp kses stripslashes"/>
<h1>wp kses stripslashes</h1>
<p>== Description ==
Strips slashes from in front of quotes.
This function changes the character sequence &lt;tt&gt;\&quot;&lt;/tt&gt; to just &lt;tt&gt;&quot;&lt;/tt&gt;. It leaves all other slashes alone. It's really weird, but the quoting from preg_replace(//e) seems to require this.
== Usage ==
%%%&lt;?php wp_kses_stripslashes( $string ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|String to strip slashes}}
== Return Values ==
; (string) : Fixed strings with quoted slashes
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_stripslashes()&lt;/tt&gt; is located in &lt;tt&gt;{{Trac|wp-includes/kses.php}}&lt;/tt&gt;.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_array_lc" d:title="wp kses array lc">
<d:index d:value="wp kses array lc"/>
<h1>wp kses array lc</h1>
<p>{{Languages|
{{en|Function Reference/wp_kses_array_lc}}
{{it|Riferimento funzioni/wp_kses_array_lc}}
}}
== Description ==
Goes through an array and changes the keys to all lower case.
== Usage ==
%%%&lt;?php wp_kses_array_lc( $inarray ) ?&gt;%%%
== Parameters ==
{{Parameter|$inarray|array|Unfiltered array}}
== Return Values ==
; (array) : Fixed array with all lowercase keys
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* This function expects a multi-dimensional array for input.
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_array_lc()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_js_entities" d:title="wp kses js entities">
<d:index d:value="wp kses js entities"/>
<h1>wp kses js entities</h1>
<p>== Description ==
Removes the [[wikipedia:HTML|HTML]] JavaScript entities found in early versions of Netscape 4.
== Usage ==
%%%&lt;?php wp_kses_js_entities( $string ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|}}
== Return Values ==
; (string) :
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_js_entities()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_html_error" d:title="wp kses html error">
<d:index d:value="wp kses html error"/>
<h1>wp kses html error</h1>
<p>== Description ==
Handles parsing errors in [[Function_Reference/wp_kses_hair|&lt;tt&gt;wp_kses_hair()&lt;/tt&gt;]].
The general plan is to remove everything to and including some whitespace, but it deals with quotes and apostrophes as well.
== Usage ==
%%%&lt;?php wp_kses_html_error( $string ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|}}
== Return Values ==
; (string) :
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_html_error()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_bad_protocol_once" d:title="wp kses bad protocol once">
<d:index d:value="wp kses bad protocol once"/>
<h1>wp kses bad protocol once</h1>
<p>== Description ==
Sanitizes content from bad protocols and other characters.
This function searches for URL protocols at the beginning of &lt;tt&gt;$string&lt;/tt&gt;, while handling whitespace and [[wikipedia:HTML|HTML]] entities.
== Usage ==
%%%&lt;?php wp_kses_bad_protocol_once( $string, $allowed_protocols ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|Content to check for bad protocols}}
{{Parameter|$allowed_protocols|string|Allowed protocols}}
== Return Values ==
; (string) : Sanitized content
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_bad_protocol_once()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_bad_protocol_once2" d:title="wp kses bad protocol once2">
<d:index d:value="wp kses bad protocol once2"/>
<h1>wp kses bad protocol once2</h1>
<p>== Description ==
Callback for [[Function_Reference/wp_kses_bad_protocol_once|&lt;tt&gt;wp_kses_bad_protocol_once()&lt;/tt&gt;]] regular expression.
This function processes URL protocols, checks to see if they're in the white-list or not, and returns different data depending on the answer.
== Usage ==
%%%&lt;?php wp_kses_bad_protocol_once2( $matches, $allowed_protocols ) ?&gt;%%%
== Parameters ==
{{Parameter|$matches|$string|URI scheme to check against the whitelist}}
{{Parameter|$allowed_protocols|$string|Allowed protocols}}
== Return Values ==
{{Return||string|Sanitized content}}
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* &lt;strong&gt;This is a private function. It should not be called directly. It is listed in the Codex for completeness.&lt;/strong&gt;
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_bad_protocol_once2()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_normalize_entities" d:title="wp kses normalize entities">
<d:index d:value="wp kses normalize entities"/>
<h1>wp kses normalize entities</h1>
<p>== Description ==
Converts and fixes [[wikipedia:HTML_entities|HTML entities]].
This function normalizes HTML entities. It will convert 'AT&amp;T' to the correct 'AT&amp;amp;amp;T', '&amp;amp;#00058;' to '&amp;amp;#58;', '&amp;amp;#XYZZY;' to '&amp;amp;amp;#XYZZY;' and so on.
== Usage ==
%%%&lt;?php wp_kses_normalize_entities( $string ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|Content to normalize entities}}
== Return Values ==
; (string) : Content with normalized entities
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_normalize_entities()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_normalize_entities2" d:title="wp kses normalize entities2">
<d:index d:value="wp kses normalize entities2"/>
<h1>wp kses normalize entities2</h1>
<p>== Description ==
Callback for [[Function_Reference/wp_kses_normalize_entities|&lt;tt&gt;wp_kses_normalize_entities()&lt;/tt&gt;]] regular expression.
This function helps [[Function_Reference/wp_kses_normalize_entities|&lt;tt&gt;wp_kses_normalize_entities()&lt;/tt&gt;]] to only accept 16 bit values and nothing more for &lt;tt&gt;&amp;#number;&lt;/tt&gt; entities.
== Usage ==
%%%&lt;?php wp_kses_normalize_entities2( $matches ) ?&gt;%%%
== Parameters ==
{{Parameter|$matches|array|[http://www.php.net/manual/en/function.preg-replace-callback.php &lt;tt&gt;preg_replace_callback()&lt;/tt&gt;] matches array}}
== Return Values ==
; (string) : Correctly encoded entity
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* &lt;strong&gt;This is a private function. It should not be called directly. It is listed in the Codex for completeness.&lt;/strong&gt;
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_normalize_entities2()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_decode_entities" d:title="wp kses decode entities">
<d:index d:value="wp kses decode entities"/>
<h1>wp kses decode entities</h1>
<p>== Description ==
Convert all entities to their character counterparts.
This function decodes numeric [[wikipedia:HTML_entities|HTML entities]] (like &lt;tt&gt;&amp;amp;#65;&lt;/tt&gt; and &lt;tt&gt;&amp;amp;#x41;&lt;/tt&gt;). It doesn't do anything with other entities like &lt;tt&gt;&amp;amp;auml;&lt;/tt&gt;, but we don't need them in the URL protocol whitelisting system anyway.
== Usage ==
%%%&lt;?php wp_kses_decode_entities( $string ) ?&gt;%%%
== Parameters ==
{{Parameter|$string|string|Content to change entities}}
== Return Values ==
; (string) : Content after decoded entities
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_decode_entities()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_filter_kses" d:title="wp filter kses">
<d:index d:value="wp filter kses"/>
<h1>wp filter kses</h1>
<p>== Description ==
Sanitize content with allowed [[wikipedia:HTML|HTML]] [http://sourceforge.net/projects/kses Kses] rules.
&lt;tt&gt;wp_filter_kses&lt;/tt&gt; should generally be preferred over &lt;tt&gt;wp_kses_data&lt;/tt&gt; because &lt;tt&gt;wp_magic_quotes&lt;/tt&gt; escapes &lt;tt&gt;$_GET&lt;/tt&gt;, &lt;tt&gt;$_POST&lt;/tt&gt;, &lt;tt&gt;$_COOKIE&lt;/tt&gt;, &lt;tt&gt;$_SERVER&lt;/tt&gt;, and &lt;tt&gt;$_REQUEST&lt;/tt&gt; fairly early in the hook system, shortly after 'plugins_loaded' but earlier then 'init' or 'wp_loaded'.
== Usage ==
%%%&lt;?php wp_filter_kses( $data ) ?&gt;%%%
== Parameters ==
{{Parameter|$data|string|Content to filter}}
== Return Values ==
; (string) : Filtered content
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;unknown&lt;/tt&gt;) &lt;tt&gt;$allowedtags&lt;/tt&gt;
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_filter_kses()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_filter_post_kses" d:title="wp filter post kses">
<d:index d:value="wp filter post kses"/>
<h1>wp filter post kses</h1>
<p>== Description ==
Sanitize content for allowed [[wikipedia:HTML|HTML]] tags for post content.
Post content refers to the page contents of the '&lt;tt&gt;post&lt;/tt&gt;' type and not &lt;tt&gt;$_POST&lt;/tt&gt; data from forms.
KSES seems to stand for &quot;kses strips evil scripts!&quot;.
== Usage ==
%%%&lt;?php wp_filter_post_kses( $data ) ?&gt;%%%
== Parameters ==
{{Parameter|$data|string|Post content to filter}}
== Return Values ==
; (string) : Filtered post content with allowed [[wikipedia:HTML|HTML]] tags and attributes intact.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;unknown&lt;/tt&gt;) &lt;tt&gt;$allowedposttags&lt;/tt&gt;
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;wp_filter_post_kses()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_filter_nohtml_kses" d:title="wp filter nohtml kses">
<d:index d:value="wp filter nohtml kses"/>
<h1>wp filter nohtml kses</h1>
<p>{{Languages|
{{en|Function Reference/wp_filter_nohtml_kses}}
{{it|Riferimento funzioni/wp_filter_nohtml_kses}}
}}
== Description ==
Strips all of the [[wikipedia:HTML|HTML]] in the content.
== Usage ==
%%%&lt;?php wp_filter_nohtml_kses( $data ) ?&gt;%%%
== Parameters ==
{{Parameter|$data|string|Content to strip all [[wikipedia:HTML|HTML]] from}}
== Return Values ==
; (string) : Filtered content without any [[wikipedia:HTML|HTML]]
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;wp_filter_nohtml_kses()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_term_children" d:title="get term children">
<d:index d:value="get term children"/>
<h1>get term children</h1>
<p>{{Languages|
{{en|Function Reference/get term children}}
{{ja|関数リファレンス/get term children}}
}}
== Description ==
Merge all term children into a single array.
This recursive function will merge all of the children of &lt;tt&gt;$term&lt;/tt&gt; into the same array. Only useful for taxonomies which are hierarchical.
Will return an empty array if &lt;tt&gt;$term&lt;/tt&gt; does not exist in &lt;tt&gt;$taxonomy&lt;/tt&gt;.
== Usage ==
%%%&lt;?php get_term_children( $term, $taxonomy ) ?&gt;%%%
== Parameters ==
{{Parameter|$term|string|ID of Term to get children}}
{{Parameter|$taxonomy|string|Taxonomy Name}}
== Return Values ==
; (array&amp;#124;WP_Error) : Array of Term IDs. WP_Error returned if &lt;tt&gt;$taxonomy&lt;/tt&gt; does not exist
== Examples ==
=== A Basic Example ===
Used to get an array of children taxonomies and write them out with links in an unordered list.
&lt;pre&gt;&lt;nowiki&gt;&lt;?php
$term_id = 10;
$taxonomy_name = 'products';
$termchildren = get_term_children( $term_id, $taxonomy_name );
echo '&lt;ul&gt;';
foreach ( $termchildren as $child ) {
$term = get_term_by( 'id', $child, $taxonomy_name );
echo '&lt;li&gt;&lt;a href=&quot;' . get_term_link( $child, $taxonomy_name ) . '&quot;&gt;' . $term-&gt;name . '&lt;/a&gt;&lt;/li&gt;';
}
echo '&lt;/ul&gt;';
?&gt; &lt;/nowiki&gt;&lt;/pre&gt;
This would return something like.
&lt;pre&gt;&lt;nowiki&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;link_to_term_page&quot;&gt;Term 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;link_to_term_page&quot;&gt;Term 2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/nowiki&gt;&lt;/pre&gt;
== Notes ==
* Uses: [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
* Uses: [[Function_Reference/_get_term_hierarchy|&lt;tt&gt;_get_term_hierarchy()&lt;/tt&gt;]]
* Uses: get_term_children Used to get the children of both &lt;tt&gt;$taxonomy&lt;/tt&gt; and the parent &lt;tt&gt;$term&lt;/tt&gt;
== Change Log ==
Since: 2.3.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_term_children()&lt;/tt&gt; is located in {{Trac|wp-includes/taxonomy.php}}.
== Related ==
{{Term Tags}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="previous_comments_link" d:title="previous comments link">
<d:index d:value="previous comments link"/>
<h1>previous comments link</h1>
<p>{{Languages|
{{en|Function Reference/previous_comments_link}}
{{it|Riferimento funzioni/previous_comments_link}}
}}
== Description ==
Display the previous comments page link.
== Usage ==
%%%&lt;?php previous_comments_link( $label ) ?&gt;%%%
== Parameters ==
{{Parameter|$label|string|Label for comments link text.|optional|&amp;#39;&amp;#39;}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 2.7.0
== Source File ==
&lt;tt&gt;previous_comments_link()&lt;/tt&gt; is located in {{Trac|wp-includes/link-template.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="format_to_post" d:title="format to post">
<d:index d:value="format to post"/>
<h1>format to post</h1>
<p>{{Deprecated}}
== Description ==
Holder for the '&lt;tt&gt;format_to_post&lt;/tt&gt;' filter. Deprecated in [[Version_3.9|3.9.0]]. Use [[Class_Reference/wpdb|wpdb::prepare()]] instead.
== Usage ==
%%%&lt;?php format_to_post( $content ) ?&gt;%%%
== Parameters ==
{{Parameter|$content|string|The text to pass through the filter.}}
== Return Values ==
; (string) : Text returned from the '&lt;tt&gt;format_to_post&lt;/tt&gt;' filter.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
* Since: [[Version_0.71|0.71]]
* Deprecated: [[Version_3.9|3.9.0]]
== Source File ==
&lt;tt&gt;format_to_post()&lt;/tt&gt; is located in {{Trac|wp-includes/formatting.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_kses_version" d:title="wp kses version">
<d:index d:value="wp kses version"/>
<h1>wp kses version</h1>
<p>{{Languages|
{{en|Function Reference/wp_kses_version}}
{{it|Riferimento funzioni/wp_kses_version}}
}}
== Description ==
This function returns the [http://sourceforge.net/projects/kses &lt;tt&gt;kses&lt;/tt&gt;] version number.
== Usage ==
%%%&lt;?php wp_kses_version() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : [http://sourceforge.net/projects/kses &lt;tt&gt;KSES&lt;/tt&gt;] Version Number
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;tt&gt;wp_kses_version()&lt;/tt&gt; is located in {{Trac|wp-includes/kses.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="maybe_serialize" d:title="maybe serialize">
<d:index d:value="maybe serialize"/>
<h1>maybe serialize</h1>
<p>== Description ==
[http://php.net/manual/en/function.serialize.php Serialize] data, if needed.
== Usage ==
%%%&lt;?php maybe_serialize( $data ); ?&gt;%%%
== Parameters ==
{{Parameter|$data|mixed|Data that might be serialized.}}
== Return Values ==
; (mixed) : A scalar data
== Examples ==
&lt;pre&gt;
&lt;?php
// Strings are returned untouched.
$data = 'Hello World!';
echo maybe_serialize( $data );
// Hello World!
// Integers, floats and boolean values are also returned untouched.
$data = 55;
echo maybe_serialize( $data );
// 55
$data = 4.560
echo maybe_serialize( $data );
// 4.560
$data = true;
$data = maybe_serialize( $data );
// $data = true;
$data = null;
$data = maybe_serialize( $data );
// $data = null
// An array or object will be returned as a serialized string.
$data = array( 1 =&gt; 'Hello World!', 'foo' =&gt; 'bar' );
echo maybe_serialize( $data );
// a:2:{i:1;s:12:&quot;Hello World!&quot;;s:3:&quot;foo&quot;;s:3:&quot;bar&quot;;}
// A serialized string will be serialized again.
$data = 'a:2:{i:1;s:12:&quot;Hello World!&quot;;s:3:&quot;foo&quot;;s:3:&quot;bar&quot;;}';
echo maybe_serialize( $data );
// s:50:&quot;a:2:{i:1;s:12:&quot;Hello World!&quot;;s:3:&quot;foo&quot;;s:3:&quot;bar&quot;;}&quot;;
?&gt;
&lt;/pre&gt;
== Notes ==
* Data might need to be &lt;i&gt;serialized&lt;/i&gt; to allow it to be successfully stored and retrieved from a database in a form that PHP can understand.
* Confusingly, strings that contain already serialized values are serialized again, resulting in a nested serialization. Other strings are unmodified.
A possible solution to prevent nested serialization is to check if a variable is serialized using %%%&lt;?php if(!is_serialized( $data )) { $data = maybe_serialize($data); } ?&gt;%%%
More info at [[Function_Reference/is_serialized | is_serialized()]].
== Change Log ==
Since: 2.0.5
== Source File ==
&lt;tt&gt;maybe_serialize()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="maybe_unserialize" d:title="maybe unserialize">
<d:index d:value="maybe unserialize"/>
<h1>maybe unserialize</h1>
<p>{{Languages|
{{en|Function Reference/maybe_unserialize}}
{{it|Riferimento funzioni/maybe_unserialize}}
}}
== Description ==
Unserialize value only if it was serialized.
== Usage ==
%%%&lt;?php maybe_unserialize( $original ) ?&gt;%%%
== Parameters ==
{{Parameter|$original|string|Maybe unserialized original, if is needed.}}
== Return Values ==
{{Return||mixed|Unserialized data can be any type.}}
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Data might need to be &lt;i&gt;serialized&lt;/i&gt; to allow it to be successfully stored and retrieved from a database in a form that PHP can understand.
== Change Log ==
Since: 2.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;maybe_unserialize()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="is_serialized" d:title="is serialized">
<d:index d:value="is serialized"/>
<h1>is serialized</h1>
<p>== Description ==
Check value to find if it was serialized.
If &lt;tt&gt;$data&lt;/tt&gt; is not a string, then returned value will always be false. Serialized data is always a string.
== Usage ==
%%%&lt;?php is_serialized( $data ) ?&gt;%%%
== Parameters ==
{{Parameter|$data|mixed|Value to check to see if was serialized.}}
== Return Values ==
; (boolean) : False if not serialized and true if it was.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Data might need to be &lt;i&gt;serialized&lt;/i&gt; to allow it to be successfully stored and retrieved from a database in a form that PHP can understand.
== Change Log ==
Since: 2.0.5
== Source File ==
&lt;tt&gt;is_serialized()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:Conditional Tags]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="is_serialized_string" d:title="is serialized string">
<d:index d:value="is serialized string"/>
<h1>is serialized string</h1>
<p>== Description ==
Check whether serialized data is of string type.
== Usage ==
%%%&lt;?php is_serialized_string( $data ) ?&gt;%%%
== Parameters ==
{{Parameter|$data|mixed|Serialized data}}
== Return Values ==
; (boolean) : False if not a serialized string, true if it is.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Data might need to be &lt;i&gt;serialized&lt;/i&gt; to allow it to be successfully stored and retrieved from a database in a form that PHP can understand.
== Change Log ==
Since: 2.0.5
== Source File ==
&lt;tt&gt;is_serialized_string()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:Conditional Tags]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_alloptions" d:title="get alloptions">
<d:index d:value="get alloptions"/>
<h1>get alloptions</h1>
<p>{{Deprecated}}
Deprecated since WordPress 3.0, use [[Function_Reference/wp_load_alloptions| wp_load_alloptions()]] instead.
== Description ==
Retrieve all autoload options or all options, if no autoloaded ones exist.
This is different from [[Function_Reference/wp_load_alloptions|&lt;tt&gt;wp_load_alloptions()&lt;/tt&gt;]] in that this function does not cache its results and will retrieve all options from the database every time it is called.
== Usage ==
%%%&lt;?php get_alloptions() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (array) : List of all options.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;pre_option_$optionname&lt;/tt&gt;' hook with option value as parameter.
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;all_options&lt;/tt&gt;' on options list.
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]]
== Change Log ==
Since: 1.0.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;get_alloptions()&lt;/tt&gt; is located in &lt;tt&gt;wp-includes/functions.php&lt;/tt&gt;.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="get_user_option" d:title="get user option">
<d:index d:value="get user option"/>
<h1>get user option</h1>
<p>== Description ==
Retrieve user option that can be either per Site or per Network.
If the user ID is not given, then the current user will be used instead. The filter for the result will also pass the original option name and finally the user data object as the third parameter.
The function will first check for the site-specific user metadata, then the network-wide user metadata. The option can either be modified or set by a plugin.
== Usage ==
%%%&lt;?php get_user_option( $option, $user ) ?&gt;%%%
== Parameters ==
{{Parameter|$option|string|User option name.}}
{{Parameter|$user|integer|User ID. If not given, the current user will be used.|optional|0}}
{{Parameter|$deprecated|string|This parameter is no longer used. Setting it will generate a deprecated argument notice.|optional|Empty string}}
== Return Values ==
; (mixed) : Option value on success, false on failure
== Examples ==
&lt;pre&gt;
&lt;?php
$bar = get_user_option( 'show_admin_bar_front', get_current_user_id() );
if ( $bar == 'true' ) {
echo 'The admin bar is enabled';
} else {
echo 'The admin bar is disabled';
}
?&gt;
&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls &lt;tt&gt;'get_user_option_$option'&lt;/tt&gt; hook with result, option parameter, and user data object.
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] WordPress database object for queries.
== Change Log ==
* [[Version_3.0|3.0.0]] - The &lt;tt&gt;$check_blog_options&lt;/tt&gt; parameter was deprecated, and the function no longer checks the options table if the option isn't found in &lt;tt&gt;[[Database_Description#Table:_wp_usermeta | wp_usermeta]]&lt;/tt&gt;. See [https://core.trac.wordpress.org/ticket/11615 #11615].
* Since: [[Version_2.0|2.0.0]]
== Source File ==
&lt;tt&gt;get_user_option()&lt;/tt&gt; is located in {{Trac|wp-includes/user.php}}.
== Related ==
{{User_Meta_Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="update_user_option" d:title="update user option">
<d:index d:value="update user option"/>
<h1>update user option</h1>
<p>== Description ==
Update a user option that can be either per Site or per Network.
User options are just like user metadata except that they have support for blog-specific options when using multisite. If the &lt;tt&gt;$global&lt;/tt&gt; parameter is &lt;tt&gt;false&lt;/tt&gt;, which it is by default, it will prepend the WordPress table prefix to the option name.
== Usage ==
%%%&lt;?php update_user_option( $user_id, $option_name, $newvalue, $global ) ?&gt;%%%
== Parameters ==
{{Parameter|$user_id|integer|User ID}}
{{Parameter|$option_name|string|User option name.}}
{{Parameter|$newvalue|mixed|User option value.}}
{{Parameter|$global|boolean|Whether option name is blog specific or not.|optional|false}}
== Return Values ==
; (boolean) : Whether the update was successful
== Examples ==
Hide the admin bar for a user on the front end of the site:
&lt;pre&gt;
update_user_option( $user_id, 'show_admin_bar_front', false );
&lt;/pre&gt;
When multisite is installed, the &lt;tt&gt;$global&lt;/tt&gt; parameter can be used to set the user option for the whole network, instead of just the current site:
&lt;pre&gt;
update_user_option( $user_id, 'show_admin_bar_front', false, true );
&lt;/pre&gt;
== Notes ==
* Uses global: (&lt;tt&gt;object&lt;/tt&gt;) [[Class Reference/wpdb|&lt;tt&gt;$wpdb&lt;/tt&gt;]] WordPress database object for queries.
== Change Log ==
* Since: [[Version 2.0|2.0]]
== Source File ==
&lt;tt&gt;update_user_option()&lt;/tt&gt; is located in {{Trac|wp-includes/user.php}}.
== Related ==
{{User_Meta_Tags}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="xmlrpc_getposttitle" d:title="xmlrpc getposttitle">
<d:index d:value="xmlrpc getposttitle"/>
<h1>xmlrpc getposttitle</h1>
<p>== Description ==
Retrieve post title from [[XML-RPC_Support|XMLRPC]] XML.
If the title element is not part of the XML, then the default post title from the &lt;tt&gt;$post_default_title&lt;/tt&gt; will be used instead.
== Usage ==
%%%&lt;?php xmlrpc_getposttitle( $content ) ?&gt;%%%
== Parameters ==
{{Parameter|$content|string|[[XML-RPC_Support|XMLRPC]] XML Request content}}
== Return Values ==
; (string) : Post title
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;string&lt;/tt&gt;) &lt;tt&gt;$post_default_title&lt;/tt&gt;
== Change Log ==
Since: 0.71
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;xmlrpc_getposttitle()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="xmlrpc_getpostcategory" d:title="xmlrpc getpostcategory">
<d:index d:value="xmlrpc getpostcategory"/>
<h1>xmlrpc getpostcategory</h1>
<p>== Description ==
Retrieve the post category or categories from [[XML-RPC_Support|XMLRPC]] XML.
If the category element is not found, then the default post category will be used. The return type then would be what &lt;tt&gt;$post_default_category&lt;/tt&gt;. If the category is found, then it will always be an array.
== Usage ==
%%%&lt;?php xmlrpc_getpostcategory( $content ); ?&gt;%%%
== Parameters ==
{{Parameter|$content|string|[[XML-RPC_Support|XMLRPC]] XML Request content}}
== Return Values ==
; (string&amp;#124;array) : List of categories or category name.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;unknown&lt;/tt&gt;) &lt;tt&gt;$post_default_category&lt;/tt&gt;
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;xmlrpc_getpostcategory()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="xmlrpc_removepostdata" d:title="xmlrpc removepostdata">
<d:index d:value="xmlrpc removepostdata"/>
<h1>xmlrpc removepostdata</h1>
<p>== Description ==
[[XML-RPC_Support|XMLRPC]] XML content without title and category elements.
== Usage ==
%%%&lt;?php xmlrpc_removepostdata( $content ) ?&gt;%%%
== Parameters ==
{{Parameter|$content|string|[[XML-RPC_Support|XMLRPC]] XML Request content}}
== Return Values ==
; (string) : [[XML-RPC_Support|XMLRPC]] XML Request content without title and category elements.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
== Change Log ==
Since: 0.71
== Source File ==
&lt;tt&gt;xmlrpc_removepostdata()&lt;/tt&gt; is located in {{Trac|wp-includes/functions.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="user_pass_ok" d:title="user pass ok">
<d:index d:value="user pass ok"/>
<h1>user pass ok</h1>
<p>{{Deprecated}}
== Description ==
'''As of WordPress [[Version_3.5|3.5]] this function has been deprecated in favor of [[Function Reference/wp_authenticate|wp_authenticate()]]'''
Check that the user login name and password is correct.
== Usage ==
%%%&lt;?php user_pass_ok( $user_login, $user_pass ) ?&gt;%%%
== Parameters ==
{{Parameter|$user_login|string|User name.}}
{{Parameter|$user_pass|string|User password.}}
== Return Values ==
; (boolean) : &lt;tt&gt;False&lt;/tt&gt; if does not authenticate, &lt;tt&gt;true&lt;/tt&gt; if username and password authenticates.
== Examples ==
&lt;pre&gt;
&lt;?php
$user_login = 'admin';
$user_pass = 'mypass';
if ( !user_pass_ok( $user_login, $user_pass ) ) {
echo &quot;Sorry, you are not allowed to do this.&quot;;
exit;
}
?&gt;
&lt;/pre&gt;
== Notes ==
== Change Log ==
* Deprecated: [[Version 3.5|3.5.0]]
* Since: 0.71
== Source File ==
&lt;tt&gt;user_pass_ok()&lt;/tt&gt; is located in {{Trac|wp-includes/user.php}}.
== Related ==
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="get_locale" d:title="get locale">
<d:index d:value="get locale"/>
<h1>get locale</h1>
<p>== Description ==
Gets the current locale.
If the locale is set, then it will filter the locale in the '&lt;tt&gt;locale&lt;/tt&gt;' filter hook and return the value.
If the locale is not set already, then the WPLANG constant is used if it is defined. Then it is filtered through the '&lt;tt&gt;locale&lt;/tt&gt;' filter hook and the value for the locale global set and the locale is returned.
The process to get the locale should only be done once but the locale will always be filtered using the '&lt;tt&gt;locale&lt;/tt&gt;' hook.
== Usage ==
%%%&lt;?php get_locale() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (string) : The locale of the blog or from the '&lt;tt&gt;locale&lt;/tt&gt;' hook.
== Examples ==
This sets the monetary locale and if empty, sets as en_US
&lt;pre&gt;setlocale(LC_MONETARY, get_locale());
$my_local_settings = localeconv();
if ($my_local_settings['int_curr_symbol'] == &quot;&quot;) setlocale(LC_MONETARY, 'en_US');&lt;/pre&gt;
This shows the value of setlocale:
&lt;pre&gt;setlocale(LC_MONETARY, get_locale());
print_r($my_local_settings);&lt;/pre&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;locale&lt;/tt&gt;' hook on locale value.
* Uses: &lt;tt&gt;$locale&lt;/tt&gt; Gets the locale stored in the global.
* Uses global: (&lt;tt&gt;unknown&lt;/tt&gt;) &lt;tt&gt;$locale&lt;/tt&gt;
* &lt;i&gt;l10n&lt;/i&gt; is an abbreviation for &lt;i&gt;localization&lt;/i&gt;.
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;tt&gt;get_locale()&lt;/tt&gt; is located in {{Trac|wp-includes/l10n.php}}.
== Related ==
{{Localization}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="_2" d:title=" 2">
<d:index d:value=" 2"/>
<h1> 2</h1>
<p>{{Languages|
{{en|Function_Reference/_2}}
{{ja|関数リファレンス/_2}}
{{ru|Справочник_по_функциям/_2}}
}}
{{Message|background=#FCECAD|text=This page is named incorrectly due to a limitation of Mediawiki page naming. The function name is &lt;tt&gt;__()&lt;/tt&gt; not &lt;tt&gt;_2()&lt;/tt&gt;.}}
== Description ==
Retrieves the translated string from the [[Function_Reference/translate|&lt;tt&gt;translate()&lt;/tt&gt;]].
== Usage ==
%%%&lt;?php $translated_text = __( $text, $domain ); ?&gt;%%%
== Parameters ==
{{Parameter|$text|string|Text to translate}}
{{Parameter|$domain|string|Domain to retrieve the translated text|optional|'default'}}
== Return Values ==
; (string) : Translated text
== Examples ==
Make a string inside your plugin or theme translatable:
&lt;pre&gt;
$translated = __( 'Hello World!', 'mytextdomain' );
&lt;/pre&gt;
&lt;tt&gt;'mytextdomain'&lt;/tt&gt; needs to be a unique text domain used throughout your plugin/theme. This should always be directly passed as a sting literal as shown above, ''not'' a string assigned to a variable or constant. E.g., this is incorrect:
&lt;pre&gt;
$text_domain = 'mytextdomain';
$string = 'Hello World!';
$translated = __( $string, $text_domain );
&lt;/pre&gt;
This ''seems'' to work, but it will interfere in automatic parsing of your plugin/theme's files for translation. See these for more information:
* [http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/ Internationalization: You're probably doing it wrong - Otto on WordPress]
* [http://markjaquith.wordpress.com/2011/10/06/translating-wordpress-plugins-and-themes-dont-get-clever/ Translating WordPress Plugins and Themes - Mark Jaquith]
== Notes ==
* See [[Function_Reference/_2|&lt;tt&gt;__()&lt;/tt&gt;]] An alias of [[Function_Reference/translate|&lt;tt&gt;translate()&lt;/tt&gt;]]
* &lt;i&gt;l10n&lt;/i&gt; is an abbreviation for &lt;i&gt;localization&lt;/i&gt;.
* The function name is two underscores in a row. In some fonts it looks like one long underscore. (Who says programmers don't have a sense of humor.)
== Change Log ==
* Since: [[Version 2.1|2.1.0]]
== Source File ==
&lt;tt&gt;__()&lt;/tt&gt; is located in {{Trac|wp-includes/l10n.php}}.
== Related ==
{{L10n}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="_e" d:title=" e">
<d:index d:value=" e"/>
<h1> e</h1>
<p>{{Languages|
{{en|Function_Reference/_e}}
{{ru|Справочник_по_функциям/_e}}
}}
== Description ==
Displays the returned translated text from [[Function_Reference/translate|&lt;tt&gt;translate()&lt;/tt&gt;]].
== Usage ==
%%%&lt;?php _e( $text, $domain ) ?&gt;%%%
== Parameters ==
{{Parameter|$text|string|Text to translate}}
{{Parameter|$domain|string|Domain to retrieve the translated text|optional|'default'}}
== Return Values ==
; (void) : This function does not return a value.
== Examples ==
Display some translated text:
&lt;?php _e( 'Some text to translate and display.', 'textdomain' ); ?&gt;
== Notes ==
* Echos returned [[Function_Reference/translate|&lt;tt&gt;translate()&lt;/tt&gt;]] string.
* &lt;i&gt;l10n&lt;/i&gt; is an abbreviation for &lt;i&gt;localization&lt;/i&gt;.
== Change Log ==
* Since: [[Version 1.2|1.2.0]]
== Source File ==
&lt;tt&gt;_e()&lt;/tt&gt; is located in {{Trac|wp-includes/l10n.php}}.
== Related ==
{{L10n}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="_2ngettext" d:title=" 2ngettext">
<d:index d:value=" 2ngettext"/>
<h1> 2ngettext</h1>
<p>{{Message|background=#FCECAD|text=This page is named incorrectly due to a limitation of Mediawiki page naming. The function name is __ngettext not _2ngettext.}}
{{Deprecated|new_function=_n|version=2.8}}
== Description ==
Retrieve the plural or single form based on the amount.
If the domain is not set in the &lt;tt&gt;$l10n&lt;/tt&gt; list, then a comparsion will be made and either &lt;tt&gt;$plural&lt;/tt&gt; or &lt;tt&gt;$single&lt;/tt&gt; parameters returned.
If the domain does exist, then the parameters &lt;tt&gt;$single&lt;/tt&gt;, &lt;tt&gt;$plural&lt;/tt&gt;, and &lt;tt&gt;$number&lt;/tt&gt; will first be passed to the domain's ngettext method. Then it will be passed to the '&lt;tt&gt;ngettext&lt;/tt&gt;' filter hook along with the same parameters. The expected type will be a string.
== Usage ==
%%%&lt;?php __ngettext( $single, $plural, $number, $domain ) ?&gt;%%%
== Parameters ==
{{Parameter|$single|string|The text that will be used if &lt;tt&gt;$number&lt;/tt&gt; is 1}}
{{Parameter|$plural|string|The text that will be used if &lt;tt&gt;$number&lt;/tt&gt; is not 1}}
{{Parameter|$number|integer|The number to compare against to use either &lt;tt&gt;$single&lt;/tt&gt; or &lt;tt&gt;$plural&lt;/tt&gt;}}
{{Parameter|$domain|string|The domain identifier the text should be retrieved in|optional|'default'}}
== Return Values ==
; (string) : Either &lt;tt&gt;$single&lt;/tt&gt; or &lt;tt&gt;$plural&lt;/tt&gt; translated text
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses: [[Function_Reference/apply_filters|&lt;tt&gt;apply_filters()&lt;/tt&gt;]] Calls '&lt;tt&gt;ngettext&lt;/tt&gt;' hook on domains text returned, along with &lt;tt&gt;$single&lt;/tt&gt;, &lt;tt&gt;$plural&lt;/tt&gt;, and &lt;tt&gt;$number&lt;/tt&gt; parameters. Expected to return string.
* Uses global: (&lt;tt&gt;array&lt;/tt&gt;) &lt;tt&gt;$l10n&lt;/tt&gt; Gets list of domain translated string (gettext_reader) objects.
* &lt;i&gt;l10n&lt;/i&gt; is an abbreviation for &lt;i&gt;localization&lt;/i&gt;.
* This function name has two leading underscores in a row. In some fonts it looks like one long underscore.
== Change Log ==
* Since: 1.2.0
* Deprecated: 2.8.0
== Source File ==
&lt;tt&gt;__ngettext()&lt;/tt&gt; was located in {{Trac|wp-includes/l10n.php}}. As of [[Version 2.8]] it was moved to {{Trac|wp-includes/deprecated.php}}.
== Related ==
{{L10n}}
{{Tag Footer}}
[[Category:Functions]]</p>
</d:entry>
<d:entry id="load_textdomain" d:title="load textdomain">
<d:index d:value="load textdomain"/>
<h1>load textdomain</h1>
<p>== Description ==
Loads MO file into the list of domains.
If the domain already exists, the inclusion will fail. If the MO file is not readable, the inclusion will fail.
On success, the MO file will be placed in the &lt;tt&gt;$l10n&lt;/tt&gt; global by &lt;tt&gt;$domain&lt;/tt&gt; and will be an &lt;tt&gt;gettext_reader&lt;/tt&gt; object.
== Usage ==
%%%&lt;?php load_textdomain( $domain, $mofile ) ?&gt;%%%
== Parameters ==
{{Parameter|$domain|string|Unique identifier for retrieving translated strings}}
{{Parameter|$mofile|string|Path to the .mo file}}
== Return Values ==
{{Return||boolean| First, will return '''true''' and exit if call to &lt;tt&gt;apply_filters('override_load_textdomain')&lt;/tt&gt; returns '''true'''. If .mo file is not readable or the import fails - returns '''false'''. Otherwise returns '''true'''. }}
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Uses global: (&lt;tt&gt;array&lt;/tt&gt;) &lt;tt&gt;$l10n&lt;/tt&gt;. Gets list of domain translated string objects.
* &lt;i&gt;l10n&lt;/i&gt; is an abbreviation for &lt;i&gt;localization&lt;/i&gt;. There are 10 characters between the initial 'l' and the terminal 'n'
== Change Log ==
Since: 1.5.0
== Source File ==
&lt;!-- Need links to current source code files --&gt;
&lt;tt&gt;load_textdomain()&lt;/tt&gt; is located in {{Trac|wp-includes/l10n.php}}.
== Related ==
{{Localization}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="load_plugin_textdomain" d:title="load plugin textdomain">
<d:index d:value="load plugin textdomain"/>
<h1>load plugin textdomain</h1>
<p>{{Languages|
{{en|Function Reference/load_plugin_textdomain}}
{{it|Riferimento funzioni/load_plugin_textdomain}}
}}
== Description ==
Loads the plugin's translated strings.
If the path is not given then it will be the root of the plugin directory. The .mo file should be named based on the domain followed by a dash, and then the locale exactly. The locale is the language code and/or country code you defined in the constant WPLANG in the file wp-config.php. For example, the locale for German is 'de_DE', and the locale for Danish is 'da_DK'. If your plugin's text domain is &quot;my-plugin&quot; the Danish .mo and.po files should be named &quot;my-plugin-da_DK.mo&quot; and &quot;my-plugin-da_DK.po&quot; Call this function in your plugin as early as the &lt;tt&gt;plugins_loaded&lt;/tt&gt; [[Plugin_API#Actions|action]].
If you call &lt;tt&gt;load_plugin_textdomain&lt;/tt&gt; multiple times for the same domain, the translations will be merged. If both sets have the same string, the translation from the original value will be taken.
== Usage ==
%%%&lt;?php load_plugin_textdomain( $domain, $abs_rel_path, $plugin_rel_path ) ?&gt;%%%
== Parameters ==
{{Parameter|$domain|string|Unique identifier for retrieving translated strings.}}
{{Parameter|$abs_rel_path|string|Relative path to &lt;tt&gt;ABSPATH&lt;/tt&gt; of a folder, where the .mo file resides. '''Deprecated''', but still functional until 2.7|optional|false}}
{{Parameter|$plugin_rel_path|string|Relative path to &lt;tt&gt;WP_PLUGIN_DIR&lt;/tt&gt;, &lt;b&gt;with a trailing slash&lt;/b&gt;. This is the preferred argument to use. It takes precendence over &lt;tt&gt;$abs_rel_path&lt;/tt&gt;|optional|false}}
== Return Values ==
; boolean : Returns true if the override_load_textdomain filter returns true or the language file wes loaded successfully. Returns false, if the language file could not be loaded (it is not readable or the mo file reader can not understand it).
== Examples ==
This example assumes that it is placed in the main plugin file, or at least a file in the plugin root. If it's not, you'll need to adjust the [https://codex.wordpress.org/Function_Reference/plugin_dir_path plugin_dir_path()] call accordingly.
&lt;pre&gt;add_action( 'plugins_loaded', 'myplugin_load_textdomain' );
/**
* Load plugin textdomain.
*
* @since 1.0.0
*/
function myplugin_load_textdomain() {
load_plugin_textdomain( 'my-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/langs/' );
}
&lt;/pre&gt;
== Notes ==
* &lt;i&gt;l10n&lt;/i&gt; is an abbreviation for &lt;i&gt;localization&lt;/i&gt;.
* &lt;i&gt;l10n&lt;/i&gt; is derived from the 10 letters between the &quot;l&quot; and the &quot;n&quot; of &lt;i&gt;localization&lt;/i&gt;.
== Change Log ==
* Since: [[Version 1.5|1.5.0]]
* [[Version 2.7|2.7.0]]: '&lt;tt&gt;$abs_rel_path&lt;/tt&gt;' parameter was deprecated.
== Source File ==
&lt;tt&gt;load_plugin_textdomain()&lt;/tt&gt; is located in {{Trac|wp-includes/l10n.php}}.
== Resources ==
* [http://geertdedeckere.be/article/loading-wordpress-language-files-the-right-way Loading WordPress language files the right way]
* [http://ottopress.com/2013/language-packs-101-prepwork/ Language packs 101 prepwork]
* [http://premium.wpmudev.org/blog/localize-a-wordpress-plugin-and-make-it-translation-ready/ Localize a WordPress plugin and make it translation ready]
== Related ==
{{Localization}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="load_theme_textdomain" d:title="load theme textdomain">
<d:index d:value="load theme textdomain"/>
<h1>load theme textdomain</h1>
<p>== Description ==
Loads the theme's translated strings.
If the current locale exists as a .mo file in the theme's root directory, it will be included in the translated strings by the &lt;tt&gt;$domain&lt;/tt&gt;.
The .mo files must be &lt;strong&gt;named based on the locale exactly&lt;/strong&gt;, &lt;code&gt;sv_SE.mo&lt;/code&gt; for example.
== Usage ==
%%%&lt;?php load_theme_textdomain( $domain, $path ) ?&gt;%%%
== Parameters ==
{{Parameter|$domain|string|Unique identifier for retrieving translated strings.}}
{{Parameter|$path|unknown|The directory where the .mo file can be found (without the trailing slash).|optional|false}}
== Return Values ==
; (bool) : This function return TRUE as textdomain well loaded, FALSE on failure.
== Examples ==
=== 1st example===
The load_theme_textdomain() function should generally be called from within the [[Plugin_API/Action_Reference/after_setup_theme|after_setup_theme]] action hook.
&lt;pre&gt;
add_action('after_setup_theme', 'my_theme_setup');
function my_theme_setup(){
load_theme_textdomain('my_theme', get_template_directory() . '/languages');
}
&lt;/pre&gt;
The &lt;code&gt;.mo&lt;/code&gt; files must use language-only filenames, like &lt;code&gt;languages/de_DE.mo&lt;/code&gt; in your theme directory.
Unlike plugin language files, a name like &lt;code&gt;my_theme-de_DE.mo&lt;/code&gt; will NOT work. Although plugin language files allow you to specify the text-domain in the filename, this will NOT work with themes. Language files for themes should include the language shortcut ONLY.
=== 2nd example===
you can use this example if you wish to switch theme language using a variable passed within the URL, for example to load the &lt;em&gt;Tamazikht&lt;/em&gt; language, your URL would look like; &lt;code&gt;www.example.com/?l=tz_MA&lt;/code&gt;, this will search for a &lt;code&gt;.mo&lt;/code&gt; file with name &lt;code&gt;tz_MA.mo&lt;/code&gt; in the language directory inside your theme.
&lt;pre&gt;
// CHANGE LOCAL LANGUAGE
// must be called before load_theme_textdomain()
add_filter( 'locale', 'my_theme_localized' );
function my_theme_localized( $locale )
{
if ( isset( $_GET['l'] ) )
{
return esc_attr( $_GET['l'] );
}
return $locale;
}
&lt;/pre&gt;
&lt;pre&gt;
// SET THEME LANGUAGES DIRECTORY
// Theme translations can be filed in the my_theme/languages/ directory
// Wordpress translations can be filed in the wp-content/languages/ directory
load_theme_textdomain( 'my_theme_textdomain', get_template_directory().'/languages' );
&lt;/pre&gt;
== Notes ==
Internationalization and localization (other correct spellings are internationalisation and localisation) are means of adapting computer software to different languages.
* &lt;i&gt;l10n&lt;/i&gt; is an abbreviation for &lt;i&gt;localization&lt;/i&gt;.
* &lt;i&gt;i18n&lt;/i&gt; 18 stands for the number of letters between the first i and last n in &lt;i&gt;internationalization&lt;/i&gt;.
== Change Log ==
* Since: [[Version 1.5|1.5.0]]
== Source File ==
&lt;tt&gt;load_theme_textdomain()&lt;/tt&gt; is located in {{Trac|wp-includes/l10n.php}}.
== External Resources ==
* [http://generatewp.com/theme-support/ WordPress Theme Support Generator]
== Related ==
{{Localization}}
{{Tag Footer}}
[[Category:Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="spawn_cron" d:title="spawn cron">
<d:index d:value="spawn cron"/>
<h1>spawn cron</h1>
<p>== Description ==
Send request to run cron through HTTP request that doesn't halt page loading. Will not run more than once every 60 seconds.
== Usage ==
%%%&lt;?php spawn_cron( $local_time ); ?&gt;%%%
== Parameters ==
== Return Values ==
; (null) : Cron could not be spawned, because it is not needed to run.
== Examples ==
&lt;!-- Need creative examples. Feel free to link to external examples. --&gt;
== Notes ==
* Cron is named after a unix program which runs unattended scheduled tasks.
== Change Log ==
Since: 2.1.0
== Source File ==
&lt;tt&gt;spawn_cron()&lt;/tt&gt; is located in {{Trac|wp-includes/cron.php}}.
== Related ==
&lt;!--
To Do:
Need to find related functions.
Need to create groups of functions and create templates to add them to a page quickly.
Some functions may be related to many groups of functions.
--&gt;
{{Tag Footer}}
[[Category:Functions]]
[[Category:WP-Cron Functions]]
[[Category:New_page_created]]</p>
</d:entry>
<d:entry id="wp_cron" d:title="wp cron">
<d:index d:value="wp cron"/>
<h1>wp cron</h1>
<p>== Description ==
Run scheduled callbacks or spawn cron for all scheduled events.
== Usage ==
%%%&lt;?php wp_cron() ?&gt;%%%
== Parameters ==
None.
== Return Values ==
; (null) : When cron doesn't need to run..
== Examples ==
&lt;pre&gt;
if ( ! wp_next_scheduled( 'my_task_hook' ) ) {
wp_schedule_event( time(), 'hourly', 'my_task_hook' );
}
add_action( 'my_task_hook', 'my_task_function' );
function my_task_function() {
wp_mail( 'your@email.com', 'Automatic email', 'Automatic scheduled email from WordPress.');
}
&lt;/pre&gt;
== Notes ==
* Cron is named after a unix program which runs unattended scheduled tasks.
== Change Log ==
* Since: [[Version 2.1|2.1.0]]
== Source File ==
&lt;tt&gt;wp_cron()&lt;/tt&gt; is located in {{Trac|wp-includes/cron.php}}.
== Related ==
* [[Function_Reference/wp_schedule_event|wp_schedule_event]]
{{Tag Footer}}
[[Category:Functions]]
[[Category:WP-Cron Functions]]</p>
</d:entry>
<d:entry id="wp_get_schedules" d:title="wp get schedules">
<d:index d:value="wp get schedules"/>
<h1>wp get schedules</h1>
<p>== Description ==
Retrieve supported and filtered Cron recurrences.
The supported recurrences are '&lt;tt&gt;hourly&lt;/tt&gt;', '&lt;tt&gt;twicedaily&lt;/tt&gt;', and '&lt;tt&gt;daily&lt;/tt&gt;'. A plugin may add more by hooking into the '&lt;tt&gt;cron_schedules&lt;/tt&gt;' filter. The filter accepts an array of arrays. The outer array has a key that is the name of the schedule or for example '&lt;tt&gt;weekly&lt;/tt&gt;'. The value is an array with two keys, one is '&lt;tt&gt;interval&lt;/tt&gt;' and the other is '&lt;tt&gt;display&lt;/tt&gt;'.
The '&lt;tt&gt;interval&lt;/tt&gt;' is a number in seconds of when the cron job should run. So for '&lt;tt&gt;hourly&lt;/tt&gt;', the time is &lt;tt&gt;3600&lt;/tt&gt; or &lt;tt&gt;60*60&lt;/tt&gt;. For weekly, the value would be &lt;tt&gt;60*60*24*7&lt;/tt&gt; or &lt;tt&gt;604800&lt;/tt&gt;. The value of '&lt;tt&gt;interval&lt;/tt&gt;' would then be &lt;tt&gt;604800&lt;/tt&gt;.
== Usage ==
%%%&lt;?php wp_get_schedules(); ?&gt;%%%
== Parameters ==
None.
== Return Values ==
Array
(
[hourly] =&gt; Array
(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment