wp-api

443
Template Tags/Anatomy of a Template Tag Contents 1 Introduction 2 PHP code tag 3 WordPress function 4 Optional parameters 5 Further reading Introduction This document provides a brief examination of the animal known as the WordPress template tag, to help those who may be new to WordPress and PHP understand what template tags are and how they're used. A WordPress template tag is made up of three components: A PHP code tag A WordPress function Optional parameters These are explained below. PHP code tag WordPress is built with the PHP scripting language. Though you certainly don't need to be a PHP developer to use it, knowing a little about the language can go a long way in getting the most out of WordPress. Here we provide a tiny bit of that PHP knowledge: <?php ?> The above shows the opening (<?php) and closing (?>) tag elements used to embed PHP functions and code in a HTML document, i.e. web page. There are a number of ways to embed PHP within a page, but this is the most "portable," in that it works on nearly every web server—as long as the server supports PHP (typically a document's filename also needs to end with the extension .php, so the server recognizes it as a PHP document). Anything within this tag is parsed and handled by the PHP interpreter, which runs on the web server (the interpreter is the PHP engine that figures out what the various functions and code do, and returns their output). For our purposes, the PHP tag lets you place WordPress functions in your page template, and through these generate the dynamic portions of your blog. WordPress function A WordPress or template function is a PHP function that performs an action or displays information specific to your blog. And like a PHP function, a WordPress function is defined by a line of text (of one or more words, no spaces), open and close brackets (parentheses), and typically a semi-colon, used to end a code statement in PHP. An example of a WordPress function is: the_ID(); the_ID() displays the ID number for a blog entry or post. To use it in a page template, you slip it into the PHP tag shown above: <?php the_ID(); ?> This is now officially a WordPress template tag, as it uses the PHP tag with a WordPress function. Optional parameters The final item making up a template tag is one you won't necessarily make use of unless you want to customize the tag's functionality. This, or rather these, are the parameters or arguments for a function. Here is the template function bloginfo(), with the show parameter being passed the 'name' value: <?php bloginfo('name'); ?> If your blog's name is Super Weblog, the bloginfo() template tag, when using 'name' as the show parameter value, will display that name where it's embedded in your page template. Not all template tags accept parameters (the_ID() is one), and those which do accept different ones based on their intended use, so that the_content() accepts parameters separate from those which get_calendar() can be passed. Further reading See the following Codex pages for more information on WordPress templates and template tags: Templates

Transcript of wp-api

Page 1: wp-api

Template Tags/Anatomy of a Template Tag

Contents1 Introduction2 PHP code tag3 WordPress function4 Optional parameters5 Further reading

Introduction

This document provides a brief examination of the animal known as the WordPress template tag, to help those who may be new to WordPressand PHP understand what template tags are and how they're used.

A WordPress template tag is made up of three components:

A PHP code tagA WordPress functionOptional parameters

These are explained below.

PHP code tag

WordPress is built with the PHP scripting language. Though you certainly don't need to be a PHP developer to use it, knowing a little about thelanguage can go a long way in getting the most out of WordPress. Here we provide a tiny bit of that PHP knowledge:

<?php ?>

The above shows the opening (<?php) and closing (?>) tag elements used to embed PHP functions and code in a HTML document, i.e. webpage. There are a number of ways to embed PHP within a page, but this is the most "portable," in that it works on nearly every web server—aslong as the server supports PHP (typically a document's filename also needs to end with the extension .php, so the server recognizes it as aPHP document).

Anything within this tag is parsed and handled by the PHP interpreter, which runs on the web server (the interpreter is the PHP engine thatfigures out what the various functions and code do, and returns their output). For our purposes, the PHP tag lets you place WordPressfunctions in your page template, and through these generate the dynamic portions of your blog.

WordPress function

A WordPress or template function is a PHP function that performs an action or displays information specific to your blog. And like a PHPfunction, a WordPress function is defined by a line of text (of one or more words, no spaces), open and close brackets (parentheses), andtypically a semi-colon, used to end a code statement in PHP. An example of a WordPress function is:

the_ID();

the_ID() displays the ID number for a blog entry or post. To use it in a page template, you slip it into the PHP tag shown above:

<?php the_ID(); ?>

This is now officially a WordPress template tag, as it uses the PHP tag with a WordPress function.

Optional parameters

The final item making up a template tag is one you won't necessarily make use of unless you want to customize the tag's functionality. This, orrather these, are the parameters or arguments for a function. Here is the template function bloginfo(), with the show parameter being passedthe 'name' value:

<?php bloginfo('name'); ?>

If your blog's name is Super Weblog, the bloginfo() template tag, when using 'name' as the show parameter value, will display that namewhere it's embedded in your page template.

Not all template tags accept parameters (the_ID() is one), and those which do accept different ones based on their intended use, so thatthe_content() accepts parameters separate from those which get_calendar() can be passed.

Further reading

See the following Codex pages for more information on WordPress templates and template tags:

Templates

Page 2: wp-api

How to Pass Tag Parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/Anatomy_of_a_Template_Tag"Categories: Template Tags | Design and Layout | Advanced Topics

Template Tags/How to Pass Tag Parameters

Contents1 Introduction2 Tags without parameters3 Tags with PHP function-style parameters4 Tags with query-string-style parameters5 Types of parameters

5.1 String5.2 Integer5.3 Boolean

Introduction

Template tags are PHP functions you can embed in your WordPress page templates to provide dynamic blog content. And like PHP functions,many template tags accept arguments, or parameters. Template tag parameters are variables you can use to change a tag's output orotherwise modify its action in some way. Think of parameters as user options or settings that allow you to customize how a template tag works.

In regards to parameters, WordPress template tags come in three "flavors." These are described below:

Tags without parameters1.Tags with PHP function-style parameters2.Tags with query-string-style parameters3.

Tags without parameters

Some template tags do not have any options, and thus have no parameters you can pass to them.

The template tag the_author_firstname() is one that accepts no parameters. This tag simply displays the first name of the author for a post.Tags without parameters should have nothing between the tag function's opening and closing brackets (parentheses):

<?php the_author_firstname(); ?>

Tags with PHP function-style parameters

For template tags that can accept parameters, some require them to be in the default PHP style. For these, parameters are passed to a tagfunction by placing one or more values inside the function's parentheses, or brackets.

The bloginfo() tag accepts one parameter (known as the show parameter) that tells it what information about your blog to display:

<?php bloginfo('name'); ?>

The wp_title() tag accepts two parameters: the first is the sep or separator parameter, and the second the echo or display parameter:

<?php wp_title(' - ', TRUE); ?>

The first is enclosed in single-quotes and the second is not because the first is a string, and the second a boolean parameter. (See Types ofparameters for information on parameter types and how to use them.)

Important points to keep in mind for PHP function-style parameters:

Some functions take multiple parameters.Multiple parameters are separated by commas.The order of parameters is important!

When passing parameters to a template tag's function, make sure you specify values for all parameters up to the last one you wish to modify,or the tag may not work as expected. For example, the template tag get_archives() has six parameters:

<?php get_archives('type', 'limit', 'format', 'before', 'after', show_post_count); ?>

To display the archives list the way you want, let's say you only need to modify the third (format) and fifth (after) parameters. To do this, youalso need to make sure to enter default values for the first, second and fourth parameters, as well:

Page 3: wp-api

<?php get_archives( , , 'custom', , '<br />'); ?>

Notice the use of single-quotes to denote empty parameter values, which in this case forces defaults for those specific parameters. Be awarethat defaults can be overwritten when passing empty parameters, as is the case of a parameter specifying a string of text, and there's no wayto pass an empty boolean value. So check the documentation for a parameter's default, and when one is specified use it as your parametervalue (also see Types of parameters for information on parameter types). The sixth parameter was left off; this is because WordPress uses thedefault for any remaining parameters left unspecified.

Make sure to follow the documentation for a template tag carefully, and place your parameters in the order the template function expects.Finally, to use the defaults for all parameters in a template tag, use the tag with no parameter values specified:

<?php get_archives(); ?>

Tags with query-string-style parameters

The last type of template tag makes use of what's called a query-string style to pass parameters to the tag. These provide a convenient'wrapper' to tags which use the PHP function parameter style and have a relatively large number of parameters. For example, the template tagwp_list_cats() is a wrapper to list_cats(), a tag with eighteen parameters!

If you want to set the exclude parameter in list_cats() (seventeenth in the parameter list) and leave the rest at their defaults, you have to dothis:

<?php list_cats(TRUE, 'All', 'ID', 'asc', '', TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, '', '', FALSE, '', '', '10,11,12'); ?>

Or you can use wp_list_cats():

<?php wp_list_cats('exclude=10,11,12'); ?>

So query-string style tags are useful in that they let you change the values of just those parameters you require, without needing to providevalues for all or nearly all of them. However, not all PHP function-style template tags have a query-string style equivalent. (Also note thatnames for tags that accept query-string style parameters usually start with a 'wp_' prefix, such as wp_list_cats(), but check the documentationon a tag to verify its method for accepting parameters, if any.)

The tag wp_list_authors() has six parameters, of which we set three here:

<?php wp_list_authors('show_fullname=1&feed=rss&optioncount=1'); ?>

First, all the parameters together are enclosed by either single or double quotes. Then each parameter is entered in the parameter=valueformat, while these are separated with an ampersand (&). Broken down, the tag as shown above states:

Parameter show_fullname (a boolean type parameter) equals 1 (true).ANDParameter feed (a string type parameter) equals rss.ANDParameter optioncount (a boolean type parameter) equals 1 (true).

(See Types of parameters for information on parameter types and how to use them.)

Parameters in the query-string style do not have to be entered in a specific order. The only real concern is assuring parameter names arespelled correctly. If legibility is a problem, you can separate parameters with a space:

<?php wp_list_authors('show_fullname=1 & feed=rss & optioncount=1'); ?>

You can also spread a query-string over several lines (note the specific format of enclosing each parameter/value pair in single quotes and adot starting each new line):

<?php wp_list_authors( 'show_fullname=1' .'&feed=rss' .'&optioncount=1' ); ?>

There are a few limitations when using query-string style tags, among which you cannot pass certain characters, such as the ampersand or aquote mark (single or double). In those cases, you can use an associative array:

<?php $params = array( 'type' => 'postbypost',

Page 4: wp-api

'limit' => 5, 'format' => 'custom', 'before' => '<li>&bull;&nbsp;', 'after' => '</li>' );wp_get_archives($params); ?>

Types of parameters

There are three types of parameters you need to know about in regards to WordPress template tags: string, integer, and boolean. Each ishandled a bit differently, as described below.

String

A string is a line of text, and is typically anything from a single character to several dozen words. A string parameter is often a selection fromtwo or more valid options, as is the show parameter in bloginfo(). Otherwise, a string is intended as text to be displayed, such as the sepparameter in wp_title().

In tags which use the PHP function parameter style, string values should be enclosed in single (') or double (") quotation marks. If a single ordouble quote is required for part of your string, mix the marks (using double quotes to enclose the parameter if a single quote exists in yourparameter value), or use the PHP escape character (a backslash: \), as the following does to assign single quotes for the before and afterparameters in the_title():

<?php the_title('\'', '\''); ?>

Integer

An integer is a whole number (…, -2, -1, 0, 1, 2,…). Integer parameters are often used for date and archive based information, like the yearand month parameters for the get_month_link() tag, or for specifying the numeric value of something on your blog, as one finds in the case ofthe id parameter in get_permalink().

When passed to a PHP function parameter style tag, integer values either in or out of quotes will be handled correctly. So the followingexamples are both valid:

<?php get_permalink('100'); ?>

<?php get_permalink(100); ?>

Boolean

Boolean parameters provide a simple true/false evaluation.

For example, the the_date() tag has an echo parameter which takes either TRUE or FALSE as a value; setting the parameter to TRUE displaysthe date on the page, whereas FALSE causes the tag to "return" the date as a value that can then be used in other PHP code.

A boolean parameter can be notated as a numeric value: 1 for TRUE, 0 for FALSE. For a boolean value in PHP function parameter style tags,these are all equivalent:

1 = TRUE = true0 = FALSE = false

However, do NOT enclose boolean values within quote marks. For query-string style tags, use only the numeric boolean values (1 or 0).

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/How_to_Pass_Tag_Parameters"Categories: Template Tags | Advanced Topics

Template Tags/bloginfo

Contents1 Description2 Usage3 Examples

3.1 Show Blog Title3.2 Show Character Set3.3 Show Blog Description

4 Parameters5 Related

Description

Page 5: wp-api

Displays information about your blog, mostly gathered from the information you supply in your User Profile and General Options from theWordPress Administration panels (Settings → General). It can be used anywhere within a page template. This always prints a result to thebrowser. If you need the values for use in PHP, use get_bloginfo().

Usage

<?php bloginfo('show'); ?>

ExamplesShow Blog Title

Displays your blog's title in a <h1> tag.

<h1><?php bloginfo('name'); ?></h1>

Show Character Set

Displays the character set your blog is using (ex: utf-8)

<p>Character set: <?php bloginfo('charset'); ?> </p>

Show Blog Description

Displays Tagline for your blog as set in the Administration panel under General Options.

<p><?php bloginfo('description'); ?> </p>

Parameters

See get_bloginfo()

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/bloginfo"Category: Template Tags

Template Tags/bloginfo rss

Contents1 Description2 Usage3 Example

3.1 Show Blog Title and Link4 Parameters5 Related

Description

Displays information about your blog, mostly gathered from the information you supply in Users > Your Profile and General Options from theWordPress Administration Panels. This function is identical to bloginfo() except it strips any markup from the output for use in WordPress'syndication feeds.

Usage

<?php bloginfo_rss('show'); ?>

ExampleShow Blog Title and Link

Displays blog name and url in title and link tags of RSS feed.

<title><?php bloginfo_rss('name'); ?></title>

Page 6: wp-api

<link><?php bloginfo_rss('url') ?></link>

Parameters

show (string) Informational detail about your blog. Valid values:

'name' - Weblog title; set in General Options. (Default)'description' - Tagline for your blog; set in General Options.'url' - URL for your blog's web site address.'rdf_url' - URL for RDF/RSS 1.0 feed.'rss_url' - URL for RSS 0.92 feed.'rss2_url' - URL for RSS 2.0 feed.'atom_url' - URL for Atom feed.'comments_rss2_url' - URL for comments RSS 2.0 feed.'pingback_url' - URL for Pingback (XML-RPC file).'admin_email' - Administrator's email address; set in General Options.'charset' - Character encoding for your blog; set in Reading Options.'version' - Version of WordPress your blog uses.

The following work in WordPress version 1.5 or after:'html_type' - "Content-type" for your blog.'wpurl' - URL for WordPress installation.'template_url' - URL for template in use.'template_directory' - URL for template's directory.'stylesheet_url' - URL for primary CSS file.'stylesheet_directory' - URL for stylesheet directory.

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/bloginfo_rss"Categories: Template Tags | Feeds

Template Tags/cancel comment reply link

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays a link which cancels the replying to a previous comment (a nested comment) and resets the comment form back to the default state.

Usage

<?php cancel_comment_reply_link('text'); ?>

Example

<?php cancel_comment_reply_link(); ?>

Parameters

text (string) Text to display as a link. Default is 'Click here to cancel reply.'

Related

Template_Tags/comment_reply_link

Page 7: wp-api

Migrating_Plugins_and_Themes_to_2.7/Enhanced_Comment_Display

Retrieved from "http://codex.wordpress.org/Template_Tags/cancel_comment_reply_link"

Template Tags/category description

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Using Category Slug3.3 With Category Title

4 Parameters5 Related

Description

Returns the description of a category.

Usage

<?php echo category_description($category); ?>

ExamplesDefault Usage

Displays the description of a category, given it's id, by echoing the return value of the tag. If no category given and used on a category page, itreturns the description of the current category.

<p><?php echo category_description(3); ?></p>

Result:

WordPress is a favorite blogging tool of mine and I share tips and tricks for using WordPress here.

Note: if there is no category description, the function returns a br tag

Using Category Slug

Displays the description of a category, using a category slug.

<?php echo category_description(get_category_by_slug('category-slug')->term_id); ?>

With Category Title

<p><strong><?php single_cat_title('Currently browsing'); ?></strong>: <?php echo category_description(); ?></p>

Result:

Currently browsing WordPress: WordPress is a favorite blogging tool of mine and I share tips and tricks for using WordPress here.

Parameters

category (integer) The numeric ID of the category for which the tag is to return the description. Defaults to the current category, if one is not set.

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/category_description"Category: Template Tags

Page 8: wp-api

Template Tags/category nicename

This page is marked as incomplete. You can help Codex by expanding it.

Description

Displays the category slug (or category nicename) a post belongs to. Must be used within The Loop. Outputs sanitized version of categoryname: single_cat_title.

Usage

<?php $getcategory = $wp_query->get_queried_object(); $getcategory->category_nicename; ?>

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/category_nicename"Categories: Stubs | Template Tags

Template Tags/comment ID

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Comment ID as Anchor ID

4 Parameters5 Related

Description

Displays the numeric ID of a comment. This tag must be within The Loop, or a comment loop.

Usage

<?php comment_ID(); ?>

ExamplesDefault Usage

<p>This is comment <?php comment_ID(); ?> for all comments.</p>

Comment ID as Anchor ID

Uses the comment ID as an anchor id for a comment.

<div id="comment-<?php comment_ID() ?>">Comment by <?php comment_author() ?>: </div><div class="comment-text"><?php comment_text() ?></div>

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,

Page 9: wp-api

comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_ID"Category: Template Tags

Template Tags/comment author

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the comment author name; that is, the one supplied by the commenter. If no name is provided (and "User must fill out name andemail" is not enabled under Discussion Options), WordPress will assign "Anonymous" as comment author. This tag must be within The Loop,or a comment loop.

Usage

<?php comment_author(); ?>

Example

<div>Comment by <?php comment_author(); ?>:</div>

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_author"Category: Template Tags

Template Tags/comment author IP

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the comment author's IP address. This tag must be within The Loop, or a comment loop.

Usage

<?php comment_author_IP(); ?>

Example

<p>Posted from: <?php comment_author_IP(); ?></p>

Page 10: wp-api

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_author_IP"Category: Template Tags

Template Tags/comment author email

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the comment author's email address, not linked. An email address must be provided if "User must fill out name and email" is enabledunder Discussion Options. This tag must be within The Loop, or a comment loop.

Usage

<?php comment_author_email(); ?>

Example

<a href="mailto:<?php comment_author_email(); ?>">contact <?php comment_author(); ?></a>

(Note: Displaying email addresses is not recommended, as email spammers could collect them from your site.)

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_author_email"Category: Template Tags

Template Tags/comment author email link

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Link Text and Styling

4 Parameters5 Related

Page 11: wp-api

Description

Displays the comment author's email address, as a mailto link. An email address must be provided if "User must fill out name and email" isenabled under Discussion Options. This tag must be within The Loop, or a comment loop.

Note: Displaying email addresses is not recommended, as it provides spam collection tools the opportunity to cull them from your site.

Usage

<?php comment_author_email_link('linktext', 'before', 'after'); ?>

ExamplesDefault Usage

email: <?php comment_author_email_link(); ?><br />

Link Text and Styling

Displays comment author's email link as text string Email Comment Author and adds arrows before and after the link to style it.

<?php comment_author_email_link('Email Comment Author', ' > ', ' < '); ?>

> Email Comment Author <

Parameters

linktext (string) Link text for the email link. Default is the comment author's email address.

before (string) Text to display before the link. There is no default.

after (string) Text to display after the link. There is no default.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_author_email_link"Category: Template Tags

Template Tags/comment author link

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the comment author's name linked to his/her URL, if one was provided. This tag must be within The Loop, or a comment loop.

Usage

<?php comment_author_link(); ?>

Example

<p>Comment by: <?php comment_author_link(); ?></p>

Page 12: wp-api

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_author_link"Category: Template Tags

Template Tags/comment author rss

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the comment author's name formatted for RSS. Typically used in the RSS comment feed template. This tag must be within The Loop,or a comment loop.

Usage

<?php comment_author_rss(); ?>

Example

<title>comment by: <?php comment_author_rss() ?></title>

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_author_rss"Categories: Template Tags | Feeds

Template Tags/comment author url

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the comment author's URL (usually their web site), not linked. This tag must be within The Loop, or a comment loop.

Page 13: wp-api

If the author provided no URL, this will display the URL of the current page instead. The tag get_comment_author_url returns an empty string inthis case.

Usage

<?php comment_author_url(); ?>

Example

Displays comment author's URL as a link, using comment author's name as part of the link text.

<a href="<?php comment_author_url(); ?>">Visit <?php comment_author(); ?>'s site</a>

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_author_url"Category: Template Tags

Template Tags/comment author url link

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Link Text and Styling

4 Parameters5 Related

Description

Displays the comment author's URL (usually their web site), linked, if one was provided. This tag must be within The Loop, or a comment loop.

Usage

<?php comment_author_url_link('linktext', 'before', 'after'); ?>

ExamplesDefault Usage

web site: <?php comment_author_url_link(); ?><br />

Link Text and Styling

Displays comment author's URL as text string Visit Site of Comment Author and adds bullets before and after the link to style it.

<?php comment_author_url_link('Visit Site of Comment Author', ' &bull; ', ' &bull; '); ?>

• Visit Site of Comment Author •

Parameters

linktext (string) Link text for the link. Default is the comment author's URL.

before (string) Text to display before the link. There is no default.

Page 14: wp-api

after (string) Text to display after the link. There is no default.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_author_url_link"Category: Template Tags

Template Tags/comment date

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the date a comment was posted. This tag must be within The Loop, or a comment loop.

Usage

<?php comment_date('d'); ?>

Example

Displays the comment date in the format "6-30-2004":

Comment posted on <?php comment_date('n-j-Y'); ?>

Parameters

d (string) Formatting for the date. Defaults to the date format set in WordPress. See Formatting Date and Time.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_date"Category: Template Tags

Template Tags/comment excerpt

Contents1 Description2 Usage3 Example

Page 15: wp-api

4 Parameters5 Related

Description

Displays an excerpt (maximum of 20 words) of a comment's text. This tag must be within The Loop, or a comment loop. This tag will workwithin a comment loop.

Usage

<?php comment_excerpt(); ?>

Example

<p>Latest comment: <?php comment_excerpt(); ?></p>

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_excerpt"Category: Template Tags

Template Tags/comment form title

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays text based on comment reply status. This only affects users with Javascript disabled or pages without the comment-reply.jsJavaScript loaded. This tag is normally used directly below <div id="respond"> and before the comment form.

Usage

<?php comment_form_title('noreplytext', 'replytext', 'linktoparent' ); ?>

Example

<h3><?php comment_form_title(); ?></h3>

<h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3>

Parameters

noreplytext (string) Optional. Text to display when not replying to a comment. Default is 'Leave a Reply'

replytext (string) Optional. Text to display when replying to a comment. Accepts "%s" for the author of the comment being replied to. Default is'Leave a Reply to %s'

linktoparent (boolean) Optional. Boolean to control making the author's name a link to their comment. Default is TRUE.

Related

Migrating_Plugins_and_Themes_to_2.7/Enhanced_Comment_Display

Page 16: wp-api

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_form_title"

Template Tags/comment link rss

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the URL to an entry's comments formatted for RSS. Typically used in the RSS comment feed template. This tag must be within TheLoop, or a comment loop.

Usage

<?php comment_link_rss(); ?>

Example

<link><?php comment_link_rss() ?></link>

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_link_rss"Categories: Template Tags | Feeds

Template Tags/comment reply linkDescription

Displays a link that lets users post a comment in reply to a specific comment. If JavaScript is enabled and the comment-reply.js JavaScriptis loaded the link moves the comment form to just below the comment.

Usage

<?php comment_reply_link(array_merge( $args, array('reply_text' => 'Reply', 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>

Related

cancel_comment_reply_linkMigrating_Plugins_and_Themes_to_2.7/Enhanced_Comment_Display

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_reply_link"

Template Tags/comment text

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Page 17: wp-api

Displays the text of a comment. This tag must be within The Loop, or a comment loop.

Usage

<?php comment_text(); ?>

Example

Displays the comment text with the comment author in a list (<li>) tag.

<li>Comment by <?php comment_author(); ?>:<br /> <?php comment_text(); ?></li>

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_text"Category: Template Tags

Template Tags/comment text rss

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the text of a comment formatted for RSS. Typically used in the RSS comment feed template. This tag must be within The Loop, or acomment loop.

Usage

<?php comment_text_rss(); ?>

Example

<description><?php comment_text_rss() ?></description>

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_text_rss"Categories: Template Tags | Feeds

Template Tags/comment time

Page 18: wp-api

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the time a comment was posted. This tag must be within The Loop, or a comment loop.

Usage

<?php comment_time('d'); ?>

Example

Dsiplays the comment time in the format "22:04:11".

<p>comment timestamp: <?php comment_time('H:i:s'); ?></p>

Parameters

d (string) Formatting for the time. Defaults to the time format set in WordPress. See Formatting Date and Time.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_time"Category: Template Tags

Template Tags/comment type

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the type of comment (regular comment, Trackback or Pingback) a comment entry is. This tag must be within The Loop, or a commentloop.

Usage

<?php comment_type('comment', 'trackback', 'pingback'); ?>

Example

<p><?php comment_type(); ?> to <?php the_title(); ?>: </p>

Parameters

comment (string) Text to describe a comment type comment. Defaults to 'Comment'.

trackback

Page 19: wp-api

(string) Text to describe a Trackback type comment. Defaults to 'Trackback'.pingback

(string) Text to describe a Pingback type comment. Defaults to 'Pingback'.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comment_type"Category: Template Tags

Template Tags/comments link

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the URL to a post's comments. This tag must be within The Loop, or the loop set up for comments.

Usage

<?php comments_link(); ?>

Example

<a href="<?php comments_link(); ?>"> Comments to this post</a>

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comments_link"Category: Template Tags

Template Tags/comments number

Contents1 Description2 Usage3 Examples

Page 20: wp-api

3.1 Text Response to Number of Comments4 Parameters5 Related

Description

Displays the total number of comments, Trackbacks, and Pingbacks for a post. This tag must be within The Loop.

Usage

<?php comments_number('zero', 'one', 'more'); ?>

ExamplesText Response to Number of Comments

Displays text based upon number of comments: Comment count zero - no reponses; comment count one - one response; more than onecomment (total 42) displays 42 responses.

<p>This post currently has <?php comments_number('no responses','one response','% responses'); ?>.</p>

Parameters

zero (string) Text to display when there are no comments. Defaults to 'No Comments'.

one (string) Text to display when there is one comment. Defaults to '1 Comment'.

more (string) Text to display when there is more than one comment. % is replaced by the number of comments, so '% so far' is displayedas "5 so far" when there are five comments. Defaults to '% Comments'.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comments_number"Category: Template Tags

Template Tags/comments popup link

Contents1 Description2 Usage3 Examples

3.1 Text Response for Number of Comments3.2 Hide Comment Link When Comments Are Deactivated

4 Parameters5 Related

Description

Displays a link to the comments popup window if comments_popup_script() is used, otherwise it displays a normal link to comments. This tagmust be within The Loop, or a comment loop, and it does nothing if is_single() or is_page() is true (even when within The Loop).

Usage

<?php comments_popup_link('zero','one','more','CSSclass','none');?>

Examples

Page 21: wp-api

Text Response for Number of Comments

Displays the comments popup link, using "No comments yet" for no comments, "1 comment so far" for one, "% comments so far (is that a lot?)"for more than one (% replaced by # of comments), and "Comments are off for this post" if commenting is disabled. Additionally,'comments-link' is a custom CSS class for the link.

<p><?php comments_popup_link('No comments yet', '1 comment so far', '% comments so far (is that a lot?)', 'comments-link', 'Comments are off for this post'); ?></p>

Hide Comment Link When Comments Are Deactivated

Hides the paragraph element <p></p> that contains the comments_popup_link when comments are deactivated in the Write>Post screen.Good for those who want enable/disable comments post by post. Must be used in the loop.

<?php if ( comments_open() ) : ?><p><?php comments_popup_link( 'No comments yet', '1 comment', '% comments so far', 'comments-link', 'Comments are off for this post'); ?></p><?php endif; ?>

Parameters

zero (string) Text to display when there are no comments. Defaults to 'No Comments'.

one (string) Text to display when there is one comment. Defaults to '1 Comment'.

more (string) Text to display when there are more than one comments. '%' is replaced by the number of comments, so '% so far' isdisplayed as "5 so far" when there are five comments. Defaults to '% Comments'.

CSSclass (string) CSS (stylesheet) class for the link. This has no default value.

none (string) Text to display when comments are disabled. Defaults to 'Comments Off'.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comments_popup_link"Category: Template Tags

Template Tags/comments popup script

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Outputs the JavaScript code for a comments popup window. Used in tandem with comments_popup_link(), this tag can be used anywherewithin a template, though is typically placed within the <head> portion of a page.

Usage

<?php comments_popup_script(width, height); ?>

Example

Page 22: wp-api

Sets the popup window's width to 400 pixels, and height to 500 pixels.

<?php comments_popup_script(400, 500); ?>

Parameters

width (integer) The width of the popup window. Defaults to 400 (pixels).

height(integer) The height of the popup window. Defaults to 400 (pixels).

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comments_popup_script"Category: Template Tags

Template Tags/comments rss link

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

This function has been deprecated, please use post_comments_feed_link().

Much like an RSS feed for your WordPress blog, this feature will display a link to the RSS feed for a given post's comments. By implementingthe feature, your readers will be able to track the comment thread for a given post, perhaps encouraging them to stay connected to theconversation.

This tag must be within The Loop, or the loop set up for comments.

Usage

<?php comments_rss_link('text', 'file'); ?>

Example

Displays the link to the comment's RSS feed, using "comment feed" as the link text.

<?php comments_rss_link('comment feed'); ?>

Parameters

'text' (string) Link text for the comments RSS link. Defaults to 'Comments RSS'.

'file' (string) The file the link points to. Defaults to 'wp-commentsrss2.php'.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Page 23: wp-api

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/comments_rss_link"Categories: Template Tags | Feeds

Template Tags/dropdown cats

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Examples

4.1 Dropdown with Submit Button4.2 Dropdown without Submit Button

5 Parameters6 Fixes7 Related

Description

Displays a list of categories in a select (i.e dropdown) box.

Replace With

wp_dropdown_categories().

Usage

<?php dropdown_cats(optionall, 'all', 'sort_column','sort_order', optiondates, optioncount, hide_empty, optionnone, selected, hide); ?>

ExamplesDropdown with Submit Button

Displays category select (dropdown) list in HTML form with a submit button, in a WordPress sidebar unordered list.

<li id="categories"><?php _e('Categories:'); ?> <ul><li> <form action="<?php echo $PHP_SELF ?>" method="get"> <?php dropdown_cats(); ?> <input type="submit" name="submit" value="view" /> </form> </li></ul></li>

Dropdown without Submit Button

Displays category select (dropdown) in HTML form without a submit button.

Download and install the plugin Drop Down Categories found here.Add the following code to your header.php template file:

<script type="text/JavaScript"><!-- function MM_jumpMenu(targ,selObj,restore){ //v3.0eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");if (restore) selObj.selectedIndex=0;}//--></script>

Then add the following code to wherever you'd like the dropdown categories to be displayed (for example, your sidebar.php file):

<form action="">

Page 24: wp-api

<select name="menu" onchange="MM_jumpMenu('parent',this,0)"><option>Choose one</option> <?php dropdown_cats_exclude('name', 'asc'); ?> </select></form>

Parameters

optionall (boolean) Sets whether to have an option to display all categories. Valid values:

TRUE (Default)FALSE

all (string) Text to display for the option to display all categories. Defaults to 'All'.

sort_column (string) Key to sort options by. Valid values:

'ID' (Default)'name'

sort_order (string) Sort order for options. Valid values:

'asc' (Default)'desc'

optiondates (boolean) Sets whether to display the date of the last post in each category. Valid values:

TRUEFALSE (Default)

optioncount (boolean) Sets whether to display a count of posts in each category. Valid values:

TRUEFALSE (Default)

hide_empty (boolean) Sets whether to hide (not display) categories with no posts. Valid values:

TRUE (Default)FALSE

optionnone (boolean) Sets whether to have an option to display none of the categories. Valid values:

TRUEFALSE (Default)

selected (integer) Sets the default selected category ID number. Defaults to current category.

hide (integer) Do not display this category (specified by category ID number). There is no default.

Fixes

When you choose a category when you are not on the main page, you will not move to that category. To fix this find the following line in thetemplate where you are using Dropdown cats. <form action="<?php echo $PHP_SELF ?>" method="get"> Replace it with : <formaction="<?bloginfo('url');?>/index.php" method="get">

This is a temporary fix to the problem, a real fix will probably come soon. This problem is usually only found on blogs using Apache Rewriterules.

(Added by Chenu J, minor edit by Derek Scruggs)

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Page 25: wp-api

Retrieved from "http://codex.wordpress.org/Template_Tags/dropdown_cats"Category: Template Tags

Template Tags/edit comment link

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Displays Edit Comment in Paragraph Tag

4 Parameters5 Related

Description

Displays a link to edit the current comment, if the user is logged in and allowed to edit the comment. It must be within The Loop, and within acomment loop.

Usage

<?php edit_comment_link('link', 'before', 'after'); ?>

ExamplesDefault Usage

Displays edit comment link using defaults.

<?php edit_comment_link(); ?>

Displays Edit Comment in Paragraph Tag

Displays edit comment link, with link text "edit comment", in a paragraph (<p>) tag.

<?php edit_comment_link('edit comment', '<p>', '</p>'); ?>

Parameters

link (string) The link text. Defaults to 'Edit This'.

before (string) Text to put before the link text. There is no default.

after (string) Text to put after the link text. There is no default.

Related

edit_post_link, edit_comment_link, link_pages, wp_link_pages, get_year_link, get_month_link, get_day_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/edit_comment_link"Category: Template Tags

Template Tags/edit post link

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Display Edit in Paragraph Tag

4 Parameters5 Related

Description

Page 26: wp-api

Displays a link to edit the current post, if a user is logged in and allowed to edit the post. It must be within The Loop.

Usage

<?php edit_post_link('link', 'before', 'after'); ?>

ExamplesDefault Usage

Displays edit post link using defaults.

<?php edit_post_link(); ?>

Display Edit in Paragraph Tag

Displays edit post link, with link text "edit", in a paragraph (<p>) tag.

<?php edit_post_link('edit', '<p>', '</p>'); ?>

Parameters

link (string) The link text. Defaults to 'Edit This'.

before (string) Text to put before the link text. There is no default.

after (string) Text to put after the link text. There is no default.

Related

edit_post_link, edit_comment_link, link_pages, wp_link_pages, get_year_link, get_month_link, get_day_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/edit_post_link"Category: Template Tags

Template Tags/get archives

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Examples

4.1 Default Usage4.2 By Month with Post Count4.3 Displays Last 10 Posts In A List4.4 Using Dropdown List4.5 List of Limited Number of Recent Posts

5 Parameters6 Related

Description

Displays a list of links to date-based archives. This tag can be used anywhere within a template. It is similar to wp_get_archives().

Replace With

wp_get_archives().

Usage

<?php get_archives('type', 'limit', 'format', 'before', 'after', show_post_count); ?>

Page 27: wp-api

ExamplesDefault Usage

Displays archive links using defaults.

<?php get_archives(); ?>

By Month with Post Count

Displays all archives by month in an unordered list, with count of posts by month.

<ul><?php get_archives('monthly', '', 'html', '', '', TRUE); ?></ul>

Displays Last 10 Posts In A List

Displays a non-bulleted list of the last 10 posts separated by line breaks.

<?php get_archives('postbypost', '10', 'custom', '', '<br />'); ?>

Using Dropdown List

Displays monthly archives in a dropdown list; the use of javascript is required to have an archive selection open on the page.

<form id="archiveform" action=""><select name="archive_chrono" onchange="window.location =(document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);"><option value=''>Select Month</option><?php get_archives('monthly','','option'); ?></select></form>

You also can use piece of code below, that works better than the example above. It shows the months list, including the number ofposts/month.

<select name="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;"> <option value="">Select month</option> <?php get_archives('monthly',,'option',,,'TRUE'); ?> </select>

List of Limited Number of Recent Posts

Displays a custom number of recent posts in an unordered list.

<ul><?php get_archives('postbypost','10','custom','<li>','</li>'); ?></ul>

Parameters

type (string) The type of archive list to display. Defaults to WordPress setting (defaults to 'monthly' in 1.5). Valid values:

'monthly' (Default)'daily''weekly''postbypost'

limit (integer) Number of archives to get. Use '' for no limit.

format (string) Format for the archive list. Valid values:

'html' - In HTML list (<li>) tags. This is the default.'option' - In select or dropdown option (<option>) tags.'link' - Within link (<link>) tags.'custom' - Custom list.

Page 28: wp-api

before (string) Text to place before the link when using 'custom' or 'html' for format option. Defaults to ''.

after (string) Text to place after the link when using 'custom' or 'html' for format option. Defaults to ''.

show_post_count (boolean) Display number of posts in an archive (TRUE) or do not (FALSE). For use when type is set to 'monthly'. Defaults to FALSE.

Related

To use the query string to pass parameters to generate an archive list, see wp_get_archives()

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_archives"Category: Template Tags

Template Tags/get bloginfo

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Blog Title3.3 Blog Tagline3.4 Template Directory3.5 Example output

4 Parameters5 Related

Description

The get_bloginfo() Template Tag returns information about your blog which can then be used elsewhere in your PHP code. This Template Tag,as well as bloginfo(), can also be used to display your blog information.

Usage

<?php get_bloginfo('show'); ?>

ExamplesDefault Usage

The default usage assigns your blog's title to the variable $blog_title.

<?php $blog_title = get_bloginfo(); ?>

Blog Title

This example assign your blog's title to the variable $blog_title. This returns the same result as the default usage.

<?php $blog_title = get_bloginfo('name'); ?>

Blog Tagline

Using this example:

<?php echo 'Your Blog Tagline is: ' . get_bloginfo ( 'description' ); ?>

results in this being displayed on your blog:

Your Blog Tagline is: All things WordPress

Template Directory

Page 29: wp-api

Returns template directory URL to the active theme. This this example the information is used to include a custom template calledsearchform.php'.

<?php include(get_bloginfo('template_directory') . '/searchform.php'); ?>

Example output

From version 2.7. On host example, the WordPress home page (Blog address) is shown at /home/, and the WordPress application(WordPress address) is installed at /home/wp/.

Note that directory URLs are missing trailing slashes.

admin_email = admin@exampleatom_url = http://example/home/feed/atomcharset = UTF-8comments_atom_url = http://example/home/comments/feed/atomcomments_rss2_url = http://example/home/comments/feeddescription = Just another WordPress bloghome = http://example/homehtml_type = text/htmllanguage = en-USname = Testpilotpingback_url = http://example/home/wp/xmlrpc.phprdf_url = http://example/home/feed/rdfrss2_url = http://example/home/feedrss_url = http://example/home/feed/rsssiteurl = http://example/homestylesheet_directory = http://example/home/wp-content/themes/largostylesheet_url = http://example/home/wp-content/themes/largo/style.csstemplate_directory = http://example/home/wp-content/themes/largotemplate_url = http://example/home/wp-content/themes/largotext_direction = ltrurl = http://example/homeversion = 2.7wpurl = http://example/home/wp

Parameters

show(string) Keyword naming the information you want. Optional; default: name. If you omit this parameter or pass any value besides thosebelow, the function returns the Weblog title. (Be careful of misspellings!)name

(default) returns the Weblog title set in Administration → Settings → General. This data is retrieved from the blogname record inthe wp_options table.

descriptionthe Tagline set in Administration → Settings → General. This data is retrieved from the blogdescription record in thewp_options table.

urlhome (deprecated)siteurl (deprecated)

the Blog address (URI) is the URL for your blog's web site address and is set in Administration → Settings → General. This datais retrieved from the home record in the wp_options table.

wpurlthe WordPress address (URI) is the URL for your WordPress installation and is set in Administration → Settings → General. Thisdata is retrieved from the siteurl record in the wp_options table.

rdf_urlURL for the blog's RDF/RSS 1.0 feed (/feed/rfd).

rss_urlURL for the blog's RSS 0.92 feed (/feed/rss).

rss2_urlURL for the blog's RSS 2.0 feed (/feed).

atom_urlURL for the blog's Atom feed (/feed/atom).

comments_rss2_urlURL for the blog's comments RSS 2.0 feed (/comments/feed).

pingback_urlURL for Pingback XML-RPC file (xmlrpc.php).

stylesheet_urlURL for primary CSS file (usually style.css) of the active theme.

Page 30: wp-api

stylesheet_directoryURL of the stylesheet directory of the active theme. (Was a local path in earlier WordPress versions.)

template_directorytemplate_url

URL of the active theme's directory. (template_directory was a local path before 2.6; see get_theme_root() andget_template() for hackish alternatives.)

admin_emailThe Administrator's E-mail address set in Administration → Settings → General. This data is retrieved from the admin_emailrecord in the wp_options table.

charsetThe Encoding for pages and feeds set in Administration → Settings → Reading. This data is retrieved from the blog_charsetrecord in the wp_options table.

versionVersion of WordPress your blog uses. This data is the value of $wp_version variable set in wp-includes/version.php.

html_typeContent-Type of WordPress HTML pages (default: text/html); stored in the html_type record in the wp_options table.Themes and plugins can override the default value by using the pre_option_html_type filter (see this section of the Codexfor more information on pre_option_ filters).

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_bloginfo"Category: Template Tags

Template Tags/get bloginfo rss

Contents1 Description2 Usage3 Example

3.1 RSS2 URL4 Parameters5 Related

Description

Returns information about your blog, which can then be used elsewhere in your PHP code. This function is identical to get_bloginfo() except itstrips any markup from the output for use in WordPress' syndication feeds.

To display this information, use bloginfo_rss().

Usage

<?php get_bloginfo_rss('show'); ?>

ExampleRSS2 URL

Assigns the URL of your blog's RSS2 feed to the variable $rss2_url.

<?php $rss2_url = get_bloginfo_rss('rss2_url'); ?>

Parameters

show (string) Informational detail about your blog. Valid values:

'name' - Weblog title; set in General Options. (Default)'description' - Tagline for your blog; set in General Options.'url' - URL for your blog's web site address.'rdf_url' - URL for RDF/RSS 1.0 feed.

Page 31: wp-api

'rss_url' - URL for RSS 0.92 feed.'rss2_url' - URL for RSS 2.0 feed.'atom_url' - URL for Atom feed.'comments_rss2_url' - URL for comments RSS 2.0 feed.'pingback_url' - URL for Pingback (XML-RPC file).'admin_email' - Administrator's email address; set in General Options.'charset' - Character encoding for your blog; set in Reading Options.'version' - Version of WordPress your blog uses.

The following work in WordPress version 1.5 or after:'html_type' - "Content-type" for your blog.'wpurl' - URL for WordPress installation.'template_url' - URL for template in use.'template_directory' - URL for template's directory.'stylesheet_url' - URL for primary CSS file.'stylesheet_directory' - URL for stylesheet directory.

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_bloginfo_rss"Category: Template Tags

Template Tags/get bookmarks

Contents1 Description2 Usage3 Examples

3.1 Default Usage4 Parameters5 Related

Description

This function will be found in WordPress v2.1, it is NOT supported by WordPress v2.0. get_bookmarks() returns an array of bookmarks found inthe Administration > Blogroll > Manage Blogroll panel. This Template Tag allows the user to retrieve the bookmark information directly.

Usage

<?php get_bookmarks('arguments'); ?>

ExamplesDefault Usage

'orderby' => 'name', 'order' => 'ASC','limit' => -1, 'category' => '','category_name' => '', 'hide_invisible' => 1,'show_updated' => 0, 'include' => '','exclude' => ''

By default, the usage gets:

All bookmarks ordered by name, ascendingBookmarks marked as hidden are not returned.The link_updated_f field (the update time in the form of a timestamp) is not returned.

Page 32: wp-api

Parameters

orderby (string) Value to sort bookmarks on. Defaults to 'name' unless you pass the value of '' (empty), in which case it sets to 'id'. Validoptions:

'id''url''name''target''description''owner' - User who added bookmark through bookmarks Manager.'rating''updated''rel' - bookmark relationship (XFN).'notes''rss''length' - The length of the bookmark name, shortest to longest.'rand' - Display bookmarks in random order.

order (string) Sort order, ascending or descending for the orderby parameter. Valid values:

ASC (Default)DESC

limit (integer) Maximum number of bookmarks to display. Defaults to -1 (all bookmarks).

category (string) Comma separated list of bookmark category ID's.

category_name (string) Category name of a catgeory of bookmarks to retrieve. Overrides category parameter.

hide_invisible (boolean) TRUE causes only bookmarks with link_visible set to 'Y' to be retrieved.

1 (True - default)0 (False)

show_updated (boolean) TRUE causes an extra column called "link_category_f" to be inserted into the results, which contains the same value as"link_updated", but in a unix timestamp format. Handy for using PHP date functions on this data.

1 (True)0 (False - default)

include (string) Comma separated list of numeric bookmark IDs to include in the output. For example, 'include=1,3,6' means to return or echobookmark IDs 1, 3, and 6. If the include string is used, the category, category_name, and exclude parameters are ignored. Defaults to(all Bookmarks).

exclude (string) Comma separated list of numeric bookmark IDs to exclude. For example, 'exclude=4,12' means that bookmark IDs 4 and 12 willNOT be returned or echoed. Defaults to (exclude nothing).

Related

wp_list_bookmarks, get_bookmarks, get_bookmark

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_bookmarks"Categories: Template Tags | New page created

Template Tags/get calendar

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Displays Weekday Abbrevations

Page 33: wp-api

4 Parameters5 Related

Description

Displays the calendar (defaults to current month/year). Days with posts are styled as such. This tag can be used anywhere within a template.

Usage

<?php get_calendar(); ?>

ExamplesDefault Usage

Displays calendar highlighting any dates with posts.

<?php get_calendar(); ?>

Displays Weekday Abbrevations

Display days using one-letter initial only; in 1.5, displays initial based on your WordPress Localization.

<?php get_calendar(true); ?>

Parameters

initial (boolean) If true, the day will be displayed using a one-letter initial; if false, an abbreviation based on your localization will be used. Forexample:

false causes "Sunday" to be displayed as "Sun"true (default) causes it to be "S"

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_calendar"Category: Template Tags

Template Tags/get category parents

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Returns a list of the parents of a category, including the category, sorted by ID.

Usage

<?php echo(get_category_parents(category, display link, separator, nice name)); ?>

Example

Returns the parent categories of the current category with links separated by '»'

<?php echo(get_category_parents($cat, TRUE, ' &raquo; ')); ?>

will output:

Page 34: wp-api

Internet » Blogging » WordPress »

Parameters

category (integer) The numeric category ID for which to return the parents. Defaults to current category, if one is set.

display link (boolean) Creates a link to each category displayed.

separator (string) What to separate each category by.

nice name (boolean) Return category nice name or not (defaults to FALSE).

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_category_parents"Category: Template Tags

Template Tags/get day link

Contents1 Description2 Usage3 Examples

3.1 Current Day as Link3.2 Use With Variables

4 Parameters5 Related

Description

Returns the daily archive URL to a specific year, month and day for use in PHP. It does NOT display the URL. If year, month and dayparameters are set to '', the tag returns the URL for the current day's archive.

Usage

<?php get_day_link('year', 'month', 'day'); ?>

ExamplesCurrent Day as Link

Returns the URL to the current day's archive as a link by displaying it within an anchor tag with the PHP echo command.

<a href="<?php echo get_day_link('', '', ''); ?>">Today's posts</a>

Use With Variables

PHP code block for use within The Loop: Assigns year, month and day of a post to the variables $arc_year, $arc_month and $arc_day. Theseare used with the get_day_link() tag, which returns the URL as a link to the daily archive for that post, displaying it within an anchor tag with thePHP echo command. See Formatting Date and Time for info on format strings used in get_the_time() tag.

<?php$arc_year = get_the_time('Y');$arc_month = get_the_time('m');$arc_day = get_the_time('d');?><a href="<?php echo get_day_link("$arc_year", "$arc_month", "$arc_day"); ?>">this day's posts</a>

Page 35: wp-api

Parameters

year (integer) The year for the archive. Use '' to assign current year.

month (integer) The month for archive. Use '' to assign current month.

day (integer) The day for archive. Use '' to assign current day.

Related

edit_post_link, edit_comment_link, link_pages, wp_link_pages, get_year_link, get_month_link, get_day_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_day_link"Category: Template Tags

Template Tags/get links

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Examples

4.1 Default Usage4.2 Specific Category Sorted by URL4.3 Shows Ratings and Timestamp

5 Parameters6 Related

Description

Like wp_get_links(), this tag displays links from the Links Manager, but allows the user to control how they are displayed by tag parameters,rather than through the WordPress admin interface (useful when displaying links on more than one template). This tag does ignore any linkwhere the Visible property is set to No.

Replace With

wp_list_bookmarks().

Usage

<?php get_links(category, 'before', 'after','between', show_images, 'order', show_description,show_rating, limit, show_updated, echo); ?>

ExamplesDefault Usage

By default, the usage shows:

All linksLine breaks after each link itemAn image if one is includedA space between the image and the textSorts the list by nameShows the description of the linkDoes not show the ratingsUnless limit is set, shows all linksDisplays links as links not text

Page 36: wp-api

<?php get_links(); ?>

Specific Category Sorted by URL

Displays links for link category ID 2 in span tags, uses images for links, does not show descriptions, sorts by link URL.

<?php get_links(2, '<span>', '</span>', '', TRUE, 'url', FALSE); ?>

Shows Ratings and Timestamp

Displays all links in an ordered list with descriptions on a new line, does not use images for links, sorts by link id, shows description, showrating, no limit to the number of links, shows last-updated timestamp, and echoes the results.

<ol><?php get_links('-1', '<li>', '</li>', '<br />', FALSE, 'id', TRUE, TRUE, -1, TRUE, TRUE); ?></ol>

Parameters

category (integer) The numeric ID of the link category whose links will be displayed. Display links in multiple categories by passing a stringcontaining comma-separated list of categories, e.g. "4,11,3". If none is specified, all links are shown. Defaults to -1 (all links).

before (string) Text to place before each link. There is no default.

after (string) Text to place after each link. Defaults to '<br />'.

between (string) Text to place between each link/image and its description. Defaults to ' ' (space).

show_images (boolean) Should images for links be shown (TRUE) or not (FALSE). Defaults to TRUE.

order (string) Value to sort links on. Defaults to 'name' unless you pass the value of '' (empty), in which case it sets to 'id'. Valid options:

'id''url''name''target''category''description''owner' - User who added link through Links Manager.'rating''updated''rel' - Link relationship (XFN).'notes''rss''length' - The length of the link name, shortest to longest.

Prefixing any of the above options with an underscore (ex: '_id') sorts links in reverse order.'rand' - Display links in random order.

show_description (boolean) Should the description be displayed (TRUE) or not (FALSE). Valid when show_images is FALSE, or an image is not defined.Defaults to TRUE.

show_rating (boolean) Should rating stars/characters be displayed (TRUE) or not (FALSE). Defaults to FALSE.

limit (integer) Maximum number of links to display. Defaults to -1 (all links).

show_updated (boolean) Should the last updated timestamp be displayed (TRUE) or not (FALSE). Defaults to FALSE.

echo (boolean) Display links (TRUE) or return them for use PHP (FALSE). Defaults to TRUE.

Related

get_links_list, wp_get_links, get_links, wp_get_linksbyname, get_linksbyname, wp_list_bookmarks, get_bookmarks, get_bookmark

How to pass parameters to tags with PHP function-style parameters

Page 37: wp-api

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_links"Category: Template Tags

Template Tags/get links list

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Example5 Parameters6 Related

Description

Displays a nested HTML unordered list of all links as defined in the Links Manager, sorted under Link Category headings. Note: the LinkCategory headings are automatically generated inside of <h2> headings.

Note: This tag does not respect the "Before Link", "Between Link and Description", and "After Link" settings defined for Link Categories in theLinks Manager, Formatting (but respect Category Options, Show, Description). To get around this feature/limitation, see Example 2 fromwp_get_links().

Replace With

wp_list_bookmarks().

Usage

<?php get_links_list('order'); ?>

Example

Display links sorted by Link Category ID.

<?php get_links_list('id'); ?>

Automatically generates the <li> with an ID of the Link Category wrapped in an <h2> heading. It looks like this (links edited for space):

<li id="linkcat-1"><h2>Blogroll</h2> <ul> <li><a href="http://example1.com/">Blogroll Link 1</a></li> <li><a href="http://example2.com/">Blogroll Link 2</a></li> <li><a href="http://example3.com/">Blogroll Link 3</a></li> </ul></li>

Parameters

order (string) Value to sort Link Categories by. Valid values:

'name' (Default)'id'

Prefixing the above options with an underscore (ex: '_id') sorts links in reverse order.

Related

get_links_list, wp_get_links, get_links, wp_get_linksbyname, get_linksbyname, wp_list_bookmarks, get_bookmarks, get_bookmark

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_links_list"

Page 38: wp-api

Category: Template Tags

Template Tags/get linksbyname

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Examples

4.1 Default Usage4.2 Specific Category Sorted by Name4.3 With Images and Ratings, No Descriptions4.4 As a Definition List with Images and Descriptions in Separate Tags

5 Parameters6 Related

Description

Like wp_get_linksbyname(), this tag displays links from the Links Manager, but allows the user to control how they are displayed by tagparameters, rather than through the WordPress admin interface (useful when displaying links on more than one template).

Replace With

wp_list_bookmarks().

Usage

<?php get_linksbyname('cat_name', 'before', 'after', 'between', show_images, 'orderby',show_description, show_rating, limit, show_updated); ?>

ExamplesDefault Usage

By default, the tag shows:

All categories if none are specifiedAll category links are shownPuts a line break after the link itemPuts a space between the image and link (if one is included)Shows link images if availableList sorted by IDShows the link descriptionDoes not show the ratingWith no limit listed, it shows all linksDoes not show the updated timestamp

<?php get_linksbyname(); ?>

Specific Category Sorted by Name

Displays links for link category "Friends" in an unordered list with descriptions on the next line, sorts by link name.

<ul><?php get_linksbyname('Friends', '<li>', '</li>', '<br />', FALSE, 'name', TRUE); ?></ul>

With Images and Ratings, No Descriptions

Displays all links one per line without descriptions, uses images for links, sorts by link name, and shows ratings.

<?php get_linksbyname('', '', '<br />', '', TRUE, 'name', FALSE, TRUE); ?>

Page 39: wp-api

As a Definition List with Images and Descriptions in Separate Tags

Displays all links in a Definition List, places linked images in the <dt>, descriptions in the <dd>, and sorts by rating but doesn't show it.

<dl> <?php get_linksbyname('Portfolio', '<dt>', '</dd>','</dt><dd>', TRUE, 'rating', TRUE, FALSE, -1, FALSE); ?> </dl>

To see examples of styling this markup in a fluid/elastic, multi-column layout with backgrounds and hover effects, please see ManipulatingDefinition Lists for Fun and Profit.

Parameters

cat_name (string) The name of the link category whose links will be displayed. If none is specified, all links are shown. Defaults to 'noname' (alllinks).

before (string) Text to place before each link. There is no default.

after (string) Text to place after each link. Defaults to '<br />'.

between (string) Text to place between each link/image and its description. Defaults to ' ' (space).

show_images (boolean) Should images for links be shown (TRUE) or not (FALSE). Defaults to TRUE.

orderby (string) Value to sort links on. Defaults to 'id'. Valid options:

'id''url''name''target''category''description''owner' - User who added link through Links Manager.'rating''updated''rel' - Link relationship (XFN).'notes''rss''length' - The length of the link name, shortest to longest.

Prefixing any of the above options with an underscore (ex: '_id') sorts links in reverse order.'rand' - Display links in random order.

show_description (boolean) Display the description (TRUE) or not (FALSE). Valid if show_images is FALSE or an image is not defined. Defaults to TRUE.

show_rating (boolean) Should rating stars/characters be displayed (TRUE) or not (FALSE). Defaults to FALSE.

limit (integer) Maximum number of links to display. Defaults to -1 (all links).

show_updated (boolean) Should the last updated timestamp be displayed (TRUE) or not (FALSE). Defaults to FALSE.

Related

get_links_list, wp_get_links, get_links, wp_get_linksbyname, get_linksbyname, wp_list_bookmarks, get_bookmarks, get_bookmark

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_linksbyname"Category: Template Tags

Template Tags/get month link

Contents

Page 40: wp-api

1 Description2 Usage3 Examples

3.1 Month Archive as Link3.2 Assigning Specific Month to Variable3.3 Use With PHP Variables

4 Parameters5 Related

Description

Returns the monthly archive URL to a specific year and month for use in PHP. It does NOT display the URL. If year and month parameters areset to '', the tag returns the URL for the current month's archive.

Usage

<?php get_month_link('year', 'month'); ?>

ExamplesMonth Archive as Link

Returns the URL to the current month's archive as a link by displaying it within an anchor tag with the PHP echo command.

<a href="<?php echo get_month_link('', ''); ?>">All posts this month</a>

Assigning Specific Month to Variable

Returns URL to the archive for October 2004, assigning it to the variable $oct_04. The variable can then be used elsewhere in a page.

<?php $oct_04 = get_month_link('2004', '10'); ?>

Use With PHP Variables

PHP code block for use within The Loop: Assigns year and month of a post to the variables $arc_year and $arc_month. These are used withthe get_month_link() tag, which returns the URL as a link to the monthly archive for that post, displaying it within an anchor tag with the PHPecho command. See Formatting Date and Time for info on format strings used in get_the_time() tag.

<?php$arc_year = get_the_time('Y');$arc_month = get_the_time('m');?><a href="<?php echo get_month_link("$arc_year", "$arc_month"); ?>">archivefor <?php the_time('F Y') ?></a>

Parameters

year (integer) The year for the archive. Use '' to assign current year.

month (integer) The month for archive. Use '' to assign current month.

Related

edit_post_link, edit_comment_link, link_pages, wp_link_pages, get_year_link, get_month_link, get_day_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_month_link"Category: Template Tags

Template Tags/get permalink

Contents1 Description2 Usage3 Examples

3.1 Default Usage

Page 41: wp-api

3.2 Link to Specific Post4 Parameters5 Related

Description

Returns the permalink to a post for use in PHP. It does NOT display the permalink and can be used outside of The Loop.

Usage

<?php get_permalink(id); ?>

ExamplesDefault Usage

The permalink for current post (used within The Loop). As the tag does not display the permalink, the example uses the PHP echo command.

Permalink for this post:<br /><?php echo get_permalink(); ?>

Link to Specific Post

Returns the permalinks of two specific posts (post IDs 1 and 10) as hypertext links within an informational list. As above, tag uses the PHPecho command to display the permalink.

<ul><li>MyBlog info: <ul> <li><a href="<?php echo get_permalink(1); ?>">About MyBlog</a></li> <li><a href="<?php echo get_permalink(10); ?>">About the owner</a></li> </ul></li></ul>

Parameters

id (integer) The numeric ID for a post. When this tag is used in The Loop without an id parameter value, tag defaults to the current post ID.

Related

permalink_anchor, get_permalink, the_permalink, permalink_single_rss

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_permalink"Category: Template Tags

Template Tags/get posts

Contents1 Description2 Usage3 Examples

3.1 Posts list with offset3.2 Access all post data3.3 Latest posts ordered by title3.4 Random posts3.5 Show all attachments3.6 Show attachments for the current post

4 Parameters: WordPress 2.6+5 Parameters: WordPress 2.5 And Older6 Related

Description

This is a simple tag for creating multiple loops.

Page 42: wp-api

Usage

<?php get_posts('arguments'); ?>

ExamplesPosts list with offset

If you have your blog configured to show just one post on the front page, but also want to list links to the previous five posts in category ID 1,you can use this:

<ul> <?php global $post; $myposts = get_posts('numberposts=5&offset=1&category=1'); foreach($myposts as $post) : ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul>

Note: With use of the offset, the above query should be used only on a category that has more than one post in it, otherwise there'll be nooutput.

Access all post data

Some post-related data is not available to get_posts by default, such as post content through the_content(), or the numeric ID. This is resolvedby calling an internal function setup_postdata(), with the $post array as its argument:

<?php $lastposts = get_posts('numberposts=3'); foreach($lastposts as $post) : setup_postdata($post); ?> <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2> <?php the_content(); ?> <?php endforeach; ?>

To access a post's ID or content without calling setup_postdata(), or in fact any post-specific data (data retained in the posts table), you canuse $post->COLUMN, where COLUMN is the table column name for the data. So $post->ID holds the ID, $post->post_content thecontent, and so on. To display or print this data on your page use the PHP echo command, like so:

<?php echo $post->ID; ?>

Latest posts ordered by title

To show the last ten posts sorted alphabetically in ascending order, the following will display their post date, title and excerpt:

<?php $postslist = get_posts('numberposts=10&order=ASC&orderby=title'); foreach ($postslist as $post) : setup_postdata($post); ?> <div> <?php the_date(); ?> <br /> <?php the_title(); ?> <?php the_excerpt(); ?> </div> <?php endforeach; ?>

Note: The orderby parameter was modified in Version 2.6. This code is using the new orderby format. See Parameters for details.

Random posts

Display a list of 5 posts selected randomly by using the MySQL RAND() function for the orderby parameter value:

<ul><li><h2>A random selection of my writing</h2> <ul>

Page 43: wp-api

<?php $rand_posts = get_posts('numberposts=5&orderby=rand'); foreach( $rand_posts as $post ) : ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> </li></ul>

Show all attachments

Do this outside any Loops in your template.

(Since Version 2.5, it may be easier to use get_children() instead.)

<?php

$args = array('post_type' => 'attachment','numberposts' => -1,'post_status' => null,'post_parent' => null, // any parent);

$attachments = get_posts($args);if ($attachments) {

foreach ($attachments as $post) {setup_postdata($post);the_title();the_attachment_link($post->ID, false);the_excerpt();

}}

?>

Show attachments for the current post

Do this inside The_Loop (where $post->ID is available).

<?php

$args = array('post_type' => 'attachment','numberposts' => -1,'post_status' => null,'post_parent' => $post->ID);

$attachments = get_posts($args);if ($attachments) {

foreach ($attachments as $attachment) {echo apply_filters('the_title', $attachment->post_title);the_attachment_link($attachment->ID, false);

}}

?>

Parameters: WordPress 2.6+

In addition to the parameters listed below under "WordPress 2.5 And Older", get_posts() can also take the parameters thatquery_posts() can since both functions now use the same database query code internally.

Note: Version 2.6 changed a number of the orderby options. Table fields that begin with post_ no longer have that part of the name. Forexample, post_title is now title and post_date is now date.

Parameters: WordPress 2.5 And Older

$numberposts(integer) (optional) Number of posts to return. Set to 0 to use the max number of posts per page. Set to -1 to remove the limit.

Default: 5

Page 44: wp-api

$offset(integer) (optional) Offset from latest post.

Default: 0

$category(integer) (optional) Only show posts from this category ID. Making the category ID negative (-3 rather than 3) will show results notmatching that category ID. Multiple category IDs can be specified by separating the category IDs with commas or by passing an arrayof IDs.

Default: None

$category_name(string) (optional) Only show posts from this category name or category slug.

Default: None

$tag(string) (optional) Only show posts with this tag slug. If you specify multiple tag slugs separated by commas, all results matching anytag will be returned. If you specify multiple tag slugs separated by spaces, the results will match all the specified tag slugs.

Default: None

$orderby(string) (optional) Sort posts by one of various values (separated by space), including:

'author' - Sort by the numeric author IDs.'category' - Sort by the numeric category IDs.'content' - Sort by content.'date' - Sort by creation date.'ID' - Sort by numeric post ID.'menu_order' - Sort by the menu order. Only useful with pages.'mime_type' - Sort by MIME type. Only useful with attachments.'modified' - Sort by last modified date.'name' - Sort by stub.'parent' - Sort by parent ID.'password' - Sort by password.'rand' - Randomly sort results.'status' - Sort by status.'title' - Sort by title.'type' - Sort by type.

Notes:

Sorting by ID and rand is only available starting with Version 2.5.

Default: post_date

$order(string) (optional) How to sort $orderby. Valid values:

'ASC' - Ascending (lowest to highest).'DESC' - Descending (highest to lowest).Default: DESC

$include(string) (optional) The IDs of the posts you want to show, separated by commas and/or spaces. The following value would work inshowing these six posts:

'45,63, 78 94 ,128 , 140'Note: Using this parameter will override the numberposts, offset, category, exclude, meta_key, meta_value, and post_parentparameters.

Default: None

$exclude(string) (optional) The IDs of any posts you want to exclude, separated by commas and/or spaces (see $include parameter).

Default: None

$meta_key and $meta_value(string) (optional) Only show posts that contain a meta (custom) field with this key and value. Both parameters must be defined, orneither will work.

Default: None

$post_type(string) (optional) The type of post to show. Available options are:

post - Default

Page 45: wp-api

pageattachmentany - all post typesDefault: post

$post_status(string) (optional) Show posts with a particular status. Available options are:

publish - Defaultprivatedraftfutureinherit - Default if $post_type is set to attachment(blank) - all statusesDefault: publish

$post_parent(integer) (optional) Show only the children of the post with this ID

Default: None

$nopaging(boolean) (optional) Enable or disable paging. If paging is disabled, the $numberposts option is ignored.

Default: None

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_posts"Category: Template Tags

Template Tags/get the category

Contents1 Description2 Usage3 Examples

3.1 Show Category Images3.2 Show the First Category Name Only

4 Member Variables5 Related

Description

Returns an array of objects, one object for each category assigned to the post. This tag must be used within The Loop.

Usage

This function does not display anything; you should access the objects and then echo or otherwise use the desired member variables.

The following example displays the category name of each category assigned to the post (this is like using the_category(), but withoutlinking each category to the category view, and using spaces instead of commas):

<?phpforeach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?>

ExamplesShow Category Images

This outputs category images named after the cat_ID with the alt attribute set to cat_name. You can also use any of the other membervariables instead.

Page 46: wp-api

<?php foreach((get_the_category()) as $category) { echo '<img src="http://example.com/images/' . $category->cat_ID . '.jpg" alt="' . $category->cat_name . '" />'; } ?>

Show the First Category Name Only

<?php$category = get_the_category(); echo $category[0]->cat_name;?>

(Echoes the first array ([0]) of $category.)

Member Variables

cat_ID the category id (also stored as 'term_id')

cat_name the category name (also stored as 'name')

category_nicename a slug generated from the category name (also stored as 'slug')

category_description the category description (also stored as 'description')

category_parent the category id of the current category's parent. '0' for no parents. (also stored as 'parent')

category_count the number of uses of this category (also stored as 'count')

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_the_category"Category: Template Tags

Template Tags/get the tag list

Contents1 Description2 Usage3 Example

3.1 A Basic Example3.2 A Slightly More Complex Example

4 Parameters5 Related

Description

Generates a HTML string of the tags associated with the current post. The name of each tag will be linked to the relevant 'tag' page. You cantell the function to put a string before and after all the tags, and in between each tag. This tag must be used inside 'The Loop'.

Usage

<?php $tag_list = get_the_tag_list( $before = 'before', $sep = 'seperator', $after = 'after' ) ?>

This function does not display anything - if you want to put it straight onto the page, you should use echo (get_the_tag_list()).Alternatively, you can assign it to a variable for further use by using $foo = get_the_tag_list().

The variables are all optional, and should be placed in the order 'before', 'separator', 'after'. You can use HTML inside each of the fields.

Example

Page 47: wp-api

A Basic Example

This outputs the list of tags inside a paragraph, with tags separated by commas.

<?phpecho get_the_tag_list('<p>Tags: ',', ','</p>');?>

This would return something like.

<p>Tags: <a href="tag1">Tag 1</a>, <a href="tag2">Tag 2</a>, ... </p>

A Slightly More Complex Example

This checks if the post has any tags, and if there are, outputs them to a standard unordered list.

<?phpif(get_the_tag_list()) { get_the_tag_list('<ul><li>','</li><li>','</li></ul>');}?>

This will return something in the form:

<ul><li><a href="tag1">Tag 1</a></li><li><a href="tag2">Tag 2</a></li> ... </ul>

You can add classes and styles with CSS, as necessary.

Parameters

$before(string) (optional) Leading text

Default: 'Tags: '

$sep(string) (optional) String to sepearte tags

Default: ', '

$after(string) (optional) Trailing text

Default: none

Related

the_tags, get_the_tags, get_the_tag_list, single_tag_title, get_tag_link, wp_tag_cloud, wp_generate_tag_cloud

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Template_Tags/get_the_tag_list"Categories: Template Tags | New page created | Stubs

Template Tags/get the tags

Page 48: wp-api

Contents1 Description2 Usage3 Examples

3.1 Show tag Images3.2 Show the First tag Name Only3.3 Display code bases on different tag values

4 Member Variables5 Related

Description

Returns an array of objects, one object for each tag assigned to the post. This tag must be used within The Loop.

Usage

This function does not display anything; you should access the objects and then echo or otherwise use the desired member variables.

The following example displays the tag name of each tag assigned to the post (this is like using the_tags(), but without linking each tag tothe tag view, and using spaces instead of commas):

<?php$posttags = get_the_tags();if ($posttags) {foreach($posttags as $tag) {echo $tag->name . ' '; }}?>

ExamplesShow tag Images

This outputs tag images named after the term_id with the alt attribute set to name. You can also use any of the other member variablesinstead.

<?php$posttags = get_the_tags();if ($posttags) {foreach($posttags as $tag) {echo '<img src="http://example.com/images/' . $tag->term_id . '.jpg" alt="' . $tag->name . '" />'; }}?>

Show the First tag Name Only

<?php$posttags = get_the_tags();$count=0;if ($posttags) {foreach($posttags as $tag) {$count++;if (1 == $count) {echo $tag->name . ' ';}}}?>

Display code bases on different tag values

This code will display HTML code depending on if this post has a certain tag or tag(s). Just add as many else if statements as you require.

<?php if ($all_the_tags);$all_the_tags = get_the_tags();foreach($all_the_tags as $this_tag) {

Page 49: wp-api

if ($this_tag->name == "sometag" ) {?>

<p>SOME HTML CODE <img src="someimage.jpg"></p>

<?php } else if ($this_tag->name == "someothertag" ) { ?>

<p>SOME OTHER HTML CODE <img src="someotherimage.jpg"></p>

<?php } else {// it's neither, do nothing

?><!-- not tagged as one or the other -->

<?}

}}?>

Member Variables

term_id the tag id

name the tag name

slug a slug generated from the tag name

term_group the group of the tag, if any

taxonomy should always be 'post_tag' for this case

description the tag description

count number of uses of this tag, total

Related

the_tags, get_the_tags, get_the_tag_list, single_tag_title, get_tag_link, wp_tag_cloud, wp_generate_tag_cloud

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_the_tags"Category: Template Tags

Template Tags/get the time

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Assigns Time in Seconds

4 Parameters5 Related

Description

Returns the time of the current post for use in PHP. It does not display the time. This tag must be used within The Loop.

This tag is available beginning with version 1.5 of WordPress. To display the time of a post, use the_time().

Usage

<?php get_the_time('format'); ?>

Page 50: wp-api

ExamplesDefault Usage

Returns the time of the current post using the WordPress default format, and displays it using the PHP echo command.

<?php echo get_the_time(); ?>

Assigns Time in Seconds

Assigns the time of the current post in seconds (since January 1 1970, known as the Unix Epoch) to the variable $u_time.

<?php $u_time = get_the_time('U'); ?>

Parameters

format (string) The format the time is to display in. Defaults to the time format configured in your WordPress options. See Formatting Date andTime.

Related

See also the_time().

the_date_xml, the_date, the_time, the_modified_date, the_modified_time, get_the_time, single_month_title, get_calendar, the_weekday,the_weekday_date

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_the_time"Category: Template Tags

Template Tags/get year link

Contents1 Description2 Usage3 Examples

3.1 Year as Link3.2 Year as a variable3.3 Using With PHP Variables

4 Parameters5 Related

Description

Returns the yearly archive URL to a specific year for use in PHP. It does NOT display the URL. If year is set to '', the tag returns the URL forthe current year's archive.

Usage

<?php get_year_link('year'); ?>

ExamplesYear as Link

Returns the URL for the current year's archive, displaying it as a link in the anchor tag by using the PHP echo command.

<a href="<?php echo get_year_link(''); ?>">Posts from this year</a>

Year as a variable

Returns URL for the archive year 2003, assigning it to the variable $year03. The variable can then be used elsewhere in a page.

<?php $year03 = get_year_link(2003); ?>

Page 51: wp-api

Using With PHP Variables

PHP code block for use within The Loop: Assigns year to the variable $arc_year. This is used with the get_year_link() tag, which returns theURL as a link to the yearly archive for a post, displaying it within an anchor tag with the PHP echo command. See Formatting Date and Timefor info on format strings used in get_the_time() tag.

<?php$arc_year = get_the_time('Y');?><a href="<?php echo get_year_link($arc_year); ?>"><?php the_time('Y') ?> archive</a>

Parameters

year (integer) The year for the archive. Use '' to assign current year.

Related

edit_post_link, edit_comment_link, link_pages, wp_link_pages, get_year_link, get_month_link, get_day_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_year_link"Category: Template Tags

Template Tags/in category

Contents1 Description2 Usage3 Examples

3.1 Display Some Category Specific Text3.2 Use OUTSIDE The Loop

3.2.1 Parameters3.3 Plugin Options3.4 Related

DescriptionReturns true if the current post is in the specified Category. Normally this tag is used within The Loop, but the $post variable must be set whenusing this tag outside of the loop.

UsageSuppose you want to execute some specific PHP or HTML only if the current post being processed is in a category with a category ID numberwe'll represent here as 'category_id'.

<?php if ( in_category('category_id') ): ?> // Some category specific PHP/HTML here<?php endif; ?>

ExamplesDisplay Some Category Specific Text

Display <span class="good-cat-5">This is a nice category</span> in each post which is a member of category 5, otherwisedisplay <span class="bad-cat">This is a BAD category</span>.

<?php if ( in_category(5) ) {echo '<span class="my-cat-5">This is a nice category</span>';} else {echo '<span class="bad-cat">This is a BAD category</span>';}?>

Unfortunately, in_category doesn't understand category child-parent relationships. If, for example, category 11 (bananas) is a child of category2 (fruits), in_category('2') will return FALSE when viewing post about bananas. So if you want the same text to be applied to the category ANDall its sub-categories, you'll have to list them all. Syntax like in_category(2,11) is not allowed. You'll have to use PHP || (logical OR) && (logical

Page 52: wp-api

AND) in the expression.

<?php if ( in_category(2) || in_category (11) || in_category (12)[more categories abouth other fruits - this can get messy] ) {echo '<span class="fruits">This is about different kinds of fruits</span>';} else {echo '<span class="bad-cat">Not tasty! Not healthy!</span>';}?>

Another way to check in child categories is to loop through the children.

<?php$in_subcategory = false;foreach( (array) get_term_children( 11, 'category' ) as $child_category ) {if(in_category($child_category))$in_subcategory = true;}

if ( $in_subcategory || in_category( 11 ) ) {echo '<span class="fruits">This is about different kinds of fruits</span>';} else {echo '<span class="bad-cat">Not tasty! Not healthy!</span>';}?>

Use OUTSIDE The Loop

Normally, this tag must be used inside The Loop because it depends on a WordPress PHP variable ($post) that is assigned a value only whenThe Loop runs. However, you can manually assign this variable and then use the tag just fine.

For example, suppose you want a single.php Template File in your Theme that will display a completely different page depending on whatcategory the individual post is in. Calling in_category() from within The Loop may not be convenient for your Template. So use the followingas your Theme's single.php.

<?php if ( have_posts() ) { the_post(); rewind_posts(); } if ( in_category(17) ) { include(TEMPLATEPATH . '/single2.php'); } else { include(TEMPLATEPATH . '/single1.php'); } ?>

This will use single2.php as the Template if the post is in category 17 and single1.php otherwise. This essentially pulls the first post intothe correct variables, then resets the main WordPress query to start from there again when the main Loop does run.

Parameters

category_id (integer) The category ID of the category for which you wish to test. The parameter may either be passed as a bare integer or as astring:

in_category(5)in_category('5')

Plugin Options

Eventually, someone will make a clever plugin that will do all of this automatically. At that point this example will become obsolete. However, theCustom Post Templates Plugin allows for creation of templates for single posts. It also shows an example of how to add a template which isused for all posts in a given category, not just a single post. That example is commented out in the plugin by default but can be easilyimplemented by uncommenting the appropriate lines.

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Page 53: wp-api

Retrieved from "http://codex.wordpress.org/Template_Tags/in_category"Category: Template Tags

Template Tags/link pages

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Examples

4.1 Default Usage4.2 Page-links in Paragraph Tags

5 Parameters6 Related

Description

Displays page-links for paginated posts (i.e. includes the <!--nextpage--> Quicktag one or more times). This tag works similarly towp_link_pages(). This tag must be within The_Loop.

Replace With

wp_link_pages().

Usage

<?php link_pages('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file'); ?>

ExamplesDefault Usage

Displays page-links by default with line breaks before and after, using next page and previous page, listing them with page numbers as Page 1,Page 2 and so on.

<?php link_pages(); ?>

Page-links in Paragraph Tags

Displays page-links wrapped in paragraph tags.

<?php link_pages('<p>', '</p>', 'number', '', '', 'page %'); ?>

Parameters

before (string) Text to put before all the links. Defaults to '<br />'.

after (string) Text to put after all the links. Defaults to '<br />'.

next_or_number (string) Indicates whether page numbers should be used. Valid values are:

'number' (Default)'next' (Valid in WordPress 1.5 or after)

nextpagelink (string) Text for link to next page. Defaults to 'next page'. (Valid in WordPress 1.5 or after)

previouspagelink(string) Text for link to previous page. Defaults to 'previous page'. (Valid in WordPress 1.5 or after)

pagelink (string) Format string for page numbers. '%' in the string will be replaced with the number, so 'Page %' would generate "Page 1","Page 2", etc. Defaults to '%'.

more_file (string) Page the links should point to. Defaults to the current page.

Related

Page 54: wp-api

To use the query string to pass parameters, see wp_link_pages()

edit_post_link, edit_comment_link, link_pages, wp_link_pages, get_year_link, get_month_link, get_day_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/link_pages"Category: Template Tags

Template Tags/list authors

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Examples

4.1 Default Usage4.2 Authors with Number of Posts4.3 Full Name and Authors With No Posts Usage

5 Parameters6 Related

Description

Displays a list of the authors on a blog, and if desired, other information such as a link to each author's RSS feed.

Replace With

wp_list_authors().

Usage

<?php list_authors(optioncount, exclude_admin, show_fullname, hide_empty, 'feed', 'feed_image'); ?>

ExamplesDefault Usage

Display the list of authors using default settings.

<?php list_authors(); ?>

Authors with Number of Posts

This example causes the site's authors to display with the number of posts written by each author, excludes the admin author, and displayseach author's full name (first and last name).

<?php list_authors(TRUE, TRUE, TRUE); ?>

Harriett Smith (42)

Sally Smith (29)

Andrew Anderson (48)

Full Name and Authors With No Posts Usage

Displays the site's authors without displaying the number of posts, does not exclude the admin, shows the full name of the authors, and doesnot hide authors with no posts. It does not display the RSS feed or image.

Page 55: wp-api

<?php list_authors(FALSE, FALSE, TRUE, FALSE); ?>

Parameters

optioncount (boolean) Display number of posts by each author. Options are:

TRUEFALSE (Default)

exclude_admin (boolean) Exclude the administrator account from authors list. Options are:

TRUE (Default)FALSE

show_fullname (boolean) Display the full (first and last) name of the authors. Options are:

TRUEFALSE (Default)

hide_empty (boolean) Do not display authors with 0 posts. Options are:

TRUE (Default)FALSE

feed (string) Text to display for a link to each author's RSS feed. Default is no text, and no feed displayed.

feed_image (string) Path/filename for a graphic. This acts as a link to each author's RSS feed, and overrides the feed parameter.

Related

To use the query string to pass parameters to generate a list of authors, see Template_Tags/wp_list_authors

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/list_authors"Category: Template Tags

Template Tags/list cats

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Examples

4.1 Default List4.2 Sorted by Category Name4.3 Customized List with Excluded Categories

5 Notes on use6 Parameters7 Related

Description

Displays a list of Categories as links. When one of those links is clicked, all the posts in that Category will display in the appropriate CategoryTemplate dicatated by the Template Hierarchy rules. This tag works like the wp_list_cats tag, except that list_cats uses a long query string ofarguments while wp_list_cats uses text-based query arguments. WordPress 2.1 saw the introduction of a new and more inclusive template tagwp_list_categories, intended to replace wp_list_cats and list_cats.

Page 56: wp-api

Replace With

wp_list_categories().

Usage

<?php list_cats(optionall, 'all', 'sort_column', 'sort_order', 'file', list, optiondates, optioncount, hide_empty, use_desc_for_title, children, child_of, 'Categories', recurse, 'feed', 'feed_img', 'exclude', hierarchical); ?>

ExamplesDefault List

Displays the list of Categories using default settings:

<?php list_cats(); ?>

Sorted by Category Name

Displays the list of Categories, with not all Categories linked, and sorted by Category name:

<?php list_cats(FALSE, ' ', 'name'); ?>

Customized List with Excluded Categories

Sets the list to not list all the Categories (based upon further parameters), sorts by ID in ascending order and in an unordered list (<ul><li>)without dates or post counts, does not hide empty Categories, uses Category "description" for the title in the links, does not show the childrenof the parent Categories, and excludes Categories 1 and 33:

<?php list_cats(FALSE, '', 'ID', 'asc', '', TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, '', FALSE, '', '', '1,33', TRUE); ?>

Notes on use

When the 'list' parameter is set for an unordered list, the list_cats() tag automatically begins and ends with UL and each item listed as an LI.

Parameters

optionall (boolean) Sets whether to display a link to all Categories. Note: This feature no longer works in WordPress 1.5.x and 2.0 but is slated tobe added back at Version 2.1. Valid values:

TRUE (Default)FALSE

all (string) If optionall is set to TRUE, this defines the text to be displayed for the link to all Categories. Note: This feature no longer worksin WordPress 1.5.x and 2.0 but is slated to be added back at Version 2.1. Defaults to 'All'.

sort_column (string) Key to sort options by. Valid values:

'ID' (Default)'name'

sort_order (string) Sort order for options. Valid values:

'asc' (Default)'desc'

file (string) The php file a Category link is to be displayed on. Defaults to 'index.php'.

list (boolean) Sets whether the Categories are enclosed in an unordered list (<ul><li>). Valid values:

TRUE (Default)FALSE

Page 57: wp-api

optiondates (boolean) Sets whether to display the date of the last post in each Category. Valid values:

TRUEFALSE (Default)

optioncount (boolean) Sets whether to display a count of posts in each Category. Valid values:

TRUEFALSE (Default)

hide_empty (boolean) Sets whether to hide (not display) Categories with no posts. Valid values:

TRUE (Default)FALSE

use_desc_for_title (boolean) Sets whether the Category description is displayed as link title (i.e. <a title="Category Description" href="...).Valid values:

TRUE (Default)FALSE

children (boolean) Sets whether to show children (sub) Categories. Valid values:

TRUEFALSE (Default)

child_of (integer) Display only the Categories that are children of this Category (ID number). There is no default.

Categories (integer) This parameter should be set to 0 (zero) when calling this template tag. (For the curious, other values are used only internallyby the tag when generating a hierarchical list.)

recurse (boolean) Display the list (FALSE) or return it for use in PHP (TRUE). Defaults to FALSE.

feed (string) Text to display for the link to each Category's RSS2 feed. Default is no text, and no feed displayed.

feed_image (string) Path/filename for a graphic to act as a link to each Category's RSS2 feed. Overrides the feed parameter.

exclude (string) Sets the Categories to be excluded. This must be in the form of an array (ex: '1, 2, 3').

hierarchical (boolean) Sets whether to display child (sub) Categories in a hierarchical (after parent) list. Valid values:

TRUE (Default)FALSE

Note: The hierarchical parameter is not available in versions of WordPress prior to 1.5

Related

To use the query string to pass parameters to generate a list of Categories, see wp_list_cats()

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/list_cats"Category: Template Tags

Template Tags/next comments link

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Working example

4 Parameters5 Related

Description

This creates a link to the next comments page containing newer comments.

Usage

<?php next_comments_link( 'Label', 'Max number of pages (default 0)' ); ?>

Page 58: wp-api

ExamplesDefault Usage

<?php next_comments_link(); ?>

Working example

<?php next_comments_link( 'Newer Comments »', 0 ); ?>

Parameters

label (string) The link text. Default is 'Newer Comments »'.

max_pages (integer) Limit the number of pages on which the link is displayed.

Related

See also previous_comments_link(), paginate_comments_links()

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/next_comments_link"Category: Template Tags

Template Tags/next post link

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Bold Post Title As Link3.3 Text As Link, Without Post Title, Within Same Category3.4 Within Same Category, Excluding One

4 Parameters5 Related

Description

Used on single post permalink pages, this template tag displays a link to the next post which exists in chronological order from the current post.

This tag must be used in The Loop.

Usage

<?php next_post_link('format', 'link', 'in_same_cat', 'excluded_categories'); ?>

ExamplesDefault Usage

Displays link with the post title of the next post (chronological post date order), followed by a right angular quote (»). By default, this tag workslike next_post()

Next Post Title »

<?php next_post_link(); ?>

Bold Post Title As Link

Displays link with next chronological post's title wrapped in 'strong' tags (typically sets text to bold).

Page 59: wp-api

Next Post Title

<?php next_post_link('<strong>%link</strong>'); ?>

Text As Link, Without Post Title, Within Same Category

Displays custom text as link to the next post within the same category as the current post. Post title is not included here. "Next post in category"is the custom text, which can be changed to fit your requirements.

Next post in category

<?php next_post_link('%link', 'Next post in category', TRUE); ?>

Within Same Category, Excluding One

Displays link to next post in the same category, as long as it is not in category 13 (the category ID #). You can change the number to anycategory you wish to exclude. Exclude multiple categories by using " and " as a delimiter.

Next post in category

<?php next_post_link('%link', 'Next post in category', TRUE, '13'); ?>

Parameters

format (string) Format string for the link. This is where to control what comes before and after the link. '%link' in string will be replaced withwhatever is declared as 'link' (see next parameter). 'Go to %link' will generate "Go to <a href=..." Put HTML tags here to stylethe final results. Defaults to '%link &raquo;'.

link (string) Link text to display. Defaults to next post's title ('%title').

in_same_cat (boolean) Indicates whether next post must be within the same category as the current post. If set to TRUE, only posts from the currentcategory will be displayed. Options are:

TRUEFALSE (Default)

excluded_categories (string) Numeric category ID(s) from which the next post should not be listed. Separate multiple categories with and; example: '1 and5 and 15'. There is no default.In Wordpress 2.2 (only), apparently, concatenating multiple categories for exclusion is done with a comma, not and; example: '1, 5,15'. Still no default.

Related

See also previous_post_link().

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/next_post_link"Category: Template Tags

Template Tags/next posts link

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Working example

4 Parameters5 Related

Description

This creates a link to the previous posts. Yes, it says "next posts," but it's named that just to confuse you.

Usage

<?php next_posts_link('Label', 'Max number of pages (default 0)'); ?>

Page 60: wp-api

ExamplesDefault Usage

<?php next_posts_link(); ?>

Working example

<?php next_posts_link('Next Entries »', 0); ?>

Parameters

label (string) The link text. Default is 'Next Page »'.

max_pages (integer) Limit the number of pages on which the link is displayed.

Related

See also previous_posts_link(), next_post_link(), and previous_post_link().

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/next_posts_link"Category: Template Tags

Template Tags/paginate comments links

Contents1 Description

1.1 Example:2 Usage3 Parameters4 Styling5 Example Source Code

5.1 Working Example6 Uses in the Default Theme7 Related

Description

Generate a new way to list the paged comments in the comment template. Instead of using Previous or Next Comments links, it displays a fulllist of comment pages using numeric indexes (Only on Wordpress 2.7+).

This is probably the most efficient way to paginate comments in Wordpres 2.7 since it allows the users to select wich comment page wants tovisit instead of clicking trough every single page using the next/prev links.

Example:

1 2 3 ... 10 Next >>

Usage

<?php paginate_comments_links(); ?>

Parameters

Needs Further Completion

'base' => add_query_arg( 'cpage', '%#%' ),'format' => ,'total' => $max_page,'current' => $page,'echo' => true,

Page 61: wp-api

'add_fragment' => '#comments'

Styling

The function prints several css classes for further CSS styiling:

.page-numbers

.current

.next

.prev

Example Source Code

<span class='page-numbers current'>1</span> <a class='page-numbers' href='http://www.site.com/post-slug/comment-page-2/#comments'>2</a> <a class='next page-numbers' href='http://www.site.com/post-slug/comment-page-2/#comments'>Next »</a>

Working Example

http://www.lagzero.net/2008/12/descarga-el-parche-de-gta-iv-para-pc-gta-iv-pc-v1010/#comments

Uses in the Default Theme

The following code uses this function to create the Comments Pages index in the Default Theme's comments.php:

<div class="navigation"> <?php paginate_comments_links(); ?> </div> <ol class="commentlist"> <?php wp_list_comments(); ?> </ol> <div class="navigation"> <?php paginate_comments_links(); ?> </div>

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/paginate_comments_links"Category: Template Tags

Template Tags/permalink anchor

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Outputs a permalink anchor identifier or id (<a id="....) for a post. This is useful for linking to a particular post on a page displaying severalposts, such as an archive page. This tag must be within The Loop.

Usage

Page 62: wp-api

<?php permalink_anchor('type'); ?>

Example

Inserts the permalink anchor next to a post's title.

<h3><?php permalink_anchor(); ?><?php the_title(); ?></h3>

Parameters

type (string) Type of anchor to output. Valid values are:

'id' - Anchor equals numeric post ID. This is the default.'title' - Anchor equals postname, i.e. post slug.

Related

permalink_anchor, get_permalink, the_permalink, permalink_single_rss

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/permalink_anchor"Category: Template Tags

Template Tags/permalink comments rss

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the permalink to the post to which a comment belongs, formatted for RSS. Typically used in the RSS comment feed template. This tagmust be within The Loop, or a comment loop.

Usage

<?php permalink_comments_rss(); ?>

Example

<link><?php permalink_comments_rss(); ?></link>

Parameters

This tag has no parameters.

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/permalink_comments_rss"Categories: Template Tags | Feeds

Template Tags/permalink single rss

Contents

Page 63: wp-api

1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the permalink for the current post, formatted for syndication feeds such as RSS or Atom. This tag must be used within The Loop.

Usage

<?php permalink_single_rss('file'); ?>

Example

Displays the permalink in an RSS link tag.

<link><?php permalink_single_rss(); ?></link>

Parameters

file (string) The page the link should point to. Defaults to the current page.

Related

For permalinks in regular page templates, it's recommended to use the_permalink() instead.

permalink_anchor, get_permalink, the_permalink, permalink_single_rss

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/permalink_single_rss"Categories: Template Tags | Feeds

Template Tags/posts nav link

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 In Centered DIV3.3 Using Images3.4 Kubrick Theme Format3.5 Customizing the Link Text

4 Parameters5 Related

Description

Displays links for next and previous pages. Useful for providing "paged" navigation of index, category and archive pages.

For displaying next and previous post navigation on individual posts, see next_post_link() and previous_post_link().

Usage

<?php posts_nav_link('sep','prelabel','nxtlabel'); ?>

Note that since weblog posts are traditionally listed in reverse chronological order (with most recent posts at the top), there is some ambiguityin the definition of "next page". WordPress defines "next page" as the "next page toward the past". In WordPress 1.5, the default Kubrick themeaddresses this ambiguity by labeling the "next page" link as "previous entries". See Example: Kubrick Theme Format.

ExamplesDefault Usage

Page 64: wp-api

By default, the posts_nav_link look like this:

« Previous Page — Next Page »

<?php posts_nav_link(); ?>

In Centered DIV

Displays previous and next page links ("previous page · next page") centered on the page.

<div style="text-align:center;"><?php posts_nav_link(' &#183; ', 'previous page', 'next page'); ?></div>

Using Images

<?php posts_nav_link(' ', '<img src="images/prev.jpg" />', '<img src="images/next.jpg" />'); ?>

Kubrick Theme Format

The Kubrick theme format for posts navigation.

<div class="navigation"><div class="alignleft"><?php posts_nav_link('','','&laquo; Previous Entries') ?></div><div class="alignright"><?php posts_nav_link('','Next Entries &raquo;','') ?></div></div>

Customizing the Link Text

You can change the text in each of the links and in the text in between the links.

You can go back to the previous page or you can go forward to the next page.

<p><?php posts_nav_link(' or ', 'You can go back to the previous page', 'you can go forward to the next page'); ?>.</p>

Parameters

sep (string) Text displayed between the links.

Defaults to ' :: ' in 1.2.x.Defaults to ' — ' in 1.5.

prelabel (string) Link text for the previous page.

Defaults to '<< Previous Page' in 1.2.x.Defaults to '« Previous Page' in 1.5.

nxtlabel (string) Link text for the next page.

Defaults to 'Next Page >>' in 1.2.x.Defaults to 'Next Page »' in 1.5

Related

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/posts_nav_link"Category: Template Tags

Page 65: wp-api

Template Tags/previous comments link

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Working example

4 Parameters5 Related

Description

This creates a link to the previous comments page containing older comments.

Usage

<?php previous_comments_link( 'Label' ); ?>

ExamplesDefault Usage

<?php previous_comments_link(); ?>

Working example

<?php previous_comments_link( '« Older Comments' ); ?>

Parameters

label (string) The link text. Default is '« Older Comments'.

Related

See also next_comments_link(), paginate_comments_links()

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/previous_comments_link"Category: Template Tags

Template Tags/previous post link

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Bold Post Title As Link3.3 Text As Link, Without Post Title, Within Same Category3.4 Within Same Category, Excluding One

4 Parameters5 Related

Description

Used on single post permalink pages, this template tag displays a link to the previous post which exists in chronological order from the currentpost.

This tag must be used in The Loop.

Usage

<?php previous_post_link('format', 'link', in_same_cat,

Page 66: wp-api

'excluded_categories'); ?>

ExamplesDefault Usage

Displays link with left angular quote («) followed by the post title of the previous post (chronological post date order). By default, this tag workslike previous_post().

« Previous Post Title

<?php previous_post_link(); ?>

Bold Post Title As Link

Displays link with previous chronological post's title wrapped in 'strong' tags (typically sets text to bold).

Previous Post Title

<?php previous_post_link('<strong>%link</strong>'); ?>

Text As Link, Without Post Title, Within Same Category

Displays custom text as link to the previous post within the same category as the current post. Post title is not included here. "Previous incategory" is the custom text, which can be changed to fit your requirements.

Previous in category

<?php previous_post_link('%link', 'Previous in category', TRUE); ?>

Within Same Category, Excluding One

Displays link to previous post in the same category, as long as it is not in category 13 (the category ID #). You can change the number to anycategory you wish to exclude. Exclude multiple categories by using " and " as a delimiter.

Previous in category

<?php previous_post_link('%link', 'Previous in category', TRUE, '13'); ?>

Parameters

format (string) Format string for the link. This is where to control what comes before and after the link. '%link' in string will be replaced withwhatever is declared as 'link' (see next parameter). 'Go to %link' will generate "Go to <a href=..." Put HTML tags here to stylethe final results. Defaults to '&laquo; %link'.

link (string) Link text to display. Defaults to previous post's title ('%title').

in_same_cat (boolean) Indicates whether previous post must be within the same category as the current post. If set to TRUE, only posts from thecurrent category will be displayed. Options are:

TRUEFALSE (Default)

excluded_categories (string) Numeric category ID(s) from which the previous post should not be listed. Separate multiple categories with and; example: '1and 5 and 15'. There is no default.

Related

See also next_post_link().

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

Page 67: wp-api

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/previous_post_link"Category: Template Tags

Template Tags/previous posts link

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Working example

4 Parameters5 Related

Description

This creates a link to the next posts. Yes, it says "previous posts," but it's named that just to confuse you.

Usage

<?php previous_posts_link('Label', 'Max number of pages (default 0)'); ?>

ExamplesDefault Usage

<?php previous_posts_link(); ?>

Working example

<?php previous_posts_link('« Previous Entries', '0') ?>

Parameters

label (string) The link text. Default is '« Previous Page'.

max_pages (integer) Limit the number of pages on which the link is displayed.

Related

See also next_posts_link() and previous_post_link().

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/previous_posts_link"Category: Template Tags

Template Tags/print AcmeMap Url

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the URL to a ACME Mapper generated map for your location. If the tag is called from within The_Loop, the Latitude and Longitudeentered for a post is inserted in the query string of the URL for the map. When called outside The Loop (or inside The Loop, but no Lat/Lon was

Page 68: wp-api

entered for a post), default Latitude and Longitude for the weblog is inserted in the query string.

Usage

<?php print_AcmeMap_Url(); ?>

Example

<a href="<?php print_AcmeMap_Url(); ?>">Locate me with ACME Mapper</a>

Parameters

This tag has no parameters.

Related

print_Lat, print_Lon, print_UrlPopNav, print_AcmeMap_Url, print_GeoURL_Url, print_GeoCache_Url, print_MapQuest_Url, print_SideBit_Url,print_DegreeConfluence_Url, print_TopoZone_Url, print_FindU_Url, print_MapTech_Url

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/print_AcmeMap_Url"Category: Template Tags

Template Tags/print DegreeConfluence Url

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the URL to the nearest integer degree intersection Confluence page for your location. If the tag is called from within The_Loop, theLatitude and Longitude entered for a post is inserted in the query string of the URL to the page of the nearest integer degree confluence. Whencalled outside The Loop (or inside The Loop, but no Lat/Lon was entered for a post), default Latitude and Longitude for the weblog is insertedin the query string.

Usage

<?php print_DegreeConfluence_Url(); ?>

Example

<a href="<?php print_DegreeConfluence_Url(); ?>">What integer degreeintersection am I near?</a>

Parameters

This tag has no parameters.

Related

print_Lat, print_Lon, print_UrlPopNav, print_AcmeMap_Url, print_GeoURL_Url, print_GeoCache_Url, print_MapQuest_Url, print_SideBit_Url,print_DegreeConfluence_Url, print_TopoZone_Url, print_FindU_Url, print_MapTech_Url

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/print_DegreeConfluence_Url"Category: Template Tags

Template Tags/print FindU Url

Contents1 Description2 Usage3 Example4 Parameters

Page 69: wp-api

5 Related

Description

Displays the URL to a APRS FindU generated page listing HAM radio stations near your location. If the tag is called from within The_Loop, theLatitude and Longitude entered for a post is inserted in the query string of the URL used for generating the list of HAM radio stations. Whencalled outside The Loop (or inside The Loop, but no Lat/Lon was entered for a post), default Latitude and Longitude for the weblog is insertedin the query string.

Usage

<?php print_FindU_Url(); ?>

Example

<a href="<?php print_FindU_Url(); ?>">HAM stations near me</a>

Parameters

This tag has no parameters.

Related

print_Lat, print_Lon, print_UrlPopNav, print_AcmeMap_Url, print_GeoURL_Url, print_GeoCache_Url, print_MapQuest_Url, print_SideBit_Url,print_DegreeConfluence_Url, print_TopoZone_Url, print_FindU_Url, print_MapTech_Url

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/print_FindU_Url"Category: Template Tags

Template Tags/print GeoCache Url

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the URL for a Geocaching generated list of geocaches near your location. If the tag is called from within The_Loop, the Latitude andLongitude entered for a post is inserted in the query string of the URL for the geocache locations. When called outside The Loop (or inside TheLoop, but no Lat/Lon was entered for a post), default Latitude and Longitude for the weblog is inserted in the query string.

Usage

<?php print_GeoCache_Url(); ?>

Example

<a href="<?php print_GeoCache_Url(); ?>">Locate geocaches near me</a>

Parameters

This tag has no parameters.

Related

print_Lat, print_Lon, print_UrlPopNav, print_AcmeMap_Url, print_GeoURL_Url, print_GeoCache_Url, print_MapQuest_Url, print_SideBit_Url,print_DegreeConfluence_Url, print_TopoZone_Url, print_FindU_Url, print_MapTech_Url

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/print_GeoCache_Url"Category: Template Tags

Template Tags/print GeoURL Url

Page 70: wp-api

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the URL to a GeoURL page listing websites near your location. If the tag is called from within The_Loop, the Latitude and Longitudeentered for a post is inserted in the query string of the URL for the list. When called outside The Loop (or inside The Loop, but no Lat/Lon wasentered for a post), default Latitude and Longitude for the weblog is inserted in the query string.

Usage

<?php print_GeoURL_Url(); ?> <meta name="robots" content="index, follow" /> <meta name="distribution" content="global" /><meta name="revisit-after" content="2 days" /> <meta name="author" content="donkdepeggy kampanye damai" /> <meta name="language"content="ID" /> <meta name="geo.country" content="ID" /> <meta name="geo.placename" content="Indonesia" />

Example

<a href="<?php print_GeoURL_Url(); ?>">Locate sites near me with GeoURL</a>

Parameters

This tag has no parameters.

Related

print_Lat, print_Lon, print_UrlPopNav, print_AcmeMap_Url, print_GeoURL_Url, print_GeoCache_Url, print_MapQuest_Url, print_SideBit_Url,print_DegreeConfluence_Url, print_TopoZone_Url, print_FindU_Url, print_MapTech_Url

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/print_GeoURL_Url"Category: Template Tags

Template Tags/print Lat

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the Geographic (geodata) Options Latitude setting. If the tag is called from within The_Loop, the Latitude entered for a post isdisplayed. When called outside The Loop (or inside The Loop, but no Latitude was entered for a post), the default Latitude setting for theweblog is displayed.

Usage

<?php print_Lat(); ?>

Example

<p>Trip locale: <?php print_Lat(); ?>Lat, <?php print_Lon(); ?>Lon</p>

Parameters

This tag has no parameters.

Related

print_Lat, print_Lon, print_UrlPopNav, print_AcmeMap_Url, print_GeoURL_Url, print_GeoCache_Url, print_MapQuest_Url, print_SideBit_Url,print_DegreeConfluence_Url, print_TopoZone_Url, print_FindU_Url, print_MapTech_Url

Page 71: wp-api

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/print_Lat"Category: Template Tags

Template Tags/print Lon

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the Geographic (geodata) Options Longitude setting. If the tag is called from within The_Loop, the Longitude entered for a post isdisplayed. When called outside The Loop (or inside The Loop, but no Longitude was entered for a post), the default Longitude setting for theweblog is displayed.

Usage

<?php print_Lon(); ?>

Example

<p>Trip locale: <?php print_Lat(); ?>Lat, <?php print_Lon(); ?>Lon</p>

Parameters

This tag has no parameters.

Related

print_Lat, print_Lon, print_UrlPopNav, print_AcmeMap_Url, print_GeoURL_Url, print_GeoCache_Url, print_MapQuest_Url, print_SideBit_Url,print_DegreeConfluence_Url, print_TopoZone_Url, print_FindU_Url, print_MapTech_Url

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/print_Lon"Category: Template Tags

Template Tags/print MapQuest Url

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the URL for a MapQuest generated map of your location. If the tag is called from within The_Loop, the Latitude and Longitude enteredfor a post is inserted in the query string of the URL used for generating the map. When called outside The Loop (or inside The Loop, but noLat/Lon was entered for a post), default Latitude and Longitude for the weblog is inserted in the query string.

Usage

<?php print_MapQuest_Url(); ?>

Example

<a href="<?php print_MapQuest_Url(); ?>">MapQuest map of my location</a>

Parameters

This tag has no parameters.

Page 72: wp-api

Related

print_Lat, print_Lon, print_UrlPopNav, print_AcmeMap_Url, print_GeoURL_Url, print_GeoCache_Url, print_MapQuest_Url, print_SideBit_Url,print_DegreeConfluence_Url, print_TopoZone_Url, print_FindU_Url, print_MapTech_Url

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/print_MapQuest_Url"Category: Template Tags

Template Tags/print MapTech Url

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the URL to a Maptech generated geographical map for your location. If the tag is called from within The_Loop, the Latitude andLongitude entered for a post is inserted in the query string of the URL used for generating the map. When called outside The Loop (or insideThe Loop, but no Lat/Lon was entered for a post), default Latitude and Longitude for the weblog is inserted in the query string.

Usage

<?php print_MapTech_Url(); ?>

Example

<a href="<?php print_MapTech_Url(); ?>">Maptech map of my location</a>

Parameters

This tag has no parameters.

Related

print_Lat, print_Lon, print_UrlPopNav, print_AcmeMap_Url, print_GeoURL_Url, print_GeoCache_Url, print_MapQuest_Url, print_SideBit_Url,print_DegreeConfluence_Url, print_TopoZone_Url, print_FindU_Url, print_MapTech_Url

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/print_MapTech_Url"Category: Template Tags

Template Tags/print SideBit Url

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the URL for a SideBit generated map of sites in your location. If the tag is called from within The_Loop, the Latitude and Longitudeentered for a post is inserted in the query string of the URL used for generating the map. When called outside The Loop (or inside The Loop,but no Lat/Lon was entered for a post), default Latitude and Longitude for the weblog is inserted in the query string.

Usage

<?php print_SideBit_Url(); ?>

Example

<a href="<?php print_SideBit_Url(); ?>">SideBit map of my location</a>

Page 73: wp-api

Parameters

This tag has no parameters.

Related

print_Lat, print_Lon, print_UrlPopNav, print_AcmeMap_Url, print_GeoURL_Url, print_GeoCache_Url, print_MapQuest_Url, print_SideBit_Url,print_DegreeConfluence_Url, print_TopoZone_Url, print_FindU_Url, print_MapTech_Url

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/print_SideBit_Url"Category: Template Tags

Template Tags/print TopoZone Url

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the URL to a TopoZone generated topographic map for your location. If the tag is called from within The_Loop, the Latitude andLongitude entered for a post is inserted in the query string of the URL used for generating the map. When called outside The Loop (or insideThe Loop, but no Lat/Lon was entered for a post), default Latitude and Longitude for the weblog is inserted in the query string.

Usage

<?php print_TopoZone_Url(); ?>

Example

<a href="<?php print_TopoZone_Url(); ?>">Topographic map of my location</a>

Parameters

This tag has no parameters.

Related

print_Lat, print_Lon, print_UrlPopNav, print_AcmeMap_Url, print_GeoURL_Url, print_GeoCache_Url, print_MapQuest_Url, print_SideBit_Url,print_DegreeConfluence_Url, print_TopoZone_Url, print_FindU_Url, print_MapTech_Url

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/print_TopoZone_Url"Category: Template Tags

Template Tags/print UrlPopNav

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays a dropdown menu, of which each option is a link opening in a new browser window the mentioned geodata-related site. If the tag iscalled from within The_Loop, the Latitude and Longitude entered for a post are queried at each site. When called outside The Loop (or insideThe Loop, but no Lat/Lon was entered for a post), default Latitude and Longitude for the weblog are queried.

Link options in the dropdown menu are:

Acme Mapper

Page 74: wp-api

GeoURLs near hereGeoCaches near hereMapQuest map of this spotSideBit URL map of this spotConfluence.org near hereTopozone near hereFindU near hereMaptech near here

Usage

<?php print_UrlPopNav(); ?>

Example

<div>Choose Geo site: <?php print_UrlPopNav(); ?></div>

Parameters

This tag has no parameters.

Related

print_Lat, print_Lon, print_UrlPopNav, print_AcmeMap_Url, print_GeoURL_Url, print_GeoCache_Url, print_MapQuest_Url, print_SideBit_Url,print_DegreeConfluence_Url, print_TopoZone_Url, print_FindU_Url, print_MapTech_Url

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/print_UrlPopNav"Category: Template Tags

Template Tags/query posts

Contents1 Description2 Important note3 Usage4 Examples

4.1 Exclude Categories From Your Home Page4.2 Retrieve a Particular Post4.3 Retrieve a Particular Page4.4 Passing variables to query_posts

4.4.1 Example 14.4.2 Example 24.4.3 Example 34.4.4 Example 4

5 Parameters5.1 Category Parameters5.2 Tag Parameters5.3 Author Parameters5.4 Post & Page Parameters5.5 Sticky Post Parameters5.6 Time Parameters5.7 Page Parameters5.8 Offset Parameter5.9 Orderby Parameters5.10 Custom Field Parameters5.11 Combining Parameters

6 Resources7 Related

Description

Query_posts can be used to control which posts show up in The Loop. It accepts a variety of parameters in the same format as used in yourURL (e.g. p=4 to show only post of ID number 4).

Why go through all the trouble of changing the query that was meticulously created from your given URL? You can customize the presentationof your blog entries by combining it with page logic (like the Conditional Tags) -- all without changing any of the URLs.

Common uses might be to:

Display only a single post on your homepage (a single Page can be done via Settings -> Reading).Show all posts from a particular time period.

Page 75: wp-api

Show the latest post (only) on the front page.Change how posts are ordered.Show posts from only one category.Exclude one or more categories.

Important note

The query_posts function is intended to be used to modify the main page Loop only. It is not intended as a means to create secondary Loopson the page. If you want to create separate Loops outside of the main one, you should create separate WP_Query objects and use thoseinstead. Use of query_posts on Loops other than the main one can result in your main Loop becoming incorrect and possibly displaying thingsthat you were not expecting.

The query_posts function overrides and replaces the main query for the page. To save your sanity, do not use it for any other purpose.

Usage

Place a call to query_posts() in one of your Template files before The Loop begins. The wp_query object will generate a new SQL queryusing your parameters. When you do this, WordPress ignores the other parameters it receives via the URL (such as page number or category).If you want to preserve that information, you can use the variable $query_string in the call to query_posts().

For example, to set the display order of the posts without affecting the rest of the query string, you could place the following before The Loop:

query_posts($query_string . "&order=ASC")

When using query_posts in this way, the quoted portion of the argument must begin with an ampersand (&).

ExamplesExclude Categories From Your Home Page

Placing this code in your index.php file will cause your home page to display posts from all categories except category ID 3.

<?php if (is_home()) { query_posts("cat=-3"); }?>

You can also add some more categories to the exclude-list(tested with WP 2.1.2):

<?php if (is_home()) { query_posts("cat=-1,-2,-3"); }?>

Retrieve a Particular Post

To retrieve a particular post, you could use the following:

<?php// retrieve one post with an ID of 5query_posts('p=5'); ?>

If you want to use the Read More functionality with this query, you will need to set the global $more variable to 0.

<?php// retrieve one post with an ID of 5query_posts('p=5'); global $more;// set $more to 0 in order to only get the first part of the post$more = 0;

// the Loopwhile (have_posts()) : the_post(); // the content of the post the_content('Read the full post »'); endwhile;?>

Page 76: wp-api

Retrieve a Particular Page

To retrieve a particular page, you could use the following:

<?phpquery_posts('page_id=7'); //retrieves page 7 only?>

or

<?phpquery_posts('pagename=about'); //retrieves the about page only?>

For child pages, the slug of the parent and the child is required, separated by a slash. For example:

<?phpquery_posts('pagename=parent/child'); // retrieve the child page of a parent?>

Passing variables to query_posts

You can pass a variable to the query with two methods, depending on your needs. As with other examples, place these above your Loop:

Example 1

In this example, we concatenate the query before running it. First assign the variable, then concatenate and then run it. Here we're pulling in acategory variable from elsewhere.

<?php $categoryvariable=$cat; // assign the variable as current category $query= 'cat=' . $categoryvariable. '&orderby=date&order=ASC'; // concatenate the query query_posts($query); // run the query ?>

Example 2

In this next example, the double " quotes " tell PHP to treat the enclosed as an expression. For this example, we are getting the current monthand the current year, and telling query posts to bring us the posts for the current month/year, and in this case, listing in ascending so we getoldest post at top of page.

<?php $current_month = date('m'); ?><?php $current_year = date('Y'); ?>

<?php query_posts("cat=22&year=$current_year&monthnum=$current_month&order=ASC"); ?><!-- put your loop here -->

Example 3

This example explains how to generate a complete list of posts, dealing with pagination. We can use the default $query_string telling queryposts to bring us a full posts listing. We can also modify the posts_per_page query argument from -1 to the number of posts you want to showon each page; in this last case, you'll probably want to use posts_nav_link() to navigate the generated archive. .

<?php query_posts($query_string.'&posts_per_page=-1');while(have_posts()) { the_post();<!-- put your loop here -->}?>

Example 4

If you don't need to use the $query_string variable, then another method exists that is more clear and readable, in some more complex cases.This method puts the parameters into an array, and then passes the array. The same query as in Example 2 above could be done like this:

query_posts(array('cat' => 22, 'year'=> $current_year, 'monthnum'=>$current_month, 'order'=>'ASC',

Page 77: wp-api

));

As you can see, with this approach, every variable can be put on its own line, for simpler reading.

Parameters

This is not an exhaustive list yet. It is meant to show some of the more common things possible with setting your own queries.

Category Parameters

Show posts only belonging to certain categories.

catcategory_namecategory__andcategory__incategory__not_in

Show One Category by ID

Display posts from only one category ID (and any children of that category):

query_posts('cat=4');

Show One Category by Name

Display posts from only one category by name:

query_posts('category_name=Staff Home');

Show Several Categories by ID

Display posts from several specific category IDs:

query_posts('cat=2,6,17,38');

Exclude Posts Belonging to Only One Category

Show all posts except those from a category by prefixing its ID with a '-' (minus) sign.

query_posts('cat=-3');

This excludes any post that belongs to category 3.

Multiple Category Handling

Display posts that are in multiple categories. This shows posts that are in both categories 2 and 6:

query_posts(array('category__and' => array(2,6)));

To display posts from either category 2 OR 6, you could use cat as mentioned above, or by using category__in:

query_posts(array('category__in' => array(2,6)));

You can also exclude multiple categories this way:

query_posts(array('category__not_in' => array(2,6)));

Tag Parameters

Show posts associated with certain tags.

tagtag__andtag__intag_slug__andtag_slug__in

Fetch posts for one tag

query_posts('tag=cooking');

Fetch posts that have either of these tags

Page 78: wp-api

query_posts('tag=bread,baking');

Fetch posts that have all three of these tags:

query_posts('tag=bread+baking+recipe');

Multiple Tag Handling

Display posts that are in multiple tags:

query_posts(array('tag__and' => array('bread','baking'));

This only shows posts that are in both tags 'bread' and 'baking'. To display posts from either tag, you could use tag as mentioned above, orexplicitly specify by using tag__in:

query_posts(array('tag__in' => array('bread','baking'));

The tag_slug__in and tag_slug__and behave much the same, except match against the tag's slug instead of the tag itself.

Also see Ryan's discussion of Tag intersections and unions.

Author Parameters

You can also restrict the posts by author.

author_name=Harriet Note: author_name operates on the user_nicename field, whilst author operates on the author id.author=3

Display all Pages for author=1, in title order, with no sticky posts tacked to the top:

query_posts('caller_get_posts=1&author=1&post_type=page&post_status=publish&orderby=title&order=ASC');

Post & Page Parameters

Retrieve a single post or page.

p=27 - use the post ID to show that postname=about-my-life - query for a particular post that has this Post Slugpage_id=7 - query for just Page ID 7pagename=about - note that this is not the page's title, but the page's pathshowposts=1 - use showposts=3 to show 3 posts. Use showposts=-1 to show all posts'post__in' => array(5,12,2,14,7) - inclusion, lets you specify the post IDs to retrieve'post__not_in' => array(6,2,8) - exclusion, lets you specify the post IDs NOT to retrieve'post_type=page' - returns Pages; defaults to value of post; can be any, attachment, page, or post.

Sticky Post Parameters

Sticky posts first became available with WordPress Version 2.7. Posts that are set as Sticky will be displayed before other posts in a query,unless excluded with the caller_get_posts=1 parameter.

array('post__in'=>get_option('sticky_posts')) - returns array of all sticky postscaller_get_posts=1 - To exclude sticky posts be included at the beginning of posts returned, but the sticky post will still be returnedin the natural order of that list of posts returned.

To return just the first sticky post:

$sticky=get_option('sticky_posts') ; query_posts('p=' . $sticky[0]);

To exclude all sticky posts from the query:

query_posts(array("post__not_in" =>get_option("sticky_posts")));

Return ALL posts with the category, but don't show sticky posts at the top. The 'sticky posts' will still show in their natural position(e.g. by date):

query_posts('caller_get_posts=1&showposts=3&cat=6');

Return posts with the category, but exclude sticky posts completely, and adhere to paging rules:

<?php$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;$sticky=get_option('sticky_posts');

Page 79: wp-api

$args=array( 'cat'=>3, 'caller_get_posts'=>1, 'post__not_in' => $sticky, 'paged'=>$paged, );query_posts($args);?>

Time Parameters

Retrieve posts belonging to a certain time period.

hour= - hour (from 0 to 23)minute= - minute (from 0 to 60)second= - second (0 to 60)day= - day of the month (from 1 to 31)monthnum= - month number (from 1 to 12)year= - 4 digit year (e.g. 2009)w= - week of the year (from 0 to 53) and uses the MySQL WEEK command Mode=1.

Returns posts for just the current date:

$today = getdate();query_posts('year=' .$today["year"] .'&monthnum=' .$today["mon"] .'&day=' .$today["mday"] );

Returns posts dated December 20:

query_posts(monthnum=12&day=20' );

Page Parameters

paged=2 - show the posts that would normally show up just on page 2 when using the "Older Entries" link.posts_per_page=10 - number of posts to show per page; a value of -1 will show all posts.order=ASC - show posts in chronological order, DESC to show in reverse order (the default)

Offset Parameter

You can displace or pass over one or more initial posts which would normally be collected by your query through the use of the offsetparameter.

The following will display the 5 posts which follow the most recent (1):

query_posts('showposts=5&offset=1');

Orderby Parameters

Sort retrieved posts by this field.

orderby=authororderby=dateorderby=category Note: this doesn't work and likely will be discontinued with version 2.8orderby=titleorderby=modifiedorderby=menu_orderorderby=parentorderby=IDorderby=randorderby=meta_value - note that a meta_key=some value clause should be present in the query parameter also

Also consider order parameter of "ASC" or "DESC"

Custom Field Parameters

Retrieve posts (or Pages) based on a custom field key or value.

meta_key=meta_value=meta_compare= - operator to test the meta_value=, default is '=', with other possible values of '!=', '>', '>=', '<', or '<='

Returns posts with custom fields matching both a key of 'color' AND a value of 'blue':

Page 80: wp-api

query_posts('meta_key=color&meta_value=blue');

Returns posts with a custom field key of 'color', regardless of the custom field value:

query_posts('meta_key=color');

Returns posts where the custom field value is 'color', regardless of the custom field key:

query_posts('meta_value=color');

Returns any Page where the custom field value is 'green', regardless of the custom field key:

query_posts('post_type=page&meta_value=green');

Returns both posts and Pages with a custom field key of 'color' where the custom field value IS NOT EQUAL TO 'blue':

query_posts('post_type=any&meta_key=color&meta_compare=!=&meta_value=blue');

Returns posts with custom field key of 'miles' with a custom field value that is LESS THAN OR EQUAL TO 22. Note the value 99 will beconsidered greater than 100 as the data is store as strings, not numbers.

query_posts('meta_key=miles&meta_compare=<=&meta_value=22');

Combining Parameters

You may have noticed from some of the examples above that you combine parameters with an ampersand (&), like so:

query_posts('cat=3&year=2004');

Posts for category 13, for the current month on the main page:

if (is_home()) {query_posts($query_string . '&cat=13&monthnum=' . date('n',current_time('timestamp')));}

At 2.3 this combination will return posts belong to both Category 1 AND 3, showing just two (2) posts, in descending order by the title:

query_posts(array('category__and'=>array(1,3),'showposts'=>2,'orderby'=>title,'order'=>DESC));

In 2.3 and 2.5 one would expect the following to return all posts that belong to category 1 and is tagged "apples"

query_posts('cat=1&tag=apples');

A bug prevents this from happening. See Ticket #5433. A workaround is to search for several tags using +

query_posts('cat=1&tag=apples+apples');

This will yield the expected results of the previous query. Note that using 'cat=1&tag=apples+oranges' yields expected results.

Resources

If..Else - Query Post ReduxIf..Else - Make WordPress Show Only one Post on the Front PageIf..Else - Query PostsPerishable Press - 6 Ways to Customize WordPress Post Ordernietoperzka's Custom order of posts on the main pagehttp://www.darrenhoyt.com/2008/06/11/displaying-related-category-and-author-content-in-wordpress/ Displaying related category andauthor content]Exclude posts from displaying

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags

Go to Template Tag index

Page 81: wp-api

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Template_Tags/query_posts"Categories: Template Tags | Stubs

Template Tags/rss enclosure

Contents1 Description2 Usage3 Parameters

3.1 Related

DescriptionTransforms links to audio or video files in a post into RSS enclosures. Used for Podcasting.

Usage<?php rss_enclosure(); ?>

ParametersNone.

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags

Go to Template Tag index

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Template_Tags/rss_enclosure"Categories: Template Tags | Stubs

Template Tags/single cat title

Contents1 Description2 Usage3 Examples4 Parameters5 Related

Description

Displays or returns the category title for the current page. For pages displaying WordPress tags rather than categories (e.g. "/tag/geek") thename of the tag is displayed instead of the category. Can be used only outside The Loop.

Usage

<?php single_cat_title('prefix', 'display'); ?>

Examples

This example displays the text "Currently browsing " followed by the category title.

<p><?php single_cat_title('Currently browsing '); ?>.</p>

Page 82: wp-api

Currently browsing WordPress.

This example assigns the current category title to the variable $current_category for use in PHP.

<?php $current_category = single_cat_title("", false); ?>

Parameters

prefix (string) Text to output before the category title. Defaults to '' (no text).

display (boolean) Display the category's title (TRUE) or return it for use in PHP (FALSE). Defaults to TRUE.

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/single_cat_title"Category: Template Tags

Template Tags/single month title

Contents1 Description2 Usage3 Examples

3.1 Month and Year on New Lines3.2 Using $my_month Variable

4 Parameters5 Related

Description

Displays or returns the month and year title for the current page. This tag only works when the m or archive month argument has been passedby WordPress to the current page (this occurs when viewing a monthly archive page). Note: This tag only works on date archive pages, not oncategory templates or others.

Usage

<?php single_month_title('prefix', display) ?>

The generated title will be:

prefix + MONTH + prefix + YEAR

If prefix parameter is '*', an example would be:

*February*2004

ExamplesMonth and Year on New Lines

Displays the title, placing month and year on new lines.

<p><?php single_month_title('<br />') ?></p>

December2004

Page 83: wp-api

Using $my_month Variable

Returns the title, which is assigned to the $my_month variable. The variable's value is then displayed with the PHP echo command.

<?php $my_month = single_month_title('', false); echo $my_month; ?>

Parameters

prefix (string) Text to place before the title. There is no default.

display (boolean) Display the title (TRUE), or return the title to be used in PHP (FALSE). Defaults to TRUE.

Related

the_date_xml, the_date, the_time, the_modified_date, the_modified_time, get_the_time, single_month_title, get_calendar, the_weekday,the_weekday_date

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/single_month_title"Category: Template Tags

Template Tags/single post title

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays or returns the title of the post when on a single post page (permalink page). This tag can be useful for displaying post titles outsideThe Loop.

Usage

<?php single_post_title('prefix', display); ?>

Example

<h2><?php single_post_title('Current post: '); ?></h2>

Current post: Single Post Title

Parameters

prefix (string) Text to place before the title. Defaults to ''.

display (boolean) Should the title be displayed (TRUE) or returned for use in PHP (FALSE). Defaults to TRUE.

Related

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Page 84: wp-api

Retrieved from "http://codex.wordpress.org/Template_Tags/single_post_title"Category: Template Tags

Template Tags/single tag title

Contents1 Description2 Usage3 Examples4 Parameters5 Related

Description

Displays or returns the tag title for the current page.

Usage

<?php single_tag_title('prefix', 'display'); ?>

Examples

This example displays the text "Currently browsing " followed by the tag title.

<p><?php single_tag_title('Currently browsing '); ?>.</p>

Currently browsing WordPress.

This example assigns the current tag title to the variable $current_tag for use in PHP.

<?php $current_tag = single_tag_title("", false); ?>

Parameters

prefix (string) Text to output before the tag title. Defaults to '' (no text).

display (boolean) Display the tag's title (TRUE) or return it for use in PHP (FALSE). Defaults to TRUE.

Related

the_tags, get_the_tags, get_the_tag_list, single_tag_title, get_tag_link, wp_tag_cloud, wp_generate_tag_cloud

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/single_tag_title"Category: Template Tags

Template Tags/sticky class

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Sticky Post Identifier

4 Parameters5 Related

Description

Displays the sticky post class on a post if applicable. This tag must be within The Loop. Requires Wordpress 2.7 or later.

Usage

Page 85: wp-api

<?php sticky_class(); ?>

ExamplesDefault Usage

<div class="post<?php sticky_class(); ?>" id="post-<?php the_ID(); ?>">

Sticky Post Identifier

Provides a sticky class to each post that it applies to:

Parameters

This tag has no parameters.

Related

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/sticky_class"Category: Template Tags

Template Tags/the ID

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Post Anchor Identifier

4 Parameters5 Related

Description

Displays the numeric ID of the current post. This tag must be within The Loop.

Usage

<?php the_ID(); ?>

ExamplesDefault Usage

<p>Post Number: <?php the_ID(); ?></p>

Post Anchor Identifier

Provides a unique anchor identifier to each post:

<h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3>

Note: In XHTML, the id attribute must not start with a digit. Since the_ID returns the post ID as numerical data, you should include at leastone alphabetical character before using it in an id attribute, as in the example above.

Parameters

This tag has no parameters.

Related

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_ID"

Page 86: wp-api

Category: Template Tags

Template Tags/the author

Contents1 Description2 Usage3 Examples

3.1 Display Author's 'Public' Name4 Parameters5 Related

Description

The author of a post can be displayed by using this Template Tag. This tag must be used within The Loop.

Usage

<?php the_author(); ?>

ExamplesDisplay Author's 'Public' Name

Displays the value in the user's Display name publicly as field.

<p>This post was written by <?php the_author(); ?></p>

Parameters

This function takes no arguments. (The arguments have been deprecated.)

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author"Category: Template Tags

Template Tags/the author ID

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the unique numeric user ID for the author of a post; the ID is assigned by WordPress when a user account is created. This tag mustbe used within The Loop.

Usage

<?php the_author_ID(); ?>

Example

Uses the author ID as a query link to all of that author's posts.

<a href="/blog/index.php?author=<?php the_author_ID(); ?>">View all posts by <?php the_author_nickname(); ?></a>

Page 87: wp-api

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_ID"Category: Template Tags

Template Tags/the author aim

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

This tag displays the AOL Instant Messenger screenname for the author of a post. The AIM field is set in the user's profile (Administration >Profile > Your Profile). This tag must be used within The Loop.

Usage

<?php the_author_aim(); ?>

Example

<p>Contact me on AOL Instant Messenger: <?php the_author_aim(); ?></p>

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_aim"Category: Template Tags

Template Tags/the author description

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the contents of the About yourself field in an author's profile (Administration > Profile > Your Profile). About yourself is a block oftext often used to publicly describe the user and can be quite long. This tag must be used within The Loop.

Usage

<?php the_author_description(); ?>

Page 88: wp-api

Example

<p>Author's About yourself biography: <?php the_author_description(); ?></p>

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_description"Category: Template Tags

Template Tags/the author email

Contents1 Description2 Usage3 Examples

3.1 Mailto Link3.2 Secure From Spammers

4 Parameters5 Related

Description

This tag displays the email address for the author of a post. The E-mail field is set in the user's profile (Administration > Profile > Your Profile).This tag must be used within The Loop.

Note that the address is not encoded or protected in any way from harvesting by spambots. For this, see the Secure From Spammersexample.

Usage

<?php the_author_email(); ?>

ExamplesMailto Link

Displays author email address as a "mailto" link.

<a href="mailto:<?php the_author_email(); ?>">Contact the author</a>

Secure From Spammers

This example partially 'obfuscates' address by using the internal function antispambot() to encode portions in HTML character entities (theseare read correctly by your browser). Note the example uses get_the_author_email() function, because the_author_email() echoes theaddress before antispambot() can act upon it.

<a href="mailto:<?php echo antispambot(get_the_author_email()); ?>">email author</a>

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Page 89: wp-api

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_email"Category: Template Tags

Template Tags/the author firstname

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

This tag displays the first name for the author of a post. The First Name field is set in the user's profile (Administration > Profile > Your Profile).This tag must be used within The Loop.

Usage

<?php the_author_firstname(); ?>

Example

<p>This post was written by <?php the_author_firstname(); ?></p>

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_firstname"Category: Template Tags

Template Tags/the author icq

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Example5 Parameters6 Related

Description

Displays the ICQ number for the author of a post. Prior to WordPress 2.0, the ICQ field was set in the user's profile, but the field is currently notaccessible in the Administration > Profile > Your Profile panel. This tag must be used within The Loop.

Replace With

No replacement exists for this template tag, as the field was removed from the Profile panel.

Usage

<?php the_author_icq(); ?>

Example

<p>Contact me on ICQ: <?php the_author_icq(); ?></p>

Page 90: wp-api

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_icq"Category: Template Tags

Template Tags/the author lastname

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

This tag displays the last name for the author of a post. The Last Name field is set in the user's profile (Administration > Profile > Your Profile).This tag must be used within The Loop.

Usage

<?php the_author_lastname(); ?>

Example

Displays author's first and last name.

<p>Post author: <?php the_author_firstname(); ?> <?php the_author_lastname(); ?></p>

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_lastname"Category: Template Tags

Template Tags/the author link

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

This tag displays a link to the Website for the author of a post. The Website field is set in the user's profile (Administration > Profile > YourProfile). The text for the link is the author's Profile Display name publicly as field. This tag must be used within The Loop.

Page 91: wp-api

Usage

<?php the_author_link(); ?>

Example

Displays the author's Website URL as a link and the text for the link is the author's Profile Display name publicly as field. In this example, theauthor's Display Name is James Smith.

<p>Written by: <?php the_author_link(); ?></p>

Which displays as:

Written by: James Smith

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_link"Category: Template Tags

Template Tags/the author login

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

This tag displays the login name of the author of a post. The login is also referred to as the Username an author uses to gain access to aWordPress blog. This tag must be used within The Loop.

Note: It's usually not a good idea to provide login information publicly.

Usage

<?php the_author_login(); ?>

Example

<p>Author username: <?php the_author_login(); ?></p>

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Page 92: wp-api

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_login"Category: Template Tags

Template Tags/the author msn

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Example5 Parameters6 Related

Description

Displays the MSN Messenger ID for the author of a post; Prior to WordPress 2.0, the MSN IM field was set in the user's profile, but this fieldhas since been removed in later versions.

This tag must be used within The Loop.

Replace With

No replacement exists for this template tag, as the field was removed from the Profile panel.

Usage

<?php the_author_msn(); ?>

Example

<p>Contact me on MSN: <?php the_author_msn(); ?></p>

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_msn"Category: Template Tags

Template Tags/the author nickname

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

This tag displays the nickname for the author of a post. The Nickname field is set in the user's profile (Administration > Profile > Your Profile).This tag must be used within The Loop.

Usage

<?php the_author_nickname(); ?>

Example

Page 93: wp-api

<p>Posted by <?php the_author_nickname(); ?></p>

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_nickname"Category: Template Tags

Template Tags/the author posts

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the total number of posts an author has published. Drafts and private posts aren't counted. This tag must be used within The Loop.

Usage

<?php the_author_posts(); ?>

Example

Displays the author's name and number of posts.

<p><?php the_author(); ?> has blogged <?php the_author_posts(); ?> posts</p>

Harriett Smith has blogged 425 posts.

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_posts"Category: Template Tags

Template Tags/the author posts link

Contents1 Description2 Usage3 Examples

3.1 Use Example4 Parameters5 Deprecated Parameters

Page 94: wp-api

6 Related

Description

Displays a link to all posts by an author. The link text is the user's Display name publicly as field. The results of clicking on the presented linkwill be controlled by the Template Hierarchy of Author Templates. This tag must be used within The Loop.

Usage

<?php the_author_posts_link(); ?>

ExamplesUse Example

Displays the link, where the default link text value is the user's Display name publicly as field.

<p>Other posts by <?php the_author_posts_link(); ?></p>

Parameters

This function takes no arguments.

Deprecated Parameters

idmode (string) Sets the element of the author's information to display for the link text.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_posts_link"Category: Template Tags

Template Tags/the author url

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

This tag displays the URL to the Website for the author of a post. The Website field is set in the user's profile (Administration > Profile > YourProfile). This tag must be used within The Loop.

Usage

<?php the_author_url(); ?>

Example

Displays the author's URL as a link and the link text.

<p>Author's web site: <a href="<?php the_author_url(); ?>"><?php the_author_url(); ?></a></p>

Which displays as:

Page 95: wp-api

Author's web site: www.example.com

This example displays the author's name as a link to the author's web site.

<?php if (get_the_author_url()) { ?><a href="<?php the_author_url(); ?>"><?php the_author(); ?></a><?php } else { the_author(); } ?>

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_url"Category: Template Tags

Template Tags/the author yim

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

This tag displays the Yahoo IM ID for the author of a post. The Yahoo IM field is set in the user's profile (Administration > Profile > Your Profile).This tag must be used within The Loop.

Usage

<?php the_author_yim(); ?>

Example

<p>Contact me on Yahoo Messenger: <?php the_author_yim(); ?></p>

Parameters

This tag does not accept any parameters.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_author_yim"Category: Template Tags

Template Tags/the category

Contents1 Description2 Usage3 Examples

3.1 Separated by Space3.2 Separated by Comma3.3 Separated by Arrow3.4 Separated by a Bullet

4 Parameters

Page 96: wp-api

5 Related

Description

Displays a link to the category or categories a post belongs to. This tag must be used within The Loop.

Usage

<?php the_category('separator', 'parents' ); ?>

ExamplesSeparated by Space

This usage lists categories with a space as the separator.

<p>Categories: <?php the_category(' '); ?></p>

Categories: WordPress Computers Blogging

Separated by Comma

Displays links to categories, each category separated by a comma (if more than one).

<p>This post is in: <?php the_category(', '); ?></p>

This post is in: WordPress, Computers, Blogging

Separated by Arrow

Displays links to categories with an arrow (>) separating the categories. (Note: Take care when using this, since some viewers may interpret acategory following a > as a subcategory of the one preceding it.)

<p>Categories: <?php the_category(' &gt; '); ?></p>

Categories: WordPress > Computers > Blogging

Separated by a Bullet

Displays links to categories with a bullet (•) separating the categories.

<p>Post Categories: <?php the_category(' &bull; '); ?></p>

Post Categories: WordPress • Computers • Blogging

Parameters

separator (string) Text or character to display between each category link. The default is to place the links in an unordered list.

parents (string) How to display links that reside in child (sub) categories. Options are:

'multiple' - Display separate links to parent and child categories, exhibiting "parent/child" relationship.'single' - Display link to child category only, with link text exhibiting "parent/child" relationship.

Note: Default is a link to the child category, with no relationship exhibited.

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags with PHP function-style parameters

Page 97: wp-api

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_category"Category: Template Tags

Template Tags/the category ID

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Example5 Parameters6 Related

Description

Displays or returns the numeric ID of the category a post belongs to. This tag must be used within The Loop.

Replace With

This tag was deprecated when multiple categories were added to WordPress, and there is no one-to-one correspondence with another tag.This PHP code block provides an example for how you can replace it:

<?php foreach((get_the_category()) as $category) { echo $category->cat_ID . ' '; } ?>

Usage

<?php the_category_ID(echo); ?>

Example

Displays a corresponding image for each category.

<img src="<?php the_category_ID(); ?>.gif" />

Parameters

echo (boolean) Display the category ID (TRUE) or return it for use in PHP (FALSE). Defaults to TRUE.

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_category_ID"Category: Template Tags

Template Tags/the category head

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents

Page 98: wp-api

1 Description2 Replace With3 Usage4 Example5 Parameters6 Related

Description

Displays the name of a category if it's different from the previous category. This tag must be used within The Loop.

Replace With

This tag was deprecated when multiple categories were added to WordPress, and there is no one-to-one correspondence with another tag.

To display the name of the category when on a category page, use:

<?php echo get_the_category_by_ID($cat); ?>

To display category name(s) on a single post page, this code block (which would need to run in The Loop) provides an example:

<?phpforeach(get_the_category() as $category) { echo $category->cat_name . ' '; }?>

Usage

<?php the_category_head('before', 'after'); ?>

Example

Displays the text "Category: " followed by the name of the category.

<h2><?php the_category_head('Category: '); ?></h2>

Parameters

before (string) Text to output before the category. Defaults to '' (no text).

after (string) Text to output after the category. Defaults to '' (no text).

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_category_head"Category: Template Tags

Template Tags/the category rss

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the name of the category or categories a post belongs to in RSS format. This tag must be used within The Loop.

Usage

Page 99: wp-api

<?php the_category_rss('type') ?>

Example

Fragment of an RSS2 feed page.

<?php the_category_rss() ?><guid><?php the_permalink($id); ?></guid>

Parameters

type (string) The type of feed to display to. Valid values:

'rss' (Default)'rdf'

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_category_rss"Categories: Template Tags | Feeds

Template Tags/the content

Contents1 Description2 Usage3 Examples

3.1 Designating the "More" Text3.2 Include Title in "More"3.3 Overriding Archive/Single Page Behavior

4 Parameters5 Related

Description

Displays the contents of the current post. This tag must be within The_Loop.

If the quicktag <!--more--> is used in a post to designate the "cut-off" point for the post to be excerpted, the_content() tag will only show theexcerpt up to the <!--more--> quicktag point on non-single/non-permalink post pages. By design, the_content() tag includes aparameter for formatting the <!--more--> content and look, which creates a link to "continue reading" the full post.

Note about <!--more--> :No whitespaces are allowed before the "more" in the <!--more--> quicktag. In other words <!-- more --> will not work!The <!--more--> quicktag will not operate and is ignored in Templates, such as single.php, where just one post is displayed.Read Customizing the Read More for more details.

Usage

<?php the_content('more_link_text', strip_teaser, 'more_file'); ?>

Alternatively, you may use this to return the content value instead of the normal echo:

<?php $content = get_the_content(); ?>

Please note! get_the_content will not have the following done to it and you are advised to add them until the core has been updated:

<?php$content = apply_filters('the_content', $content);$content = str_replace(']]>', ']]&gt;', $content);?>

ExamplesDesignating the "More" Text

Page 100: wp-api

Displays the content of the post and uses "Read more..." for the more link text when the <!--more--> Quicktag is used.

<?php the_content('Read more...'); ?>

Include Title in "More"

Similar to the above example, but thanks to the_title() tag and the display parameter, it can show "Continue reading ACTUAL POST TITLE"when the <!--more--> Quicktag is used.

<?php the_content("Continue reading " . the_title('', '', false)); ?>

Overriding Archive/Single Page Behavior

If the_content() isn't working as you desire (displaying the entire story when you only want the content above the <!--more--> Quicktag, forexample) you can override the behavior with global $more.

<?php // Declare global $more, before the loop.global $more;?>

<?php// Display content above the more tag$more = 0;the_content("More...");?>

Alternatively, if you need to display all of the content:

<?php // Declare global $more, before the loop.global $more;?>

<?php// Display all content, including text below more$more = 1;the_content();?>

note: in my case I had to set $more=0; INSIDE the loop for it to work.

Parameters

more_link_text (string) The link text to display for the "more" link. Defaults to '(more...)'.

strip_teaser (boolean) Should the text before the "more" link be hidden (TRUE) or displayed (FALSE). Defaults to FALSE.

more_file (string) File the "more" link points to. Defaults to the current file. (V2.0: Currently the 'more_file' parameter doesn't work).

Related

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_content"Category: Template Tags

Template Tags/the content rss

Contents1 Description2 Usage3 Examples

3.1 Default Usage

Page 101: wp-api

3.2 Hides Teaser Link and Limits Content4 Parameters5 Related

Description

Displays the content of the current post formatted for RSS. This tag must be within The_Loop.

This tag will display a "teaser" link to read more of a post, when on non-single/non-permalink post pages and the <!--more--> Quicktag isused.

Usage

<?php the_content_rss('more_link_text', strip_teaser, 'more_file', cut, encode_html); ?>

ExamplesDefault Usage

Displays the content in RSS format using defaults.

<?php the_content_rss(); ?>

Hides Teaser Link and Limits Content

Displays the content in RSS format, hides the teaser link and cuts the content after 50 words.

<?php the_content_rss('', TRUE, '', 50); ?>

Parameters

more_link_text (string) Link text to display for the "more" link. Defaults to '(more...)'.

strip_teaser (boolean) Should the text before the "more" link be hidden (TRUE) or displayed (FALSE). Defaults to FALSE.

more_file (string) File which the "more" link points to. Defaults to the current file.

cut (integer) Number of words displayed before ending content. Default is 0 (display all).

encode_html (integer) Defines html tag filtering and special character (e.g. '&') encoding. Options are:

0 - (Default) Parses out links for numbered "url footnotes".1 - Filters through the PHP function htmlspecialchars(), but also sets cut to 0, so is not recommended when using the cutparameter.2 - Strips html tags, and replaces '&' with HTML entity equivalent (&amp;). This is the default when using the cut parameter.

Related

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_content_rss"Categories: Template Tags | Feeds

Template Tags/the date

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Date as Year, Month, Date in Heading3.3 Date in Heading Using $my_date Variable

4 Parameters5 Related

Description

Displays or returns the date of a post, or a set of posts if published on the same day.

SPECIAL NOTE: When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the firstpost (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tagthe_time() with a date-specific format string.

Page 102: wp-api

This tag must be used within The Loop.

Usage

<?php the_date('format', 'before', 'after', echo); ?>

ExamplesDefault Usage

Displays the date using defaults.

<p>Date posted: <?php the_date(); ?></p>

Date as Year, Month, Date in Heading

Displays the date using the '2007-07-23' format (ex: 2004-11-30), inside an <h2> tag.

<?php the_date('Y-m-d', '<h2>', '</h2>'); ?>

Date in Heading Using $my_date Variable

Returns the date in the default format inside an <h2> tag and assigns it to the $my_date variable. The variable's value is then displayed withthe PHP echo command.

<?php $my_date = the_date('', '', '', FALSE); echo $my_date; ?>

Parameters

format (string) The format for the date. Defaults to the date format configured in your WordPress options. See Formatting Date and Time.

before (string) Text to place before the date. There is no default.

after (string) Text to place after the date. There is no default.

echo (boolean) Display the date (TRUE), or return the date to be used in PHP (FALSE). Defaults to TRUE.

Related

the_date_xml, the_date, the_time, the_modified_date, the_modified_time, get_the_time, single_month_title, get_calendar, the_weekday,the_weekday_date

Affects the return value of the is_new_day() function.

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_date"Category: Template Tags

Template Tags/the date xml

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the date of the post in YYYY-MM-DD format (ex: 2004-09-24). This tag must be used within The Loop.

Usage

<?php the_date_xml(); ?>

Example

Page 103: wp-api

<p>Date posted: <?php the_date_xml(); ?></p>

Date posted: 2005-05-14

Parameters

This tag does not accept any parameters.

Related

the_date_xml, the_date, the_time, the_modified_date, the_modified_time, get_the_time, single_month_title, get_calendar, the_weekday,the_weekday_date

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_date_xml"Category: Template Tags

Template Tags/the excerpt

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Use with Conditional Tags

4 Parameters5 Comparison of the_excerpt() vs. the_content()6 Related

Description

Displays the excerpt of the current post with [...] at the end, which is not a "read more" link. If you do not provide an explicit excerpt to a post (inthe post editor's optional excerpt field), it will display a teaser which refers to the first 55 words of the post's content. Also in the latter case,HTML tags and graphics are stripped from the excerpt's content. This tag must be within The Loop.

If the current post is an attachment, such as in the attachment.php and image.php template loops, then the attachment caption is displayed.Captions do not include the excerpt [...] marks.

Usage

<?php the_excerpt(); ?>

ExamplesDefault Usage

Displays the post excerpt. Used on non-single/non-permalink posts as a replacement for the_content() to force excerpts to show within theLoop.

<?php the_excerpt(); ?>

Use with Conditional Tags

Replaces the_content() tag with the_excerpt() when on archive (tested by is_archive()) or category (is_category()) pages.

Both the examples below work for versions 1.5 and above.

<?php if(is_category() || is_archive()) { the_excerpt(); } else { the_content(); } ?>

For versions of WordPress prior to 1.5, only the following will work :

<?php if($cat || $m) { the_excerpt(); } else { the_content();

Page 104: wp-api

} ?>

Parameters

This tag has no parameters.

Comparison of the_excerpt() vs. the_content()

Sometimes is more meaningful to use only the_content() function. the_content() will decide what to display according to whether<!--more--> tag was used.

<!--more--> tag splits post/page into two parts: only content before tag should be displayed in listing.

Remember that <!--more--> is (of course) ignored when showing only post/page (singles).

Related

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_excerpt"Categories: Template Tags | UI Link

Template Tags/the excerpt rss

Contents1 Description2 Usage3 Example4 Parameters

4.1 Parameters for 1.25 Related

Description

Displays the excerpt of the current post formatted for RSS.If you do not provide an explicit excerpt to a post (in the post editor's optionalexcerpt field), the first 55 words of the post's content are used. This tag must be within The_Loop.

For finer control over output, see the_content_rss().

Usage

<?php the_excerpt_rss(); ?>

See Parameters for 1.2 for arguments available in that version.

Example

Displays the post's excerpt, or the first 120 words of the post's content when no excerpt exists, formatted for RSS syndication.

<description><?php the_excerpt_rss(); ?></description>

Parameters

This tag has no parameters.

Parameters for 1.2

WordPress version 1.5 does not support parameters for this tag. The following information is retained for the benefit of 1.2 users.

Usage: <?php the_excerpt_rss(cut, encode_html); ?>

Parameters:

cut (integer) Number of words to display before ending the excerpt. Can be any numeric value up to the default.

encode_html (integer) Defines html tag filtering and special character (e.g. '&') encoding. Options are:

0 - (Default) Parses out links for numbered "url footnotes".1 - Filters through the PHP function htmlspecialchars(), but also sets cut to 0, so is not recommended when using the cut

Page 105: wp-api

parameter.2 - Strips html tags, and replaces '&' with HTML entity equivalent (&amp;). This is the default when using the cut parameter.

Related

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_excerpt_rss"Categories: Template Tags | Feeds

Template Tags/the meta

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays an unordered list of meta "key:value" pairs, or the post-meta, for the current post. Must be used from within The_Loop. For moreinformation on this tag, see Using_Custom_Fields.

Usage

<?php the_meta(); ?>

Example

<p>Meta information for this post:</p><?php the_meta(); ?>

Parameters

This tag has no parameters.

Related

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_meta"Category: Template Tags

Template Tags/the modified author

Contents1 Description2 Usage3 Examples

3.1 Display Last Modified Author's 'Public' Name4 Parameters5 Related

Description

The author who last modified a post can be displayed by using this Template Tag. This tag must be used within The Loop. Note:the_modified_author was first available with Version 2.8.

Usage

<?php the_modified_author(); ?>

Page 106: wp-api

ExamplesDisplay Last Modified Author's 'Public' Name

Displays the value in the user's Display name publicly as field.

<p>This post was written by <?php the_modified_author(); ?></p>

Parameters

This function takes no arguments.

Related

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_modified_author"Category: Template Tags

Template Tags/the modified date

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Date as Month Day, Year3.3 Date and Time

4 Parameters5 Related

Description

This tag displays the date (and time) a post was last modified. This tag works just like the_modified_time(), which also displays the time/date apost was last modified. This tag must be used within The Loop. If no format parameter is specified, the Default date format (please note thatsays Date format) setting from Administration > Settings > General is used for the display format.

If the post or page is not yet modified, the modified date is the same as the creation date.

Usage

<?php the_modified_date('d'); ?>

ExamplesDefault Usage

Displays the date the post was last modified, using the Default date format setting (e.g. F j, Y) from Administration > Settings > General.

<p>Last modified: <?php the_modified_date(); ?></p>

Last modified: December 2, 2006

Date as Month Day, Year

Displays the last modified date in the date format 'F j, Y' (ex: December 2, 2006).

<div>Last modified: <?php the_modified_date('F j, Y'); ?></div>

Last modified: December 2, 2006

Date and Time

Page 107: wp-api

Displays the date and time.

<p>Modified: <?php the_modified_date('F j, Y'); ?> at <?php the_modified_date('g:i a'); ?></p>

Modified: December 2, 2006 at 10:36 pm

Parameters

d (string) The format the date is to display in. Defaults to the date format configured in your WordPress options. See Formatting Date andTime.

Related

the_date_xml, the_date, the_time, the_modified_date, the_modified_time, get_the_time, single_month_title, get_calendar, the_weekday,the_weekday_date

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_modified_date"Categories: Template Tags | New page created

Template Tags/the modified time

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Time in the 12-hour format (am/pm)3.3 Time in the 24-hour format3.4 Date as Month Day, Year3.5 Date and Time

4 Parameters5 Related

Description

This tag displays the time (and date) a post was last modified and is similar to the functionality of the_time(), which displays the time (and date)a post was created. This tag must be used within The Loop. If no format parameter is specified, the Default date format (please note that saysDate format) setting from Administration > Settings > General is used for the display format.

If the post or page is not yet modified, the modified time is the same as the creation time.

If you want to display both the modified time and the creation time, you may want to use an if statement (e.g. if(get_the_modified_time() != get_the_time())) to avoid showing the same time/date twice.

Usage

<?php the_modified_time('d'); ?>

ExamplesDefault Usage

Displays the time (date) the post was last modified, using the Default date format setting (e.g. F j, Y) from Administration > Settings >General.

<p>Last modified: <?php the_modified_time(); ?></p>

Last modified: December 2, 2006

Time in the 12-hour format (am/pm)

If a post was modified at 10:36pm, this example displays the time the post was last modified using the 12-hour format parameter string 'g:i

Page 108: wp-api

a'.

<p>Time last modified: <?php the_modified_time('g:i a'); ?></p>

Time last modified: 10:36 pm

Time in the 24-hour format

If a post was modified at 10:36pm, this example displays the time the post was last modified using the 24-hour format parameter string 'G:i'.

<p>Time last modified: <?php the_modified_time('G:i'); ?></p>

Time last modified: 22:36

Date as Month Day, Year

Displays the last modified time and date in the date format 'F j, Y' (ex: December 2, 2006), which could be used to replace the tagthe_modified_date().

<div>Last modified: <?php the_modified_time('F j, Y'); ?></div>

Last modified: December 2, 2006

Date and Time

Displays the date and time.

<p>Modified: <?php the_modified_time('F j, Y'); ?> at <?php the_modified_time('g:i a'); ?></p>

Modified: December 2, 2006 at 10:36 pm

Parameters

d (string) The format the time is to display in. Defaults to the date format configured in your WordPress options. See Formatting Date andTime.

Related

the_date_xml, the_date, the_time, the_modified_date, the_modified_time, get_the_time, single_month_title, get_calendar, the_weekday,the_weekday_date

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_modified_time"Categories: Template Tags | New page created

Template Tags/the permalink

Contents1 Description2 Usage3 Examples

3.1 Display Post URL as Text3.2 As Link With Text3.3 Used as Link With Title Tag

4 Parameters5 Related

Description

Displays the URL for the permalink to the post currently being processed in The Loop. This tag must be within The Loop, and is generally used

Page 109: wp-api

to display the permalink for each post, when the posts are being displayed. Since this template tag is limited to displaying the permalink for thepost that is being processed, you cannot use it to display the permalink to an arbitrary post on your weblog. Refer to get_permalink() if youwant to display the permalink for a post, given its unique post id.

Usage

<?php the_permalink(); ?>

ExamplesDisplay Post URL as Text

Displays the URL to the post, without creating a link:

This address for this post is: <?php the_permalink(); ?>

As Link With Text

You can use whatever text you like as the link text, in this case, "permalink".

<a href="<?php the_permalink(); ?>">permalink</a>

Used as Link With Title Tag

Creates a link for the permalink, with the post's title as the link text. This is a common way to put the post's title.

<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>

Parameters

This tag has no parameters.

Related

To generate the permalink for a single, specific post, see get_permalink.

permalink_anchor, get_permalink, the_permalink, permalink_single_rss

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_permalink"Category: Template Tags

Template Tags/the search query

Contents1 Description2 Usage3 Examples

3.1 Show search query in search box3.2 Show search query in results page

4 Related

Description

Displays the search query for the current request, if a search was made.

This function can be used safely within HTML attributes (as in the "search box" example, below).

Usage

<?php the_search_query(); ?>

ExamplesShow search query in search box

If you have just performed a search, you can show the last query in the search box:

Page 110: wp-api

<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/"> <div> <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" /> <input type="submit" id="searchsubmit" value="Search" /> </div></form>

Show search query in results page

You can display the search string on search result pages

<p>You searched for \" <?php the_search_query() ?>\". Here are the results:</p>

Related

get_search_query functionget_search_query filter

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_search_query"Categories: Template Tags | New page created

Template Tags/the tags

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Separated by Arrow3.3 Separated by a Bullet3.4 A List Example3.5 Integrating Categories and Tags

4 Parameters5 Related

Description

First available with WordPress Version 2.3, this template tag displays a link to the tag or tags a post belongs to. If no tags are associated withthe current entry, the associated category is displayed instead. This tag should be used within The Loop.

Usage

<?php the_tags('before', 'separator', 'after'); ?>

Examples

Displays a list of the tags with a linebreak after it. <?php the_tags('Tags:', ', ', '<br />'); ?>

Default Usage

The default usage lists tags with each tag (if more than one) separated by a comma (,) and preceded with the default text Tags: .

<p><?php the_tags(); ?></p>

Tags: WordPress, Computers, Blogging

Separated by Arrow

Displays links to tags with an arrow (>) separating the tags and preceded with the text Social tagging:

<?php the_tags('Social tagging: ',' > '); ?>

Page 111: wp-api

Social tagging: WordPress > Computers > Blogging

Separated by a Bullet

Displays links to tags with a bullet (•) separating the tags and preceded with the text Tagged with: and followed by a line break.

<?php the_tags('Tagged with: ',' &bull; ','<br />'); ?>

Tagged with: WordPress • Computers • Blogging

A List Example

Displays a list of the tags as a real and simple (X)HTML list (<ul> / <ol> / <dl> ):

<?php the_tags('<ul><li>','</li><li>','</li></ul>');?>

WordPressComputersBlogging

Integrating Categories and Tags

If you have existing posts associated with categories, and have started adding tags to posts as well, you may want to show an integrated list ofcategories and tags beneath each post. For example, assume you have pre-existing categories called Culture and Media, and have added tagsto a post "Arts" and "Painting". To simplify the reader's experience and keep things uncluttered, you may want to display these as if they wereall tags:

Tags: Culture, Media, Arts, Painting

This code will get you there, and will only render categories or tags if they're non-empty for the current post:

Tags:<?php if (the_category(', ')) the_category(); ?><?php if (get_the_tags()) the_tags(); ?>

Parameters

before (string) Text to display before the actual tags are displayed. Defaults to Tags:

separator (string) Text or character to display between each tag link. The default is a comma (,) between each tag.

after (string) Text to display after the last tag. The default is to display nothing.

Related

the_tags, get_the_tags, get_the_tag_list, single_tag_title, get_tag_link, wp_tag_cloud, wp_generate_tag_cloud

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Page 112: wp-api

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Template_Tags/the_tags"Categories: Template Tags | Stubs

Template Tags/the time

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Time as AM/PM VS. 24H format3.3 Date as Month Day, Year3.4 Date and Time

4 Parameters5 Related

Description

Displays the time of the current post. This tag must be used within The Loop.

Usage

<?php the_time('d'); ?>

ExamplesDefault Usage

Displays the time using your WordPress defaults.

Time posted: <?php the_time(); ?>

Time as AM/PM VS. 24H format

Displays the time using the format parameter string '09:18 am' (ex: 10:36 pm).

<p>Time posted: <?php the_time('g:i a'); ?></p>

--

Displays the time using the 24 hours format parameter string 'G:i' (ex: 17:52).

<p>Time posted: <?php the_time('G:i'); ?></p>

Date as Month Day, Year

Displays the time in the date format 'F j, Y' (ex: December 2, 2004), which could be used to replace the tag the_date().

<div><?php the_time('F j, Y'); ?></div>

Date and Time

Displays the date and time.

<p>Posted: <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?></p>

Posted: July 17, 2007 at 7:19 am

Parameters

d (string) The format the time is to display in. Defaults to the time format configured in your WordPress options. See Formatting Date andTime.

Related

the_date_xml, the_date, the_time, the_modified_date, the_modified_time, get_the_time, single_month_title, get_calendar, the_weekday,the_weekday_date

Page 113: wp-api

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_time"Category: Template Tags

Template Tags/the title

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays or returns the title of the current post. This tag must be within The Loop.

Usage

<?php the_title('before', 'after', display); ?>

Example

<?php the_title('<h3>', '</h3>'); ?>

Parameters

before (string) Text to place before the title. Defaults to ''.

after (string) Text to place after the title. Defaults to ''.

display (Boolean) Display the title (TRUE) or return it for use in PHP (FALSE). Defaults to TRUE.

Related

See also the_title_attribute().

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_title"Category: Template Tags

Template Tags/the title attribute

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays or returns the title of the current post. It somewhat duplicates the functionality of the_title(), but provides a 'clean' version of the title bystripping HTML tags and converting certain characters (including quotes) to their character entity equivalent; it also uses query-string styleparameters. This tag must be within The Loop.

Page 114: wp-api

Usage

<?php the_title_attribute('arguments'); ?>

Example

<?php the_title_attribute('before=<h3>&after=</h3>'); ?>

Parameters

before (string) Text to place before the title. Defaults to ''.

after (string) Text to place after the title. Defaults to ''.

echo (Boolean) Echo the title (1) or return it for use in PHP (0). Defaults to 1.

Related

See also the_title().

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_title_attribute"Categories: Template Tags | New page created

Template Tags/the title rss

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays the title of the current post, formatted for RSS. This tag must be within The Loop.

Usage

<?php the_title_rss(); ?>

Example

Displays the post title in an RSS title tag.

<item> <title><?php the_title_rss(); ?></title>

Parameters

This tag has no parameters.

Related

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss,previous_post_link, next_post_link, posts_nav_link, the_meta,

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_title_rss"Categories: Template Tags | Feeds

Page 115: wp-api

Template Tags/the weekday

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Example5 Parameters6 Related

Description

Displays the day of the week (e.g. Friday). This tag must be used within The Loop.

Replace With

To replace this tag, use the_time() with 'l' as the format string:

<?php the_time('l'); ?>

See Formatting Date and Time for information on date and time format string use.

Usage

<?php the_weekday() ?>

Example

<p>This was posted on a <?php the_weekday() ?>.</p>

Parameters

This tag does not accept any parameters.

Related

the_date_xml, the_date, the_time, the_modified_date, the_modified_time, get_the_time, single_month_title, get_calendar, the_weekday,the_weekday_date

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_weekday"Category: Template Tags

Template Tags/the weekday date

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Example5 Parameters6 Related

Description

Displays the weekday of the current post (e.g. Friday) only if it is different from the weekday of the previous post. This tag must be used withinThe Loop.

Replace With

Page 116: wp-api

There is one-to one correspondence with another template tag, so to replace, use the_date() as a trigger and the_time() with 'l' (lowercaseletter L) as the format string, as shown in this PHP code block:

<?php if(the_date('','','', FALSE)) the_time('l'); ?>

See Formatting Date and Time for information on date and time format string use.

Usage

<?php the_weekday_date('before', 'after') ?>

Example

<p>Posts from <?php the_weekday_date('<strong>', '</strong>') ?>:</p>

Parameters

before (string) Text placed before the tag's output. There is no default.

after (string) Text placed after the tag's output. There is no default.

Related

the_date_xml, the_date, the_time, the_modified_date, the_modified_time, get_the_time, single_month_title, get_calendar, the_weekday,the_weekday_date

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/the_weekday_date"Category: Template Tags

Template Tags/trackback rdf

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Outputs the trackback RDF information for a post. This tag must be within The Loop.

This information is not displayed in a browser. Its use is partly intended for auto-detection of the trackback URI to a post, which can be"trackbacked" by some blogging and RDF tools. Include this tag in your template if you want to enable auto-discovery of the trackback URI fora post. Without it, people who wish to send a trackback to one of your posts will have to manually search for the trackback URI.

Usage

<?php trackback_rdf(); ?>

Example

Displays the RDF information before the end of The Loop. You should wrap the tag in an HTML comment tag, to avoid issues with validation.

<!--<?php trackback_rdf(); ?>-->

<?php endforeach; else: ?>

Parameters

This tag has no parameters.

Related

Page 117: wp-api

trackback_url, trackback_rdf

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/trackback_rdf"Category: Template Tags

Template Tags/trackback url

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Displays or returns the trackback URL for the current post. This tag must be within The Loop.

A trackback URL is where somebody posts a link to their site on your site. In return, they have posted a link to your site on their site and havecopied an article you have written.

Usage

<?php trackback_url(display); ?>

Example

<p>Trackback URL for this post: <?php trackback_url(); ?></p>

Parameters

display (boolean) Display the URL (TRUE), or to return it for use in PHP (FALSE). Defaults to TRUE.

Related

trackback_url, trackback_rdf

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/trackback_url"Category: Template Tags

Template Tags/wp dropdown categories

This article is marked as in need of editing. You can help Codex by editing it.

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Dropdown with Submit Button3.3 Dropdown without a Submit Button using JavaScript3.4 Dropdown without a Submit Button using JavaScript (2)

4 Parameters5 Related

Description

Displays a list of categories in a select (i.e dropdown) box with no submit button.

Usage

Page 118: wp-api

<?php wp_dropdown_categories('arguments'); ?>

ExamplesDefault Usage

$defaults = array('show_option_all' => '', 'show_option_none' => '', 'orderby' => 'ID', 'order' => 'ASC', 'show_last_update' => 0, 'show_count' => 0, 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1, 'selected' => 0, 'hierarchical' => 0, 'name' => 'cat', 'class' => 'postform', 'depth' => 0);

By default, the usage shows:

Sorts by category id in ascending orderDoes not show the last date updatedDoes not show the count of posts within a categoryDoes not show 'empty' categoriesExcludes nothingDisplays (echos) the categoriesNo category is 'selected' in the formDoes not display the categories in a hierarchical structureAssigns 'cat' to the form nameAssigns the form to the class 'postform'No depth limit

<?php wp_dropdown_categories(); ?>

Dropdown with Submit Button

Displays a hierarchical category dropdown list in HTML form with a submit button, in a WordPress sidebar unordered list, with a count of postsin each category.

<li id="categories"> <h2><?php _e('Categories:'); ?></h2> <form action="<?php bloginfo('url'); ?>" method="get"> <?php wp_dropdown_categories('show_count=1&hierarchical=1'); ?> <input type="submit" name="submit" value="view" /> </form></li>

Dropdown without a Submit Button using JavaScript

Example depicts using the show_option_none parameter and was gleaned from Moshu's forum post.

<li id="categories"><h2><?php _e('Posts by Category'); ?></h2><?php wp_dropdown_categories('show_option_none=Select category'); ?>

<script type="text/javascript"><!-- var dropdown = document.getElementById("cat"); function onCatChange() {

if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {location.href = "<?php echo get_option('home');

?>/?cat="+dropdown.options[dropdown.selectedIndex].value;}

} dropdown.onchange = onCatChange;--></script></li>

Dropdown without a Submit Button using JavaScript (2)

In this example the echo parameter (echo=0) is used. A simple preg_replace inserts the JavaScript code. It even works without JavaScript(submit button is wrapped by noscript tags).

<li id="categories"><h2><?php _e('Posts by Category'); ?></h2><form action="<?php bloginfo('url'); ?>/" method="get">

<?php$select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0');$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);echo $select;

Page 119: wp-api

?><noscript><input type="submit" value="View" /></noscript></form>

</li>

Parameters

show_option_all (string) Causes the HTML for the dropdown to allow you to select All of the categories.

show_option_none (string) Causes the HTML for the dropdown to allow you to select NONE of the categories.

orderby (string) Key to sort options by. Valid values:

'ID' (Default)'name'

order (string) Sort order for options. Valid values:

'ASC' (Default)'DESC'

show_last_update (boolean) Sets whether to display the date of the last post in each category. Valid values:

1 (True)0 (False - Default)

show_count (boolean) Sets whether to display a count of posts in each category. Valid values:

1 (True)0 (False - Default)

hide_empty (boolean) Sets whether to hide (not display) categories with no posts. Valid values:

1 (True - Default)0 (False)

child_of (integer) Only display categories that are children of the category identified by its ID. There is no default for this parameter.

exclude (string) Comma separated list of category IDs to exclude. For example, 'exclude=4,12' means category IDs 4 and 12 will NOT bedisplayed/echoed or returned. Defaults to exclude nothing.

echo (boolean) Display bookmarks (TRUE) or return them for use by PHP (FALSE). Defaults to TRUE.

1 (True - default)0 (False)

selected (integer) Category ID of the category to be 'selected' or presented in the display box. Defaults to no category selected.

hierarchical (boolean) Display categories in hierarchical fashion (child categories show indented). Defaults to FALSE.

1 (True)0 (False - Default)

name (string) Name assigned to the dropdown form. Defaults to 'cat'.

class (string) Class assinged to the dropdown form. Defaults to 'postform'.

depth (integer) This parameter controls how many levels in the hierarchy of Categories are to be included in the list of Categories. The defaultvalue is 0 (display all Categories and their children). This parameter added at Version 2.5

0 - All Categories and child Categories (Default).-1 - All Categories displayed in flat (no indent) form (overrides hierarchical).1 - Show only top level Categoriesn - Value of n (some number) specifies the depth (or level) to descend in displaying Categories

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

Page 120: wp-api

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_dropdown_categories"Categories: Copyedit | Template Tags | New page created

Template Tags/wp dropdown pages

This article is marked as in need of editing. You can help Codex by editing it.

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Dropdown with Submit Button

4 Parameters5 Other Parameters6 Related

Description

Displays a list of pages in a select (i.e dropdown) box with no submit button.

Usage

<?php wp_dropdown_pages('arguments'); ?>

ExamplesDefault Usage

$defaults = array( 'depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'show_option_none' => '');

By default, the usage shows:

Pages and sub-pages displayed in hierarchical (indented) formDisplays all pages (not restricted to child pages)No page is be 'selected' or presented in the display boxThe name assigned to the dropdown form is 'page_id'Allows you to select NONE of the pages (show_option_none)

<?php wp_dropdown_pages(); ?>

Dropdown with Submit Button

Displays a hierarchical page dropdown list in HTML form with a submit button.

<li id="pages"> <h2><?php _e('pages:'); ?></h2> <form action="<?php bloginfo('url'); ?>" method="get"> <?php wp_dropdown_pages(); ?> <input type="submit" name="submit" value="view" /> </form></li>

Parameters

depth (integer)This parameter controls how many levels in the hierarchy of pages are to be included in the list generated by wp_list_pages. Thedefault value is 0 (display all pages, including all sub-pages).

0 - Pages and sub-pages displayed in hierarchical (indented) form (Default).

Page 121: wp-api

-1 - Pages in sub-pages displayed in flat (no indent) form.1 - Show only top level Pages2 - Value of 2 (or greater) specifies the depth (or level) to descend in displaying Pages.

child_of (integer)Displays the sub-pages of a single Page only; uses the ID for a Page as the value. Defaults to 0 (displays all Pages).

selected (integer) Page ID of the page to be 'selected' or presented in the display box. Defaults to no page selected.

echo (boolean)Toggles the display of the generated list of links or return the list as an HTML text string to be used in PHP. The default value is 1(display the generated list items). Valid values:

1 (true) - default0 (false)

name (string) Name assigned to the dropdown form. Defaults to 'page_id'.

show_option_none (string) Causes the HTML for the dropdown to allow you to select NONE of the pages.

exclude (string) Comma separated list of category IDs to exclude. For example, 'exclude=4,12' means category IDs 4 and 12 will NOT bedisplayed/echoed or returned. Defaults to exclude nothing.

exclude_tree (string)Define a comma-separated list of parent Page IDs to be excluded. Use this parameter to exclude a parent and all of that parent's childPages. So 'exclude_tree=5' would exclude the parent Page 5, and its child Pages. This parameter was available at Version 2.7.

Other Parameters

It is possible, but not confirmed, some of the paramters for the function get_pages could be used for wp_dropdown_pages. Here's the defaultsettings for the get_pages parameters

$defaults = array( 'child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => '' 'exclude_tree => '');

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_dropdown_pages"Categories: Copyedit | Template Tags | New page created

Template Tags/wp generate tag cloud

Returns an HTML string that makes a tag cloud.

Synopsis

string $html = wp_generate_tag_cloud( array $tags, array|string $args = '' )

Default arguments

Page 122: wp-api

$defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC');

Related

Called by wp_tag_cloud() and takes input from get_tags().

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_generate_tag_cloud"Category: Template Tags

Template Tags/wp get archives

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Last Twelve Months3.3 Last Fifteen Days3.4 Last Twenty Posts3.5 Dropdown Box

4 Parameters5 Related

Description

This function displays a date-based archives list in the same way as get_archives(). The only difference is that parameter arguments are givento the function in query string format. This tag can be used anywhere within a template.

Usage

<?php wp_get_archives('arguments'); ?>

ExamplesDefault Usage

<?php $defaults = array( 'type' => 'monthly', 'limit' => , 'format' => 'html', 'before' => , 'after' => , 'show_post_count' => false); ?>

By default, the usage shows:

Monthly archives links displayedDisplays all archives (not limited in number)Displays archives in an <li> HTML listNothing displayed before or after each linkDoes not display the count of the number of posts

Last Twelve Months

Displays archive list by month, displaying only the last twelve.

<?php wp_get_archives('type=monthly&limit=12'); ?>

Last Fifteen Days

Displays archive list by date, displaying only the last fifteen days.

<?php wp_get_archives('type=daily&limit=15'); ?>

Last Twenty Posts

Displays archive list of the last twenty most recent posts listed by post title.

<?php wp_get_archives('type=postbypost&limit=20&format=custom'); ?>

Page 123: wp-api

Dropdown Box

Displays a dropdown box of Monthly archives, in select tags, with the post count displayed.<select name=\"archive-dropdown\" onChange='document.location.href=this.options[this.selectedIndex].value;'> <option value=\"\"><?php echo attribute_escape(__('Select Month')); ?></option> <?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select>

Parameters

type (string) The type of archive list to display. Defaults to WordPress settings. Valid values:

yearlymonthly (Default)dailyweeklypostbypost

limit (integer) Number of archives to get. Default is no limit.

format (string) Format for the archive list. Valid values:

html - In HTML list (<li>) tags and before and after strings. This is the default.option - In select (<select>) or dropdown option (<option>) tags.link - Within link (<link>) tags.custom - Custom list using the before and after strings.

before (string) Text to place before the link when using the html or custom for format option. There is no default.

after (string) Text to place after the link when using the html or custom for format option. There is no default.

show_post_count (boolean) Display number of posts in an archive (1 - true) or do not (0 - false). For use with all type except 'postbypost'. Defaults to0.

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_get_archives"Category: Template Tags

Template Tags/wp get links

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Examples

4.1 Links by Category Number4.2 Include Before and After Text

5 Parameters6 Related

Description

Displays links associated with a numeric link category ID. This tag uses the settings you specify in the Links Manager (pre-WordPress 2.1only). For control over the formatting and display of your links within the tag's parameters, see get_links().

Page 124: wp-api

Replace With

wp_list_bookmarks() accepts one or more numeric link categories through the 'category' parameter.

Usage

<?php wp_get_links(category); ?>

ExamplesLinks by Category Number

Show links for link category 1.

<?php wp_get_links(1); ?>

Include Before and After Text

Mimic the behavior of get_links_list() but do respect the "Before Link", "Between Link and Description", and "After Link" settings definedfor Link Categories in the Links Manager.

Parameters

category (integer) The numeric ID of the link category whose links will be displayed. You must select a link category, if none is selected it willgenerate an error.

Related

get_links_list, wp_get_links, get_links, wp_get_linksbyname, get_linksbyname, wp_list_bookmarks, get_bookmarks, get_bookmark

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_get_links"Category: Template Tags

Template Tags/wp get linksbyname

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Examples

4.1 Default Usage5 Parameters

5.1 category5.2 arguments

6 Related

Description

Displays links associated with the named link category. This tag uses the settings you specify in the Links Manager. For control over theformatting and display of your links within the tag's parameters, see get_linksbyname().

Replace With

wp_list_bookmarks().

Usage

<?php wp_get_linksbyname('category','arguments'); ?>

Examples

Page 125: wp-api

Default Usage

By default, the tag shows:

All categories if none are specifiedAll category links are shownPuts a line break after the link itemPuts a space between the image and link (if one is included)Shows link images if availableList sorted by IDShows the link descriptionDoes not show the ratingWith no limit listed, it shows all linksDoes not show the updated timestamp

<?php wp_get_linksbyname(); ?>

List all links in the Link Category called "Favorites".

<?php wp_get_linksbyname('Favorites') ?>

List all links in the Link Category Blogroll, order the links by name, don't show the description, and show last update timestamp.

<?php wp_get_linksbyname('Blogroll','orderby=name&show_description=0&show_updated=1') ?>

Parameterscategory

category (string) The name of the category whose links will be displayed. No default.

arguments

before (string) Text to place before each link. There is no default.

after (string) Text to place after each link. Defaults to '<br />'.

between (string) Text to place between each link/image and its description. Defaults to ' ' (space).

show_images (boolean) Should images for links be shown.

1 (True - default)0 (False)

orderby (string) Value to sort links on. Valid options:

'id' (default)'url''name''target''category''description''owner' - User who added link through Links Manager.'rating''updated''rel' - Link relationship (XFN).'notes''rss''length' - The length of the link name, shortest to longest.

Prefixing any of the above options with an underscore (ex: '_id') sorts links in reverse order.'rand' - Display links in random order.

show_description (boolean) Display the description. Valid if show_images is FALSE or an image is not defined.

1 (True - default)0 (False)

show_rating (boolean) Should rating stars/characters be displayed.

1 (True)

Page 126: wp-api

0 (False - default)

limit (integer) Maximum number of links to display. Defaults to -1 (all links).

show_updated (boolean) Should the last updated timestamp be displayed.

1 (True)0 (False - default)

echo (boolean) Display the Links list (1 - true) or return the list to be used in PHP (0 - false). Defaults to 1.

1 (True - default)0 (False)

Related

get_links_list, wp_get_links, get_links, wp_get_linksbyname, get_linksbyname, wp_list_bookmarks, get_bookmarks, get_bookmark

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_get_linksbyname"Category: Template Tags

Template Tags/wp link pages

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Page-links in Paragraph Tags3.3 Page-links in DIV

4 Parameters5 Related

Description

Displays page-links for paginated posts (i.e. includes the <!--nextpage--> Quicktag one or more times). This works in much the same wayas link_pages(), the difference being that arguments are given in query string format. This tag must be within The_Loop.

Usage

<?php wp_link_pages('arguments'); ?>

ExamplesDefault Usage

Displays page-links by default with paragraph tags before and after, using Next page and Previous page, listing them with page numbers asPage 1, Page 2 and so on.

<?php wp_link_pages(); ?>

Page-links in Paragraph Tags

Displays page-links wrapped in paragraph tags.

<?php wp_link_pages('before=<p>&after=</p>&next_or_number=number&pagelink=page %'); ?>

Page-links in DIV

Displays page-links in DIV for CSS reference as <div id="page-links">.

<?php wp_link_pages('before=<div id="page-links">&after=</div>'); ?>

Parameters

Page 127: wp-api

before (string) Text to put before all the links. Defaults to <p>Pages:.

after (string) Text to put after all the links. Defaults to </p>.

link_before (string) Text that goes before the text of the link. Defaults to (blank). Version 2.7 or later required.

link_after (string) Text that goes after the text of the link. Defaults to (blank). Version 2.7 or later required.

next_or_number (string) Indicates whether page numbers should be used. Valid values are:

number (Default)next (Valid in WordPress 1.5 or after)

nextpagelink (string) Text for link to next page. Defaults to Next page. (Valid in WordPress 1.5 or after)

previouspagelink(string) Text for link to previous page. Defaults to Previous page. (Valid in WordPress 1.5 or after)

pagelink (string) Format string for page numbers. % in the string will be replaced with the number, so Page % would generate "Page 1", "Page2", etc. Defaults to %.

more_file (string) Page the links should point to. Defaults to the current page.

Related

edit_post_link, edit_comment_link, link_pages, wp_link_pages, get_year_link, get_month_link, get_day_link

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_link_pages"Category: Template Tags

Template Tags/wp list authors

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Authors Full Names and Number of Posts

4 Parameters5 Related

Description

Displays a list of the blog's authors (users), and if the user has authored any posts, the author name is displayed as a link to their posts.Optionally this tag displays each author's post count and RSS feed link.

Usage

<?php wp_list_authors('arguments'); ?>

ExamplesDefault Usage

<?php $defaults = array( 'optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'echo' => true, 'feed' => , 'feed_image' => ); ?>

By default, the usage shows:

Page 128: wp-api

Does not display the count of the number of postsExcludes the 'admin' author from the listDoes not display the full name (first and last) but displays the author nicknameExcludes users with no postsDisplay the resultsNo author feed text is displayedNo author feed image is displayed

<?php wp_list_authors(); ?>

Authors Full Names and Number of Posts

This example displays a list of the site's authors with the full name (first and last name) plus the number of posts for each author. Also, and bydefault, it excludes the admin author, hides authors with no posts, and does not display the RSS feed or image.

<?php wp_list_authors('show_fullname=1&optioncount=1'); ?>

Harriett Smith (42)

Sally Smith (29)

Andrew Anderson (48)

Parameters

optioncount (boolean) Display number of published posts by each author. Options are:

1 (true)0 (false - this is the default)

exclude_admin (boolean) Exclude the 'admin' (login is admin) account from authors list. Options are:

1 (true - this is the default)0 (false)

show_fullname (boolean) Display the full (first and last) name of the authors. If false, the nickname is displayed. Options are:

1 (true)0 (false - this is the default)

hide_empty (boolean) Do not display authors with 0 posts. Options are:

1 (true - this is the default)0 (false)

echo (boolean) Display the results. Options are:

1 (true - this is the default)0 (false)

feed (string) Text to display for a link to each author's RSS feed. Default is no text, and no feed displayed.

feed_image (string) Path/filename for a graphic. This acts as a link to each author's RSS feed, and overrides the feed parameter.

style (string) Style in which to display the author list. A value of list displays the authors as list items while none generates no special displaymethod (the list items are separated by <br> tags). The default setting is list (creates list items for an unordered list). See the markupsection for more. This option added with Version 2.8. Valid values:

list - default.none

html (string) Whether to list the items in html or plaintext. The default setting is html. This option added with Version 2.8. Valid values:

list - default.none

Related

Page 129: wp-api

the_author, the_author_description, the_author_login, the_author_firstname, the_author_lastname, the_author_nickname, the_author_ID,the_author_email, the_author_url, the_author_link, the_author_icq, the_author_aim, the_author_yim, the_author_msn, the_modified_author,the_author_posts, the_author_posts_link, list_authors, wp_list_authors

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_list_authors"Category: Template Tags

Template Tags/wp list bookmarks

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Simple List3.3 Simple List without the Heading3.4 Specific Category Sorted by URL3.5 Shows Ratings and Timestamp

4 Parameters5 Related

Description

This function was introduced in WordPress v2.1 . wp_list_bookmarks(), displays bookmarks found in the Administration > Blogroll > ManageBlogroll panel. This Template Tag allows the user to control how the bookmarks are sorted and displayed and is intended to replace theTemplate tags 'get_links_list()' and 'get_links()'.

Usage

<?php wp_list_bookmarks('arguments'); ?>

ExamplesDefault Usage

By default, the function shows:

Bookmarks divided into Categories with a Category name headingAll bookmarks included, regardless of Category ID, Category Name, or Category IDSorts the list by nameAn image if one is includedA space between the image and the textShows the description of the bookmarkDoes not show the ratingsUnless limit is set, shows all bookmarksDisplays bookmarks

<?php wp_list_bookmarks(); ?>

Simple List

Displays all bookmarks with the title "Bookmarks" and with items wrapped in <li> tags. The title is wrapped in h2 tags.

<?php wp_list_bookmarks('title_li=&category_before=&category_after='); ?>

Simple List without the Heading

Displays all bookmarks as above, but does not include the default heading.

<?php wp_list_bookmarks('title_li=&categorize=0'); ?>

Specific Category Sorted by URL

Displays bookmarks for Category ID 2 in span tags, uses images for bookmarks, does not show descriptions, sorts by bookmark URL.

<?php wp_list_bookmarks('categorize=0&category=2&before=<span>&after=</span>&show_images=1&show_description=0&orderby=url'); ?>

Page 130: wp-api

Shows Ratings and Timestamp

Displays all bookmarks in an ordered list with descriptions on a new line, does not use images for bookmarks, sorts by bookmark id, showsratings and last-updated timestamp.

<ol><?php wp_list_bookmarks('between=<br />&show_images=0&orderby=id&show_rating=1&show_updated=1'); ?></ol>

Parameters

categorize (boolean) Bookmarks should be shown within their assigned Categories (TRUE) or not (FALSE). Defaults to TRUE.

1 (True - default)0 (False)

category (string) Comma separated list of numeric Category IDs to be displayed. If none is specified, all Categories with bookmarks are shown.Defaults to (all Categories).

exclude_category (string) Comma separated list of numeric Category IDs to be excluded from display. Defaults to (no categories excluded).

category_name (string) The name of a Category whose bookmarks will be displayed. If none is specified, all Categories with bookmarks are shown.Defaults to (all Categories).

category_before (string) Text to put before each category. Defaults to '<li id="[category id]" class="linkcat">' .

category_after (string) Text to put before each category. Defaults to '<'/li>' .

class (string) The class each cateogory li will have on it. Defaults to 'linkcat' .

category_orderby (string) Value to sort Categories on. Defaults to 'name'. Valid options:

'name' (Default)'id''slug''count''term_group' (not used yet)

category_order (string) Sort order, ascending or descending for the category_orderby parameter. Valid values:

ASC (Default)DESC

title_li (string) Text for the heading of the links list. Defaults to '__('Bookmarks')', which displays "Bookmarks" (the __('') is used forlocalization purposes). Only used with categorize set to 0 (else the category names will be used instead). If passed a null (0) value, noheading is displayed, and the list will not be wrapped with <ul>, </ul> tags (be sure to pass the categorize option to 0 to this optiontakes effect).

title_before (string) Text to place before each Category description if 'categorize' is TRUE. Defaults to '<h2>'.

title_after (string) Text to place after each Category description if 'categorize' is TRUE. Defaults to '</h2>'.

show_private (boolean) Should a Category be displayed even if the Category is considered private. Ignore the admin setting and show privateCategories (TRUE) or do NOT show private Categories (FALSE). Defaults to FALSE.

1 (True)0 (False - default)

include (string) Comma separated list of numeric bookmark IDs to include in the output. For example, 'include=1,3,6' means to return or echobookmark IDs 1, 3, and 6. If the include string is used, the category, category_name, and exclude parameters are ignored. Defaults to(all Bookmarks).

exclude (string) Comma separated list of numeric bookmark IDs to exclude. For example, 'exclude=4,12' means that bookmark IDs 4 and 12 willNOT be returned or echoed. Defaults to (exclude nothing).

orderby (string) Value to sort bookmarks on. Defaults to 'name' unless you pass the value of '' (empty), in which case it sets to 'id'. Validoptions:

'id'

Page 131: wp-api

'url''name''target''description''owner' - User who added bookmark through bookmarks Manager.'rating''updated''rel' - bookmark relationship (XFN).'notes''rss''length' - The length of the bookmark name, shortest to longest.'rand' - Display bookmarks in random order.

order (string) Sort order, ascending or descending for the orderby parameter. Valid values:

ASC (Default)DESC

limit (integer) Maximum number of bookmarks to display. Defaults to -1 (all bookmarks).

before (string) Text to place before each bookmark. Defaults to '<li>'.

after (string) Text to place after each bookmark. Defaults to '</li>'.

link_before (string) Text to place before the text of each bookmark, inside the hyperlink code. There is no set default. (Requires version 2.7 or later.)

link_after (string) Text to place after the text of each bookmark. There is no set default. (Requires version 2.7 or later.)

category_before (string) Text to place before each category. Defaults to '<li>' with an appropriate id and class.

category_after (string) Text to place after each category. Defaults to '</li>'.

between (string) Text to place between each bookmark/image and its description. Defaults to '\n' (newline).

show_images (boolean) Should images for bookmarks be shown (TRUE) or not (FALSE). Defaults to TRUE.

1 (True - default)0 (False)

show_description (boolean) Should the description be displayed (TRUE) or not (FALSE). Valid when show_images is FALSE, or an image is not defined.Defaults to FALSE.

1 (True)0 (False - default)

show_name (2.7) (boolean) Displays the text of a link when (TRUE). Works when show_images is TRUE. Defaults to FALSE.

1 (True)0 (False - default)

show_rating (boolean) Should rating stars/characters be displayed (TRUE) or not (FALSE). Defaults to FALSE.

1 (True)0 (False - default)

show_updated (boolean) Should the last updated timestamp be displayed (TRUE) or not (FALSE). Defaults to FALSE.

1 (True)0 (False - default)

hide_invisible (boolean) Should bookmark be displayed even if it's Visible setting is No. Abides by admin setting (TRUE) or does no abide by adminsetting (FALSE). Defaults to TRUE.

1 (True - default)0 (False)

echo (boolean) Display bookmarks (TRUE) or return them for use by PHP (FALSE). Defaults to TRUE.

1 (True - default)

Page 132: wp-api

0 (False)

Related

wp_list_bookmarks, get_bookmarks, get_bookmark

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_list_bookmarks"Categories: Template Tags | New page created

Template Tags/wp list categories

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Include or Exclude Categories3.3 Display or Hide the List Heading3.4 Only Show Children of a Category3.5 Remove Parentheses from Category Counts3.6 Display Categories with RSS Feed Links3.7 Markup and Styling of Category Lists

4 Parameters5 Related

Description

The template tag, wp_list_categories, displays a list of Categories as links. When a Category link is clicked, all the posts in that Category willdisplay on a Category Page using the appropriate Category Template dictated by the Template Hierarchy rules. wp_list_categories works inmuch the same way as the two template tags replaced in WordPress 2.1, list_cats()(deprecated), and wp_list_cats()(deprecated).

Usage

<?php wp_list_categories('arguments'); ?>

ExamplesDefault Usage

$defaults = array('show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'show_last_update' => 0, 'style' => 'list','show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'feed' => '', 'feed_image' => '', 'exclude' => '', 'current_category' => 0,'hierarchical' => true, 'title_li' => __('Categories'), 'echo' => 1,'depth' => 0);

As well as the silent

'number' => NULL

By default, the usage shows:

No link to all categories

Page 133: wp-api

Sorts the list of Categories in by the Category name in ascending orderDoes not show the last update (last updated post in each Category)Displayed in an unordered list styleDoes not show the post countDisplays only Categories with postsSets the title attribute to the Category DescriptionIs not restricted to the child_of any CategoryNo feed or feed image usedDoes not exclude any Category and includes all Categories ('include' => is not shown above)Displays the active Category with the CSS Class-Suffix ' current-cat'Shows the Categories in hierarchical indented fashionDisplay Category as the heading over the listNo SQL LIMIT is imposed ('number' => 0 is not shown above)Displays (echos) the categoriesNo limit to depthAll categories.

wp_list_categories();

Include or Exclude Categories

To sort categories alphabetically and include only the categories with IDs of 16, 3, 9 and 5, you could write the following code:

<ul><?phpwp_list_categories('orderby=name&include=3,5,9,16'); ?> </ul>

The following example displays category links sorted by name, shows the number of posts for each category, and excludes the category withthe ID of 10 from the list.

<ul><?phpwp_list_categories('orderby=name&show_count=1&exclude=10'); ?> </ul>

Display or Hide the List Heading

The title_li parameter sets or hides a title or heading for the category list generated by wp_list_categories. It defaults to'(__('Categories')', i.e. it displays the word "Categories" as the list's heading. If the parameter is set to a null or empty value, no headingis displayed. The following example code excludes categories with IDs 4 and 7 and hides the list heading:

<ul><?phpwp_list_categories('exclude=4,7&title_li='); ?></ul>

In the following example, only Cateogories with IDs 9, 5, and 23 are included in the list and the heading text has been changed to the word"Poetry", with a heading style of <h2>:

<ul><?phpwp_list_categories('include=5,9,23&title_li=<h2>' . __('Poetry') . '</h2>' ); ?> </ul>

Only Show Children of a Category

The following example code generates category links, sorted by ID, only for the children of the category with ID 8; it shows the number of postsper category and hides category descriptions from the title attribute of the generated links. Note: If there are no posts in a parent Category,the parent Category will not display.

<ul> <?php wp_list_categories('orderby=id&show_count=1&use_desc_for_title=0&child_of=8'); ?></ul>

Remove Parentheses from Category Counts

When show_count=1, each category count is surrounded by parentheses. In order to remove the parentheses without modifying coreWordPress files, use the following code.

Page 134: wp-api

<?php$variable = wp_list_categories('echo=0&show_count=1&title_li=<h2>Categories</h2>');$variable = str_replace(array('(',')'), '', $variable);echo $variable;?>

Display Categories with RSS Feed Links

The following example generates Category links sorted by name, shows the number of posts per Category, and displays links to the RSS feedfor each Category.

<ul><?php wp_list_categories('orderby=name&show_count=1&feed=RSS'); ?></ul>

To replace the rss link with a feed icon, you could write:

<ul><?php wp_list_categories('orderby=name&show_count=1&feed_image=/images/rss.gif'); ?></ul>

Markup and Styling of Category Lists

By default, wp_list_categories() generates nested unordered lists (ul) within a single list item (li) titled "Categories".

You can remove the outermost item and list by setting the title_li parameter to an empty string. You'll need to wrap the output in anordered list (ol) or unordered list yourself (see the examples below). If you don't want list output at all, set the style parameter to none.

If the category list is generated on a Category Archive page, the list item for that category is marked with the HTML class current-cat. Theother list items have no class.

...<li class="current-cat"> [You are on this category page]</li><li> [Another category]</li>...

You can style that list item with a CSS selector :

.categories { ... } .cat-item { ... } .current-cat { ... } .current-cat-parent { ... }

Parameters

show_option_all (string) A non-blank values causes the display of a link to all categories if the style is set to list. The default value is not to display a linkto all.

orderby (string) Sort categories alphabetically, by unique Category ID, or by the count of posts in that Category. The default is sort by categoryname. Valid values:

IDname - defaultslugcount

order (string) Sort order for categories (either ascending or descending). The default is ascending. Valid values:

ASC - defaultDESC

show_last_updated (boolean) Should the last updated timestamp for posts be displayed (TRUE) or not (FALSE). Defaults to FALSE.

Page 135: wp-api

* 1 (true)* 0 (false) - default

style (string) Style to display the categories list in. A value of list displays the categories as list items while none generates no special displaymethod (the list items are separated by <br> tags). The default setting is list (creates list items for an unordered list). See the markupsection for more. Valid values:

list - default.none

show_count (boolean) Toggles the display of the current count of posts in each category. The default is false (do not show post counts). Validvalues:

1 (true)0 (false) - default

hide_empty (boolean) Toggles the display of categories with no posts. The default is true (hide empty categories). Valid values:

1 (true) - default0 (false)

use_desc_for_title (boolean) Sets whether a category's description is inserted into the title attribute of the links created (i.e. <a title="<em>CategoryDescription</em>" href="...). The default is true (category descriptions will be inserted). Valid values:

1 (true) - default0 (false)

child_of (integer) Only display categories that are children of the category identified by this parameter. There is no default for this parameter. Ifthe parameter is used, the hide_empty parameter is set to false.

feed (string)Display a link to each category's rss-2 feed and set the link text to display. The default is no text and no feed displayed.

feed_image (string) Set a URI for an image (usually an rss feed icon) to act as a link to each categories' rss-2 feed. This parameter overrides thefeed parameter. There is no default for this parameter.

exclude (string) Exclude one or more categories from the results. This parameter takes a comma-separated list of categories by unique ID, inascending order. See the example. The child_of parameter is automatically set to false.

include (string) Only include the categories detailed in a comma-separated list by unique ID, in ascending order. See the example.

hierarchical (boolean) Display sub-categories as inner list items (below the parent list item) or inline. The default is true (display sub-categoriesbelow the parent list item). Valid values:

1 (true) - default0 (false)

title_li (string) Set the title and style of the outer list item. Defaults to "_Categories". If present but empty, the outer list item will not bedisplayed. See below for examples.

number (integer) Sets the number of Categories to display. This causes the SQL LIMIT value to be defined. Default to no LIMIT.

echo (boolean) Show the result or keep it in a variable. The default is true (display the categories organized). Valid values:

1 (true) - default0 (false)

depth (integer) This parameter controls how many levels in the hierarchy of Categories are to be included in the list of Categories. The defaultvalue is 0 (display all Categories and their children). This parameter added at Version 2.5

0 - All Categories and child Categories (Default).-1 - All Categories displayed in flat (no indent) form (overrides hierarchical).1 - Show only top level Categoriesn - Value of n (some number) specifies the depth (or level) to descend in displaying Categories

Page 136: wp-api

current_category (integer) Allows you to force the "current-cat" to appear on uses of wp_list_categories that are not on category archive pages. Normally,the current-cat is set only on category archive pages. If you have another use for it, or want to force it to highlight a different category,this overrides what the function thinks the "current" category is.

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_list_categories"Categories: Template Tags | Copyedit

Template Tags/wp list cats

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may beremoved from future versions. All code that uses this function should be converted to use its replacement if one exists.

Contents1 Description2 Replace With3 Usage4 Examples

4.1 Default Usage4.2 Categories With Excludes4.3 Show Children Only of Category4.4 Display Categories With RSS Feed Links

5 Notes on use6 Parameters7 Related

Description

Displays a list of Categories as links. When one of those links is clicked, all the posts in that Category will display in the appropriate CategoryTemplate dictated by the Template Hierarchy rules. This works in much the same way as list_cats(), the difference being that arguments aregiven in query string format.

See wp_list_categories() which replaces this in the current version.

Replace With

wp_list_categories().

Usage

<?php wp_list_cats('arguments'); ?>

ExamplesDefault Usage

By default, the tag:

optionall - Does not display a link to all Categoriesall - Text to display for link to all Categoriessort_column - Sorts by Category IDsort_order - Sorts in ascending orderfile - Displays the Categories using the index.php templatelist - Sets the Categories in an unordered list (<ul><li>)optioncount - Does not display the count of posts within each Categoryhide_empty - Does not display links to Categories which have no posts

Page 137: wp-api

use_desc_for_title - Uses the Category description as the link titlechildren - Shows the children (sub-Categories) of every Category listedhierarchical - Displays the children Categories in a hierarchical order under its Category parent

<?php wp_list_cats(); ?>

Categories With Excludes

Displays Category links sorted by name, shows # of posts for each Category, and excludes Category IDs 10 and 15 from the list.

<ul><?php wp_list_cats('sort_column=name&optioncount=1&exclude=10, 15'); ?></ul>

Show Children Only of Category

Displays Category links sorted by ID (sort_column=id), without showing the number of posts per Category (optioncount=0), showingonly the sub-Categories titles (use_desc_for_title=0), for just the children of Category ID 8 (child_of=8).

<?php wp_list_cats('sort_column=id&optioncount=0&use_desc_for_title=0&child_of=8'); ?>

Note: If there are no posts in a parent Category, that parent Category will not display.

Display Categories With RSS Feed Links

Displays Category links sorted by name, without showing the number of posts per Category, and displays links to the RSS feed for eachCategory.

<?php wp_list_cats('sort_column=name&optioncount=0&feed=RSS'); ?>

Notes on use

When the 'list' parameter is set for an unordered list, the wp_list_cats() tag requires an opening and closing UL tag, but will automatically listeach item as an LI.

Parameters

optionall (boolean) Sets whether to display a link to all Categories. Note: This feature no longer works in WordPress 1.5.x and 2.0 but is slated tobe added back at Version 2.1. Valid values:

1 (True)0 (False - default)

all (string) If optionall is set to 1 (TRUE), this defines the text to be displayed for the link to all Categories. Note: This feature no longerworks in WordPress 1.5.x and 2.0 but is slated to be added back at Version 2.1. Defaults to 'All'.

sort_column (string) Key to sort options by. Valid values:

ID (Default)name

sort_order (string) Sort order for options. Valid values:

asc (Default)desc

file (string) The php file a Category link is to be displayed on. Defaults to index.php.

list (boolean) Sets whether the Categories are enclosed in an unordered list (<ul><li>). Valid values:

1 (True - default)0 (False)

optiondates (string) Sets whether to display the date of the last post in each Category. Valid values:

1 (True, displays Y-m-d)0 (False - default)string (Eg. Y-m-d, see all available options)

optioncount (boolean) Sets whether to display a count of posts in each Category. Valid values:

Page 138: wp-api

1 (True)0 (False - default)

hide_empty (boolean) Sets whether to hide (not display) Categories with no posts. Valid values:

1 (True - default)0 (False)

use_desc_for_title (boolean) Sets whether the Category description is displayed as link title (i.e. <a title="Category Description" href="...).Valid values:

1 (True - default)0 (False)

children (boolean) Sets whether to show children (sub) Categories. Valid values:

1 (True - default)0 (False)

child_of (integer) Display only the Categories that are children of this Category (ID number). There is no default. If this parameter is used,hide_empty gets set to False.

feed (string) Text to display for the link to each Category's RSS2 feed. Default is no text, and no feed displayed.

feed_image (string) Path/filename for a graphic to act as a link to each Categories' RSS2 feed. Overrides the feed parameter.

exclude (string) Sets the Categories to be excluded. This must be in the form of an array (ex: 1, 2, 3).

hierarchical (boolean) Sets whether to display child (sub) Categories in a hierarchical (after parent) list. Valid values:

1 (True - default)0 (False)

Note: The hierarchical parameter is not available in versions of WordPress prior to 1.5

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category,get_category_parents, get_the_category get_category_link,

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_list_cats"Category: Template Tags

Template Tags/wp list comments

This page is marked as incomplete. You can help Codex by expanding it.

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Comments Only With A Custom Comment Display

4 Parameters5 Related

Description

Introduced in Version 2.7, this function displays all comments for a post or Page based on a variety of parameters including ones set in theadministration area.

See also: Migrating Plugins and Themes to 2.7

Page 139: wp-api

Usage

<?php wp_list_comments('arguments'); ?>

ExamplesDefault Usage

Outputs an ordered list of the comments. Things like threading or paging being enabled or disabled are controlled via the Settings DiscussionSubPanel.

<ol class="commentlist"><?php wp_list_comments(); ?></ol>

Comments Only With A Custom Comment Display

Displays just comments (no pingbacks or trackbacks) while using a custom callback function to control the look of the comment.

<ul class="commentlist"><?php wp_list_comments('type=comment&callback=mytheme_comment'); ?></ul>

You will need to define your custom callback function in your theme's functions.php file. Here is an example:

function mytheme_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?> <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>"> <div id="comment-<?php comment_ID(); ?>"> <div class="comment-author vcard"> <?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>

<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?> </div> <?php if ($comment->comment_approved == '0') : ?> <em><?php _e('Your comment is awaiting moderation.') ?></em> <br /> <?php endif; ?>

<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ','') ?></div>

<?php comment_text() ?>

<div class="reply"> <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?> </div> </div><?php }

Note the lack of a trailing </li>. WordPress will add it itself once it's done listing any children and whatnot.

Parameters

This needs expanding / explaining.

avatar_size (int) Size that the avatar should be shown as, in pixels. Default: 32. http://gravatar.com/ supports sizes between 1 and 512.

style (string) Can be either 'div', 'ol', or 'ul', to display comments using divs, ordered, or unordered lists. Defaults to 'ul'. Note that there arecontaining tags that must be written explicitly such as

<div class="commentlist"><?php wp_list_comments(array('style' => 'div')); ?></div>

or

<ol class="commentlist"><?php wp_list_comments(array('style' => 'ol')); ?></ol>

type (string) The type of comment(s) to display. Can be 'all', 'comment', 'trackback', 'pingback', or 'pings'. 'pings' is 'trackback' and 'pingback'together. Default is 'all'.

Page 140: wp-api

callback (string) The name of a custom function to use to display each comment. Defaults to null. Using this will make your custom function getcalled to display each comment, bypassing all internal WordPress functionality in this respect. Use to customize comments display forextreme changes to the HTML layout. Not recommended.

$defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all','page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');

Related

comments_number, comments_link, comments_rss_link, comments_popup_script, comments_popup_link, comment_ID, comment_author,comment_author_IP, comment_author_email, comment_author_url, comment_author_email_link, comment_author_url_link,comment_author_link, comment_type, comment_text, comment_excerpt, comment_date, comment_time, comments_rss_link,comment_author_rss, comment_text_rss, comment_link_rss, permalink_comments_rss, wp_list_comments, previous_comments_link,next_comments_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_list_comments"Categories: Stubs | Template Tags | New page created

Template Tags/wp list pages

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Hiding or Changing the List Heading3.3 List Pages by Page Order3.4 Sort Pages by Post Date3.5 Exclude Pages from List3.6 Include Pages in List3.7 List Sub-Pages3.8 List subpages even if on a subpage3.9 Markup and styling of page items

4 Parameters5 Related

Description

The Template Tag, wp_list_pages(), displays a list of WordPress Pages as links. It is often used to customize the Sidebar or Header, but maybe used in other Templates as well.

This Template Tag is available for WordPress versions 1.5 and newer.

Usage

<?php wp_list_pages('arguments'); ?>

ExamplesDefault Usage

$defaults = array( 'depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'exclude_tree'=> '' );

Page 141: wp-api

By default, the usage shows:

All Pages and sub-pages are displayed (no depth restriction)Date created is not displayedIs not restricted to the child_of any PageNo pages are excludedThe title of the pages listed is "Pages"Results are echoed (displayed)Is not restricted to any specific authorSorted by Page Order then Page Title.Sorted in ascending order (not shown in defaults above)Pages displayed in a hierarchical indented fashion (not shown in defaults above)Includes all Pages (not shown in defaults above)Not restricted to Pages with specific meta key/meta value (not shown in defaults above)No Parent/Child trees excluded

wp_list_pages();

Hiding or Changing the List Heading

The default heading of the list ("Pages") of Pages generated by wp_list_pages can be hidden by passing a null or empty value to the title_liparameter. The following example displays no heading text above the list.

<ul><?php wp_list_pages('title_li='); ?></ul>

In the following example, only Pages with IDs 9, 5, and 23 are included in the list and the heading text has been changed to the word "Poetry",with a heading style of <h2>:

<ul> <?php wp_list_pages('include=5,9,23&title_li=<h2>' . __('Poetry') . '</h2>' ); ?></ul>

List Pages by Page Order

The following example lists the Pages in the order defined by the Page Order settings for each Page in the Write > Page administrative panel.

<ul> <?php wp_list_pages('sort_column=menu_order'); ?></ul>

If you wanted to sort the list by Page Order and display the word "Prose" as the list heading (in h2 style) on a Sidebar, you could add thefollowing code to the sidebar.php file:

<ul> <?php wp_list_pages('sort_column=menu_order&title_li=<h2>' . __('Prose') . '</h2>' ); ?></ul>

Using the following piece of code, the Pages will display without heading and in Page Order:

<ul> <?php wp_list_pages('sort_column=menu_order&title_li='); ?></ul>

Sort Pages by Post Date

This example displays Pages sorted by (creation) date, and shows the date next to each Page list item.

<ul> <?php wp_list_pages('sort_column=post_date&show_date=created'); ?></ul>

Exclude Pages from List

Use the exclude parameter to hide certain Pages from the list to be generated by wp_list_pages.

<ul> <?php wp_list_pages('exclude=17,38' ); ?></ul>

Include Pages in List

Page 142: wp-api

To include only certain Pages in the list, for instance, Pages with ID numbers 35, 7, 26 and 13, use the include parameter.

<ul> <?php wp_list_pages('include=7,13,26,35&title_li=<h2>' . __('Pages') . '</h2>' ); ?> </ul>

List Sub-Pages

Versions prior to Wordpress 2.0.1 :

Put this inside the the_post() section of the page.php template of your WordPress theme after the_content(), or put it in a copy of thepage.php template that you use for pages that have sub-pages:

<ul> <?php global $id; wp_list_pages("title_li=&child_of=$id&show_date=modified &date_format=$date_format"); ?></ul>

This example does not work with Wordpress 2.0.1 or newer if placed in a page template because the global $id is not set. Use the followingcode instead.

Wordpress 2.0.1 or newer :

NOTE: Requires an HTML tag (either <ul> or <ol>) even if there are no subpages. Keep this in mind if you are using css to style the list.

<ul> <?php wp_list_pages('title_li=&child_of='.$post->ID.'&show_date=modified &date_format=$date_format'); ?> </ul>

The following example will generate a list only if there are child (Pages that designate the current page as a Parent) for the current Page:

<?php $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0'); if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?>

List subpages even if on a subpage

The above examples will only show the children from the parent page, but not when actually on a child page. This code will show the childpages, and only the child pages, when on a parent or on one of the children.

This code will not work if placed after a widget block in the sidebar.

<?php if($post->post_parent) $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?>

Markup and styling of page items

By default, wp_list_pages() generates a nested, unordered list of WordPress Pages created with the Write > Page admin panel. You canremove the outermost item (li.pagenav) and list (ul) by setting the title_li parameter to an empty string.

All list items (li) generated by wp_list_pages() are marked with the class page_item. When wp_list_pages() is called while displaying aPage, the list item for that Page is given the additional class current_page_item.

Page 143: wp-api

<li class="pagenav">Pages <ul> <li class="page_item current_page_parent"> [parent of the current page] <ul> <li class="page_item current_page_item"> [the current page] </li> </ul> </li> <li class="page_item"> [another page] </li> </ul></li>

They can be styled with CSS selectors:

.pagenav { ... }

.page_item { ... }

.current_page_item { ... }

.current_page_parent { ... }

Parameters

sort_column (string)Sorts the list of Pages in a number of different ways. The default setting is sort alphabetically by Page title.

'post_title' - Sort Pages alphabetically (by title) - default'menu_order' - Sort Pages by Page Order. N.B. Note the difference between Page Order and Page ID. The Page ID is aunique number assigned by WordPress to every post or page. The Page Order can be set by the user in the Write>Pagesadministrative panel. See the example below.'post_date' - Sort by creation time.'post_modified' - Sort by time last modified.'ID' - Sort by numeric Page ID.'post_author' - Sort by the Page author's numeric ID.'post_name' - Sort alphabetically by Post slug.

Note: The sort_column parameter can be used to sort the list of Pages by the descriptor of any field in the wp_post table of the WordPressdatabase. Some useful examples are listed here.

sort_order (string)Change the sort order of the list of Pages (either ascending or descending). The default is ascending. Valid values:

'asc' - Sort from lowest to highest (Default).'desc' - Sort from highest to lowest.

exclude (string)Define a comma-separated list of Page IDs to be excluded from the list (example: 'exclude=3,7,31'). There is no default value.See the Exclude Pages from List example below.

exclude_tree (string)Define a comma-separated list of parent Page IDs to be excluded. Use this parameter to exclude a parent and all of that parent's childPages. So 'exclude_tree=5' would exclude the parent Page 5, and its child (all descendant) Pages. This parameter was availableat Version 2.7.

include (string)Only include certain Pages in the list generated by wp_list_pages. Like exclude, this parameter takes a comma-separated list of PageIDs. There is no default value. See the Include Pages in List example below.

depth (integer)This parameter controls how many levels in the hierarchy of pages are to be included in the list generated by wp_list_pages. Thedefault value is 0 (display all pages, including all sub-pages).

0 - Pages and sub-pages displayed in hierarchical (indented) form (Default).-1 - Pages in sub-pages displayed in flat (no indent) form.1 - Show only top level Pages2 - Value of 2 (or greater) specifies the depth (or level) to descend in displaying Pages.

Page 144: wp-api

child_of (integer)Displays the sub-pages of a single Page only; uses the ID for a Page as the value. Note that the child_of parameter will also fetch"grandchildren" of the given ID, not just direct descendants. Defaults to 0 (displays all Pages).

show_date (string)Display creation or last modified date next to each Page. The default value is the null value (do not display dates). Valid values:

'' - Display no date (Default).'modified' - Display the date last modified.'xxx' - Any value other than modified displays the date (post_date) the Page was first created. See the example below.

date_format (string)Controls the format of the Page date set by the show_date parameter (example: "l, F j, Y"). This parameter defaults to the dateformat configured in your WordPress options. See Formatting Date and Time and the date format page on the php web site.

title_li (string)Set the text and style of the Page list's heading. Defaults to '__('Pages')', which displays "Pages" (the __('') is used forlocalization purposes). If passed a null or empty value (''), no heading is displayed, and the list will not be wrapped with <ul>,</ul> tags. See the example for Headings.

echo (boolean)Toggles the display of the generated list of links or return the list as an HTML text string to be used in PHP. The default value is 1(display the generated list items). Valid values:

1 (true) - default0 (false)

hierarchical (boolean) Display sub-Pages in an indented manner below their parent or list the Pages inline. The default is true (display sub-Pagesindented below the parent list item). Valid values:

1 (true) - default0 (false)

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 conjuntion with the meta_key field).

link_before (string)Sets the text or html that proceeds the link text inside <a> tag. (Version 2.7.0 or newer.)

link_after (string)Sets the text or html that follows the link text inside <a> tag. (Version 2.7.0 or newer.)

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_list_pages"Categories: Template Tags | Copyedit

Template Tags/wp loginout

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Page 145: wp-api

Displays a login link, or if a user is logged in, a logout link.

This tag was introduced in version 1.5 of WordPress.

Usage

<?php wp_loginout(); ?>

Example

<p><?php wp_loginout(); ?></p>

Parameters

This tag has no parameters.

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_loginout"Category: Template Tags

Template Tags/wp logout url

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Logout link in a comment popup template3.3 Parameters

4 Related

Description

Introduced with Version 2.7, this Template Tag returns a nonce-protected URL that can be echoed as part of an <a> tag allowing a user tologout of a site. Because wp_logout_url is protected by a nonce, this tag should be used in place of code such as/wp-login.php?action=logout. The WordPress Default and Classic themes both use this tag in the comments.php and comments-popup.php> Templates.

Usage

<?php echo wp_logout_url($redirect); ?>

ExamplesDefault Usage

The following example returns a URL that can be used to compose a link that allows the user to logout and be returned to the login screen.

<a href="<?php echo wp_logout_url(); ?>">Logout</a>

Logout link in a comment popup template

Presents a link that when clicked logs the user out and redirects the user to the post/page from where the link was activated.

<a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out »</a>

Parameters

redirect (string)Text to append to after the wp-login.php?action=logout. Default is ' '.

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,

Page 146: wp-api

wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_logout_url"Category: Template Tags

Template Tags/wp page menu

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Display Home as a Page3.3 Display only Home

4 Parameters5 Related

Description

The Template Tag, wp_page_menu(), displays a list of WordPress Pages as links, and affords the opportunity to have Home addedautomatically to the list of Pages displayed. This Tag is useful to customize the Sidebar or Header, but may be used in other Templates as well.

This Template Tag is available for WordPress versions 2.7 and newer.

Usage

<?php wp_page_menu('arguments'); ?>

ExamplesDefault Usage

$defaults = array( 'sort_column' => 'post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');

By default, the usage shows:

Sorted by titleThe div class is 'menu'Results are echoed (displayed)No link_before or link_after textDo not add "Home" to the list of pages (this is not shown in defaults above)Note: Output is encompassed by the <ul> and </ul> tags

wp_page_menu();

Display Home as a Page

The following example causes "Home" to be added to the beginning of the list of Pages displayed. In addition, the Pages wrapped in a divelement, Page IDs 5, 9, and 23, are excluded from the list of Pages displayed, and the pages are listed in Page Order. The list is prefaced withthe title, "Page Menu",

<h2>Page Menu</h2><?php wp_page_menu('show_home=1&exclude=5,9,23&menu_class=page-navi&sort_column=menu_order'); ?>

Display only Home

The following example displays just a link to "Home". Note that the include=99999' references a Page ID that does not exist so only a link forHome is displayed.

<?php wp_page_menu('show_home=1&include=9999); ?>

Page 147: wp-api

Parameters

sort_column (string)Sorts the list of Pages in a alphabetic order by title of the pages. The default setting is sort alphabetically by page title. Thesort_column parameter can be used to sort the list of Pages by the descriptor of any field in the wp_post table of the WordPressdatabase. Some useful examples are listed here.

'post_title' - Sort Pages alphabetically (by title) - default'menu_order' - Sort Pages by Page Order. Note the difference between Page Order and Page ID. The Page ID is a uniquenumber assigned by WordPress to every post or page. The Page Order can be set by the user in the administrative panel (e.g.Administration > Page > Edit).'post_date' - Sort by creation time.'post_modified' - Sort by time last modified.'ID' - Sort by numeric Page ID.'post_author' - Sort by the Page author's numeric ID.'post_name' - Sort alphabetically by Post slug.

menu_class (string)The div class the list is displayed in. Defaults to menu.

echo (boolean)Toggles the display of the generated list of links or return the list as an HTML text string to be used in PHP. The default value is 0 (doNOT display the generated list items). Valid values:

0 (false) - default1 (true)

show_home (boolean)Add "Home" as the first item in the list of "Pages". The URL assigned to "Home" is pulled from the Blog address (URL) inAdministration > Settings > General. The default value is 0 (do NOT display "Home" in the generated list). Valid values:

0 (false) - default1 (true)

link_before (string)Sets the text or html that proceeds the link text inside <a> tag.

link_after (string)Sets the text or html that follows the link text inside <a> tag.

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_page_menu"Categories: Template Tags | Copyedit

Template Tags/wp register

Contents1 Description2 Usage

2.1 Parameters3 Examples

3.1 Default Usage3.2 Display Without Text Before or After

4 WordPress µ5 Related

Description

This tag displays either the "Register" link to users that are not logged in or the "Site Admin" link if a user is logged in. The "Register" link isonly offered if the Administration > Settings > General > Membership: Anyone can register box is checked. The Register link causes the

Page 148: wp-api

/wp-register.php script to execute and Site Admin links to /wp-admin/index.php.

This tag became available beginning with WordPress 1.5.

This tag does not function as intended on WordPress µ.

Usage

<?php wp_register('before', 'after'); ?>

Parameters

before (string)Text to display before the Register or Site Admin link. Default is '<li>'.

after (string)Text to display after the Register or Site Admin link. Default is '</li>'.

ExamplesDefault Usage

wp_register displays the link in list format <li>.

<?php wp_register(); ?>

Display Without Text Before or After

The following code example displays the "Register" or "Site Admin" link with no text in before or after parameters.

<?php wp_register('', ''); ?>

WordPress µ

On WordPress µ, there is no /wp-register.php file, and /wp-login.php?action=register is not a valid registration form. Thus, wp_register does notshow a registration link.

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_register"Category: Template Tags

Template Tags/wp tag cloud

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Cloud displayed under Popular Tags title3.3 Cloud limited in size and ordered by count rather than name3.4 Cloud returned as array but not displayed

4 Parameters5 Creating a Tag Archive6 Related

Description

Available with WordPress Version 2.3, this template tag wp_tag_cloud displays a list of tags in what is called a 'tag cloud', where the size ofeach tag is determined by how many times that particular tag has been assigned to posts. Beginning with Version 2.8, the taxonomyparameter was added so that any taxonony could be used as the basis of generating the cloud. That means, for example, that a cloud for postscategories can be presented to visitors.

Usage

Page 149: wp-api

<?php wp_tag_cloud(''); ?>

ExamplesDefault Usage

$defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC','exclude' => , 'include' => );

By default, the usage shows:

smallest - The smallest tag (lowest count) is shown at size 8largest - The largest tag (highest count) is shown at size 22unit - Describes 'pt' (point) as the font-size unit for the smallest and largest valuesnumber - Displays at most 45 tagsformat - Displays the tags in flat (separated by whitespace) styleorderby - Order the tags by nameorder - Sort the tags in ASCENDING fashionexclude - Exclude no tagsinclude - Include all tags

Cloud displayed under Popular Tags title

<?php if ( function_exists('wp_tag_cloud') ) : ?><li><h2>Popular Tags</h2><ul><?php wp_tag_cloud('smallest=8&largest=22'); ?></ul></li><?php endif; ?>

Cloud limited in size and ordered by count rather than name

<?php wp_tag_cloud('smallest=8&largest=22&number=30&orderby=count'); ?>

Cloud returned as array but not displayed

The variable $tag will contain the tag cloud for use in other PHP code

<?php $tag = wp_tag_cloud('format=array' );?>

Parameters

smallest (integer) The text size of the tag with the smallest count value (units given by unit parameter).

largest (integer) The text size of the tag with the highest count value (units given by the unit parameter).

unit (string) Unit of measure as pertains to the smallest and largest values. This can be any CSS length value, e.g. pt, px, em, %;default is pt (points).

number (integer) The number of actual tags to display in the cloud. (Use '0' to display all tags.)

format (string) Format of the cloud display.

'flat' (Default) tags are separated by whitespace'list' tags are in UL with a class='wp-tag-cloud''array' tags are in an array and function returns the tag cloud as an array for use in PHP Note: the array returned, ratherthan displayed, was instituted with Version 2.5.

orderby (string) Order of the tags. Valid values:

'name' (Default)'count'

order (string) Sort order. Valid values - Must be Uppercase:

'ASC' (Default)'DESC''RAND' tags are in a random order. Note: this parameter was introduced with Version 2.5.

Page 150: wp-api

exclude (string) Comma separated list of tags (term_id) to exclude. For example, 'exclude=5,27' means tags that have the term_id 5 or 27 willNOT be displayed. Defaults to exclude nothing.

include (string) Comma separated list of tags (term_id) to include. For example, 'include=5,27' means tags that have the term_id 5 or 27 will bethe only tags displayed. Defaults to include everything.

taxonomy (string) Taxonomy to use in generating the cloud. Note: this parameter was introduced with Version 2.8.

'post_tag' - (Default) Post tags are used as source of cloud'category' - Post categories are used to generate cloud'link_category' - Link categories are used to generate cloud

Creating a Tag Archive

While the new tagging feature in 2.3 is a great addition, the wp_tag_cloud tag can be used to display a Tag Archive. What this means is thatwhen a visitor clicks on any particular tag a page displaying the tag cloud and all posts tagged the same will be displayed. According to theTemplate_Hierarchy if a tag.php template does not exist then the archives.php template will be used. By making this tag.php template you cancustomize the way your Tag Archive will look, this template includes the tag cloud at the top for very easy navigation.

To do this a new template will need to be added to your theme files. These are good resources for everything pertaining to templates,Template_Hierarchy. Basic steps needed are

1. Create file with the contents below named tag.php.2. Upload file to your themes directory.3. This is optional only if you would like to have a link in your page navigation to the Tag archive, otherwise when clicking ona tag this template will be used.

Create a new blank page using this template, give this page the title Tag Archive.

To elobarate more on step three.

WordPress can be configured to use different Page Templates for different Pages. Toward the bottom of the Write->Write Page administrationpanel (or on the sidebar, depending on which version of WordPress you are using) is a drop-down labeled "Page Template". From there youcan select which Template will be used when displaying this particular Page.

<?php /*Template Name: Tag Archive*/ ?><div><?php get_header(); ?><h2>Tag Archive</h2><?php wp_tag_cloud(''); ?>

<div class="navigation"><div class="alignleft"><?php next_posts_link('« Older Entries') ?></div><div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>

</div><?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>

<div class="entry"><?php the_content('Read the rest of this entry »'); ?></div>

<?php endwhile; ?><?php endif; ?>

</div><?php get_footer(); ?>

Please Note that styling has not been added to this template. A good way to determine the structure that your theme uses is to view thesingle.php theme file.

Related

the_tags, get_the_tags, get_the_tag_list, single_tag_title, get_tag_link, wp_tag_cloud, wp_generate_tag_cloud

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Page 151: wp-api

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_tag_cloud"Categories: Template Tags | Stubs

Template Tags/wp title

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Using Separator3.3 Separator with Blog Name and Title Reversed

4 Parameters5 Related

Description

Displays or returns the title of the page. A separator string can be defined, and beginning with Version 2.5, that separator can be designated toprint before or after the title of the page.

This tag can be used anywhere within a template as long as it's outside The Loop on the main page, though is typically used in the <title>element for the head of a page.

The title text depends on the query:

Single post or a Pagethe title of the post (or Page)

Date-based archive the date (e.g., "2006", "2006 - January")

Category the name of the category

Author page the public name of the user

Usage

<?php wp_title('sep', echo, 'seplocation'); ?>

ExamplesDefault Usage

Displays the blog name (using bloginfo()) and the post title using defaults when accessing a single post page. If the blog name is "MyWordPress Blog", and the title of the post is "Hello world!", then the example below will show the title as My WordPress Blog » Hello world!

<title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>

This example would the same do the same thing:

<title><?php bloginfo('name'); ?> <?php wp_title('',true,''); ?></title>

Using Separator

Displays blog name (using bloginfo()) along with post title in the document's title tag, using "--" as the separator. This results in (when on asingle post page) My WordPress Blog--Hello world!.

<title><?php bloginfo('name'); ?> <?php wp_title('--'); ?></title>

This example would do the same thing:

<title><?php bloginfo('name'); ?> <?php wp_title('--',true,''); ?></title>

Separator with Blog Name and Title Reversed

For Wordpress 2.5 and newer

<title> <?php wp_title('--',true,'right'); ?>

Page 152: wp-api

<?php bloginfo('name'); ?> </title>

For previous versions

This lets you reverse page title and blog name in the title tag from example above (Hello world!--My WordPress Blog) by removing theseparator (using wp_title(' '), then tests if there is a post title (using if(wp_title(' ', false))), and displays the separatorbetween it and bloginfo() if it does.

<title> <?php wp_title(' '); ?> <?php if(wp_title(' ', false)) { echo '--'; } ?> <?php bloginfo('name'); ?> </title>

Parameters

sep (string) Text to display before or after of the post title (i.e. the separator). By default (if sep is blank) then the &raquo; (») symbol will beplaced before or after (specified by the seplocation) the post title.

echo (boolean) Echo the title (True) or return the title for use as a PHP string (False). Valid values:

1 (True) - default0: (False)

seplocation (string) Introduced with Version 2.5, this parameter defines the location of where the sep string prints in relation to the title of the post.For all values except 'right', the sep value is placed in front of (to the left of) the post title. If the value of seplocation is 'right' then thesep string will be appended after the post title.

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_title"Category: Template Tags

Template Tags/get bookmarks

Contents1 Description2 Usage3 Examples

3.1 Default Usage4 Parameters5 Related

Description

This function will be found in WordPress v2.1, it is NOT supported by WordPress v2.0. get_bookmarks() returns an array of bookmarks found inthe Administration > Blogroll > Manage Blogroll panel. This Template Tag allows the user to retrieve the bookmark information directly.

Usage

<?php get_bookmarks('arguments'); ?>

ExamplesDefault Usage

'orderby' => 'name', 'order' => 'ASC','limit' => -1, 'category' => '',

Page 153: wp-api

'category_name' => '', 'hide_invisible' => 1,'show_updated' => 0, 'include' => '','exclude' => ''

By default, the usage gets:

All bookmarks ordered by name, ascendingBookmarks marked as hidden are not returned.The link_updated_f field (the update time in the form of a timestamp) is not returned.

Parameters

orderby (string) Value to sort bookmarks on. Defaults to 'name' unless you pass the value of '' (empty), in which case it sets to 'id'. Validoptions:

'id''url''name''target''description''owner' - User who added bookmark through bookmarks Manager.'rating''updated''rel' - bookmark relationship (XFN).'notes''rss''length' - The length of the bookmark name, shortest to longest.'rand' - Display bookmarks in random order.

order (string) Sort order, ascending or descending for the orderby parameter. Valid values:

ASC (Default)DESC

limit (integer) Maximum number of bookmarks to display. Defaults to -1 (all bookmarks).

category (string) Comma separated list of bookmark category ID's.

category_name (string) Category name of a catgeory of bookmarks to retrieve. Overrides category parameter.

hide_invisible (boolean) TRUE causes only bookmarks with link_visible set to 'Y' to be retrieved.

1 (True - default)0 (False)

show_updated (boolean) TRUE causes an extra column called "link_category_f" to be inserted into the results, which contains the same value as"link_updated", but in a unix timestamp format. Handy for using PHP date functions on this data.

1 (True)0 (False - default)

include (string) Comma separated list of numeric bookmark IDs to include in the output. For example, 'include=1,3,6' means to return or echobookmark IDs 1, 3, and 6. If the include string is used, the category, category_name, and exclude parameters are ignored. Defaults to(all Bookmarks).

exclude (string) Comma separated list of numeric bookmark IDs to exclude. For example, 'exclude=4,12' means that bookmark IDs 4 and 12 willNOT be returned or echoed. Defaults to (exclude nothing).

Related

wp_list_bookmarks, get_bookmarks, get_bookmark

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index

Page 154: wp-api

Retrieved from "http://codex.wordpress.org/Template_Tags/get_bookmarks"Categories: Template Tags | New page created

Template Tags/get posts

Contents1 Description2 Usage3 Examples

3.1 Posts list with offset3.2 Access all post data3.3 Latest posts ordered by title3.4 Random posts3.5 Show all attachments3.6 Show attachments for the current post

4 Parameters: WordPress 2.6+5 Parameters: WordPress 2.5 And Older6 Related

Description

This is a simple tag for creating multiple loops.

Usage

<?php get_posts('arguments'); ?>

ExamplesPosts list with offset

If you have your blog configured to show just one post on the front page, but also want to list links to the previous five posts in category ID 1,you can use this:

<ul> <?php global $post; $myposts = get_posts('numberposts=5&offset=1&category=1'); foreach($myposts as $post) : ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul>

Note: With use of the offset, the above query should be used only on a category that has more than one post in it, otherwise there'll be nooutput.

Access all post data

Some post-related data is not available to get_posts by default, such as post content through the_content(), or the numeric ID. This is resolvedby calling an internal function setup_postdata(), with the $post array as its argument:

<?php $lastposts = get_posts('numberposts=3'); foreach($lastposts as $post) : setup_postdata($post); ?> <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2> <?php the_content(); ?> <?php endforeach; ?>

To access a post's ID or content without calling setup_postdata(), or in fact any post-specific data (data retained in the posts table), you canuse $post->COLUMN, where COLUMN is the table column name for the data. So $post->ID holds the ID, $post->post_content thecontent, and so on. To display or print this data on your page use the PHP echo command, like so:

<?php echo $post->ID; ?>

Latest posts ordered by title

To show the last ten posts sorted alphabetically in ascending order, the following will display their post date, title and excerpt:

Page 155: wp-api

<?php $postslist = get_posts('numberposts=10&order=ASC&orderby=title'); foreach ($postslist as $post) : setup_postdata($post); ?> <div> <?php the_date(); ?> <br /> <?php the_title(); ?> <?php the_excerpt(); ?> </div> <?php endforeach; ?>

Note: The orderby parameter was modified in Version 2.6. This code is using the new orderby format. See Parameters for details.

Random posts

Display a list of 5 posts selected randomly by using the MySQL RAND() function for the orderby parameter value:

<ul><li><h2>A random selection of my writing</h2> <ul> <?php $rand_posts = get_posts('numberposts=5&orderby=rand'); foreach( $rand_posts as $post ) : ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> </li></ul>

Show all attachments

Do this outside any Loops in your template.

(Since Version 2.5, it may be easier to use get_children() instead.)

<?php

$args = array('post_type' => 'attachment','numberposts' => -1,'post_status' => null,'post_parent' => null, // any parent);

$attachments = get_posts($args);if ($attachments) {

foreach ($attachments as $post) {setup_postdata($post);the_title();the_attachment_link($post->ID, false);the_excerpt();

}}

?>

Show attachments for the current post

Do this inside The_Loop (where $post->ID is available).

<?php

$args = array('post_type' => 'attachment','numberposts' => -1,'post_status' => null,'post_parent' => $post->ID);

$attachments = get_posts($args);

Page 156: wp-api

if ($attachments) {foreach ($attachments as $attachment) {

echo apply_filters('the_title', $attachment->post_title);the_attachment_link($attachment->ID, false);

}}

?>

Parameters: WordPress 2.6+

In addition to the parameters listed below under "WordPress 2.5 And Older", get_posts() can also take the parameters thatquery_posts() can since both functions now use the same database query code internally.

Note: Version 2.6 changed a number of the orderby options. Table fields that begin with post_ no longer have that part of the name. Forexample, post_title is now title and post_date is now date.

Parameters: WordPress 2.5 And Older

$numberposts(integer) (optional) Number of posts to return. Set to 0 to use the max number of posts per page. Set to -1 to remove the limit.

Default: 5

$offset(integer) (optional) Offset from latest post.

Default: 0

$category(integer) (optional) Only show posts from this category ID. Making the category ID negative (-3 rather than 3) will show results notmatching that category ID. Multiple category IDs can be specified by separating the category IDs with commas or by passing an arrayof IDs.

Default: None

$category_name(string) (optional) Only show posts from this category name or category slug.

Default: None

$tag(string) (optional) Only show posts with this tag slug. If you specify multiple tag slugs separated by commas, all results matching anytag will be returned. If you specify multiple tag slugs separated by spaces, the results will match all the specified tag slugs.

Default: None

$orderby(string) (optional) Sort posts by one of various values (separated by space), including:

'author' - Sort by the numeric author IDs.'category' - Sort by the numeric category IDs.'content' - Sort by content.'date' - Sort by creation date.'ID' - Sort by numeric post ID.'menu_order' - Sort by the menu order. Only useful with pages.'mime_type' - Sort by MIME type. Only useful with attachments.'modified' - Sort by last modified date.'name' - Sort by stub.'parent' - Sort by parent ID.'password' - Sort by password.'rand' - Randomly sort results.'status' - Sort by status.'title' - Sort by title.'type' - Sort by type.

Notes:

Sorting by ID and rand is only available starting with Version 2.5.

Default: post_date

$order(string) (optional) How to sort $orderby. Valid values:

'ASC' - Ascending (lowest to highest).

Page 157: wp-api

'DESC' - Descending (highest to lowest).Default: DESC

$include(string) (optional) The IDs of the posts you want to show, separated by commas and/or spaces. The following value would work inshowing these six posts:

'45,63, 78 94 ,128 , 140'Note: Using this parameter will override the numberposts, offset, category, exclude, meta_key, meta_value, and post_parentparameters.

Default: None

$exclude(string) (optional) The IDs of any posts you want to exclude, separated by commas and/or spaces (see $include parameter).

Default: None

$meta_key and $meta_value(string) (optional) Only show posts that contain a meta (custom) field with this key and value. Both parameters must be defined, orneither will work.

Default: None

$post_type(string) (optional) The type of post to show. Available options are:

post - Defaultpageattachmentany - all post typesDefault: post

$post_status(string) (optional) Show posts with a particular status. Available options are:

publish - Defaultprivatedraftfutureinherit - Default if $post_type is set to attachment(blank) - all statusesDefault: publish

$post_parent(integer) (optional) Show only the children of the post with this ID

Default: None

$nopaging(boolean) (optional) Enable or disable paging. If paging is disabled, the $numberposts option is ignored.

Default: None

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/get_posts"Category: Template Tags

Template Tags/permalink single rss

Contents1 Description2 Usage3 Example4 Parameters5 Related

Page 158: wp-api

Description

Displays the permalink for the current post, formatted for syndication feeds such as RSS or Atom. This tag must be used within The Loop.

Usage

<?php permalink_single_rss('file'); ?>

Example

Displays the permalink in an RSS link tag.

<link><?php permalink_single_rss(); ?></link>

Parameters

file (string) The page the link should point to. Defaults to the current page.

Related

For permalinks in regular page templates, it's recommended to use the_permalink() instead.

permalink_anchor, get_permalink, the_permalink, permalink_single_rss

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Template_Tags/permalink_single_rss"Categories: Template Tags | Feeds

Template Tags/query posts

Contents1 Description2 Important note3 Usage4 Examples

4.1 Exclude Categories From Your Home Page4.2 Retrieve a Particular Post4.3 Retrieve a Particular Page4.4 Passing variables to query_posts

4.4.1 Example 14.4.2 Example 24.4.3 Example 34.4.4 Example 4

5 Parameters5.1 Category Parameters5.2 Tag Parameters5.3 Author Parameters5.4 Post & Page Parameters5.5 Sticky Post Parameters5.6 Time Parameters5.7 Page Parameters5.8 Offset Parameter5.9 Orderby Parameters5.10 Custom Field Parameters5.11 Combining Parameters

6 Resources7 Related

Description

Query_posts can be used to control which posts show up in The Loop. It accepts a variety of parameters in the same format as used in yourURL (e.g. p=4 to show only post of ID number 4).

Why go through all the trouble of changing the query that was meticulously created from your given URL? You can customize the presentationof your blog entries by combining it with page logic (like the Conditional Tags) -- all without changing any of the URLs.

Common uses might be to:

Display only a single post on your homepage (a single Page can be done via Settings -> Reading).

Page 159: wp-api

Show all posts from a particular time period.Show the latest post (only) on the front page.Change how posts are ordered.Show posts from only one category.Exclude one or more categories.

Important note

The query_posts function is intended to be used to modify the main page Loop only. It is not intended as a means to create secondary Loopson the page. If you want to create separate Loops outside of the main one, you should create separate WP_Query objects and use thoseinstead. Use of query_posts on Loops other than the main one can result in your main Loop becoming incorrect and possibly displaying thingsthat you were not expecting.

The query_posts function overrides and replaces the main query for the page. To save your sanity, do not use it for any other purpose.

Usage

Place a call to query_posts() in one of your Template files before The Loop begins. The wp_query object will generate a new SQL queryusing your parameters. When you do this, WordPress ignores the other parameters it receives via the URL (such as page number or category).If you want to preserve that information, you can use the variable $query_string in the call to query_posts().

For example, to set the display order of the posts without affecting the rest of the query string, you could place the following before The Loop:

query_posts($query_string . "&order=ASC")

When using query_posts in this way, the quoted portion of the argument must begin with an ampersand (&).

ExamplesExclude Categories From Your Home Page

Placing this code in your index.php file will cause your home page to display posts from all categories except category ID 3.

<?php if (is_home()) { query_posts("cat=-3"); }?>

You can also add some more categories to the exclude-list(tested with WP 2.1.2):

<?php if (is_home()) { query_posts("cat=-1,-2,-3"); }?>

Retrieve a Particular Post

To retrieve a particular post, you could use the following:

<?php// retrieve one post with an ID of 5query_posts('p=5'); ?>

If you want to use the Read More functionality with this query, you will need to set the global $more variable to 0.

<?php// retrieve one post with an ID of 5query_posts('p=5'); global $more;// set $more to 0 in order to only get the first part of the post$more = 0;

// the Loopwhile (have_posts()) : the_post(); // the content of the post the_content('Read the full post »'); endwhile;

Page 160: wp-api

?>

Retrieve a Particular Page

To retrieve a particular page, you could use the following:

<?phpquery_posts('page_id=7'); //retrieves page 7 only?>

or

<?phpquery_posts('pagename=about'); //retrieves the about page only?>

For child pages, the slug of the parent and the child is required, separated by a slash. For example:

<?phpquery_posts('pagename=parent/child'); // retrieve the child page of a parent?>

Passing variables to query_posts

You can pass a variable to the query with two methods, depending on your needs. As with other examples, place these above your Loop:

Example 1

In this example, we concatenate the query before running it. First assign the variable, then concatenate and then run it. Here we're pulling in acategory variable from elsewhere.

<?php $categoryvariable=$cat; // assign the variable as current category $query= 'cat=' . $categoryvariable. '&orderby=date&order=ASC'; // concatenate the query query_posts($query); // run the query ?>

Example 2

In this next example, the double " quotes " tell PHP to treat the enclosed as an expression. For this example, we are getting the current monthand the current year, and telling query posts to bring us the posts for the current month/year, and in this case, listing in ascending so we getoldest post at top of page.

<?php $current_month = date('m'); ?><?php $current_year = date('Y'); ?>

<?php query_posts("cat=22&year=$current_year&monthnum=$current_month&order=ASC"); ?><!-- put your loop here -->

Example 3

This example explains how to generate a complete list of posts, dealing with pagination. We can use the default $query_string telling queryposts to bring us a full posts listing. We can also modify the posts_per_page query argument from -1 to the number of posts you want to showon each page; in this last case, you'll probably want to use posts_nav_link() to navigate the generated archive. .

<?php query_posts($query_string.'&posts_per_page=-1');while(have_posts()) { the_post();<!-- put your loop here -->}?>

Example 4

If you don't need to use the $query_string variable, then another method exists that is more clear and readable, in some more complex cases.This method puts the parameters into an array, and then passes the array. The same query as in Example 2 above could be done like this:

query_posts(array('cat' => 22, 'year'=> $current_year, 'monthnum'=>$current_month,

Page 161: wp-api

'order'=>'ASC',));

As you can see, with this approach, every variable can be put on its own line, for simpler reading.

Parameters

This is not an exhaustive list yet. It is meant to show some of the more common things possible with setting your own queries.

Category Parameters

Show posts only belonging to certain categories.

catcategory_namecategory__andcategory__incategory__not_in

Show One Category by ID

Display posts from only one category ID (and any children of that category):

query_posts('cat=4');

Show One Category by Name

Display posts from only one category by name:

query_posts('category_name=Staff Home');

Show Several Categories by ID

Display posts from several specific category IDs:

query_posts('cat=2,6,17,38');

Exclude Posts Belonging to Only One Category

Show all posts except those from a category by prefixing its ID with a '-' (minus) sign.

query_posts('cat=-3');

This excludes any post that belongs to category 3.

Multiple Category Handling

Display posts that are in multiple categories. This shows posts that are in both categories 2 and 6:

query_posts(array('category__and' => array(2,6)));

To display posts from either category 2 OR 6, you could use cat as mentioned above, or by using category__in:

query_posts(array('category__in' => array(2,6)));

You can also exclude multiple categories this way:

query_posts(array('category__not_in' => array(2,6)));

Tag Parameters

Show posts associated with certain tags.

tagtag__andtag__intag_slug__andtag_slug__in

Fetch posts for one tag

query_posts('tag=cooking');

Fetch posts that have either of these tags

Page 162: wp-api

query_posts('tag=bread,baking');

Fetch posts that have all three of these tags:

query_posts('tag=bread+baking+recipe');

Multiple Tag Handling

Display posts that are in multiple tags:

query_posts(array('tag__and' => array('bread','baking'));

This only shows posts that are in both tags 'bread' and 'baking'. To display posts from either tag, you could use tag as mentioned above, orexplicitly specify by using tag__in:

query_posts(array('tag__in' => array('bread','baking'));

The tag_slug__in and tag_slug__and behave much the same, except match against the tag's slug instead of the tag itself.

Also see Ryan's discussion of Tag intersections and unions.

Author Parameters

You can also restrict the posts by author.

author_name=Harriet Note: author_name operates on the user_nicename field, whilst author operates on the author id.author=3

Display all Pages for author=1, in title order, with no sticky posts tacked to the top:

query_posts('caller_get_posts=1&author=1&post_type=page&post_status=publish&orderby=title&order=ASC');

Post & Page Parameters

Retrieve a single post or page.

p=27 - use the post ID to show that postname=about-my-life - query for a particular post that has this Post Slugpage_id=7 - query for just Page ID 7pagename=about - note that this is not the page's title, but the page's pathshowposts=1 - use showposts=3 to show 3 posts. Use showposts=-1 to show all posts'post__in' => array(5,12,2,14,7) - inclusion, lets you specify the post IDs to retrieve'post__not_in' => array(6,2,8) - exclusion, lets you specify the post IDs NOT to retrieve'post_type=page' - returns Pages; defaults to value of post; can be any, attachment, page, or post.

Sticky Post Parameters

Sticky posts first became available with WordPress Version 2.7. Posts that are set as Sticky will be displayed before other posts in a query,unless excluded with the caller_get_posts=1 parameter.

array('post__in'=>get_option('sticky_posts')) - returns array of all sticky postscaller_get_posts=1 - To exclude sticky posts be included at the beginning of posts returned, but the sticky post will still be returnedin the natural order of that list of posts returned.

To return just the first sticky post:

$sticky=get_option('sticky_posts') ; query_posts('p=' . $sticky[0]);

To exclude all sticky posts from the query:

query_posts(array("post__not_in" =>get_option("sticky_posts")));

Return ALL posts with the category, but don't show sticky posts at the top. The 'sticky posts' will still show in their natural position(e.g. by date):

query_posts('caller_get_posts=1&showposts=3&cat=6');

Return posts with the category, but exclude sticky posts completely, and adhere to paging rules:

<?php$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;$sticky=get_option('sticky_posts');

Page 163: wp-api

$args=array( 'cat'=>3, 'caller_get_posts'=>1, 'post__not_in' => $sticky, 'paged'=>$paged, );query_posts($args);?>

Time Parameters

Retrieve posts belonging to a certain time period.

hour= - hour (from 0 to 23)minute= - minute (from 0 to 60)second= - second (0 to 60)day= - day of the month (from 1 to 31)monthnum= - month number (from 1 to 12)year= - 4 digit year (e.g. 2009)w= - week of the year (from 0 to 53) and uses the MySQL WEEK command Mode=1.

Returns posts for just the current date:

$today = getdate();query_posts('year=' .$today["year"] .'&monthnum=' .$today["mon"] .'&day=' .$today["mday"] );

Returns posts dated December 20:

query_posts(monthnum=12&day=20' );

Page Parameters

paged=2 - show the posts that would normally show up just on page 2 when using the "Older Entries" link.posts_per_page=10 - number of posts to show per page; a value of -1 will show all posts.order=ASC - show posts in chronological order, DESC to show in reverse order (the default)

Offset Parameter

You can displace or pass over one or more initial posts which would normally be collected by your query through the use of the offsetparameter.

The following will display the 5 posts which follow the most recent (1):

query_posts('showposts=5&offset=1');

Orderby Parameters

Sort retrieved posts by this field.

orderby=authororderby=dateorderby=category Note: this doesn't work and likely will be discontinued with version 2.8orderby=titleorderby=modifiedorderby=menu_orderorderby=parentorderby=IDorderby=randorderby=meta_value - note that a meta_key=some value clause should be present in the query parameter also

Also consider order parameter of "ASC" or "DESC"

Custom Field Parameters

Retrieve posts (or Pages) based on a custom field key or value.

meta_key=meta_value=meta_compare= - operator to test the meta_value=, default is '=', with other possible values of '!=', '>', '>=', '<', or '<='

Returns posts with custom fields matching both a key of 'color' AND a value of 'blue':

Page 164: wp-api

query_posts('meta_key=color&meta_value=blue');

Returns posts with a custom field key of 'color', regardless of the custom field value:

query_posts('meta_key=color');

Returns posts where the custom field value is 'color', regardless of the custom field key:

query_posts('meta_value=color');

Returns any Page where the custom field value is 'green', regardless of the custom field key:

query_posts('post_type=page&meta_value=green');

Returns both posts and Pages with a custom field key of 'color' where the custom field value IS NOT EQUAL TO 'blue':

query_posts('post_type=any&meta_key=color&meta_compare=!=&meta_value=blue');

Returns posts with custom field key of 'miles' with a custom field value that is LESS THAN OR EQUAL TO 22. Note the value 99 will beconsidered greater than 100 as the data is store as strings, not numbers.

query_posts('meta_key=miles&meta_compare=<=&meta_value=22');

Combining Parameters

You may have noticed from some of the examples above that you combine parameters with an ampersand (&), like so:

query_posts('cat=3&year=2004');

Posts for category 13, for the current month on the main page:

if (is_home()) {query_posts($query_string . '&cat=13&monthnum=' . date('n',current_time('timestamp')));}

At 2.3 this combination will return posts belong to both Category 1 AND 3, showing just two (2) posts, in descending order by the title:

query_posts(array('category__and'=>array(1,3),'showposts'=>2,'orderby'=>title,'order'=>DESC));

In 2.3 and 2.5 one would expect the following to return all posts that belong to category 1 and is tagged "apples"

query_posts('cat=1&tag=apples');

A bug prevents this from happening. See Ticket #5433. A workaround is to search for several tags using +

query_posts('cat=1&tag=apples+apples');

This will yield the expected results of the previous query. Note that using 'cat=1&tag=apples+oranges' yields expected results.

Resources

If..Else - Query Post ReduxIf..Else - Make WordPress Show Only one Post on the Front PageIf..Else - Query PostsPerishable Press - 6 Ways to Customize WordPress Post Ordernietoperzka's Custom order of posts on the main pagehttp://www.darrenhoyt.com/2008/06/11/displaying-related-category-and-author-content-in-wordpress/ Displaying related category andauthor content]Exclude posts from displaying

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags

Go to Template Tag index

Page 165: wp-api

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Template_Tags/query_posts"Categories: Template Tags | Stubs

Template Tags/wp list pages

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Hiding or Changing the List Heading3.3 List Pages by Page Order3.4 Sort Pages by Post Date3.5 Exclude Pages from List3.6 Include Pages in List3.7 List Sub-Pages3.8 List subpages even if on a subpage3.9 Markup and styling of page items

4 Parameters5 Related

Description

The Template Tag, wp_list_pages(), displays a list of WordPress Pages as links. It is often used to customize the Sidebar or Header, but maybe used in other Templates as well.

This Template Tag is available for WordPress versions 1.5 and newer.

Usage

<?php wp_list_pages('arguments'); ?>

ExamplesDefault Usage

$defaults = array( 'depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'exclude_tree'=> '' );

By default, the usage shows:

All Pages and sub-pages are displayed (no depth restriction)Date created is not displayedIs not restricted to the child_of any PageNo pages are excludedThe title of the pages listed is "Pages"Results are echoed (displayed)Is not restricted to any specific authorSorted by Page Order then Page Title.Sorted in ascending order (not shown in defaults above)Pages displayed in a hierarchical indented fashion (not shown in defaults above)Includes all Pages (not shown in defaults above)Not restricted to Pages with specific meta key/meta value (not shown in defaults above)No Parent/Child trees excluded

wp_list_pages();

Page 166: wp-api

Hiding or Changing the List Heading

The default heading of the list ("Pages") of Pages generated by wp_list_pages can be hidden by passing a null or empty value to the title_liparameter. The following example displays no heading text above the list.

<ul><?php wp_list_pages('title_li='); ?></ul>

In the following example, only Pages with IDs 9, 5, and 23 are included in the list and the heading text has been changed to the word "Poetry",with a heading style of <h2>:

<ul> <?php wp_list_pages('include=5,9,23&title_li=<h2>' . __('Poetry') . '</h2>' ); ?></ul>

List Pages by Page Order

The following example lists the Pages in the order defined by the Page Order settings for each Page in the Write > Page administrative panel.

<ul> <?php wp_list_pages('sort_column=menu_order'); ?></ul>

If you wanted to sort the list by Page Order and display the word "Prose" as the list heading (in h2 style) on a Sidebar, you could add thefollowing code to the sidebar.php file:

<ul> <?php wp_list_pages('sort_column=menu_order&title_li=<h2>' . __('Prose') . '</h2>' ); ?></ul>

Using the following piece of code, the Pages will display without heading and in Page Order:

<ul> <?php wp_list_pages('sort_column=menu_order&title_li='); ?></ul>

Sort Pages by Post Date

This example displays Pages sorted by (creation) date, and shows the date next to each Page list item.

<ul> <?php wp_list_pages('sort_column=post_date&show_date=created'); ?></ul>

Exclude Pages from List

Use the exclude parameter to hide certain Pages from the list to be generated by wp_list_pages.

<ul> <?php wp_list_pages('exclude=17,38' ); ?></ul>

Include Pages in List

To include only certain Pages in the list, for instance, Pages with ID numbers 35, 7, 26 and 13, use the include parameter.

<ul> <?php wp_list_pages('include=7,13,26,35&title_li=<h2>' . __('Pages') . '</h2>' ); ?> </ul>

List Sub-Pages

Versions prior to Wordpress 2.0.1 :

Put this inside the the_post() section of the page.php template of your WordPress theme after the_content(), or put it in a copy of the page.phptemplate that you use for pages that have sub-pages:

<ul> <?php global $id; wp_list_pages("title_li=&child_of=$id&show_date=modified

Page 167: wp-api

&date_format=$date_format"); ?></ul>

This example does not work with Wordpress 2.0.1 or newer if placed in a page template because the global $id is not set. Use the followingcode instead.

Wordpress 2.0.1 or newer :

NOTE: Requires an HTML tag (either <ul> or <ol>) even if there are no subpages. Keep this in mind if you are using css to style the list.

<ul> <?php wp_list_pages('title_li=&child_of='.$post->ID.'&show_date=modified &date_format=$date_format'); ?> </ul>

The following example will generate a list only if there are child (Pages that designate the current page as a Parent) for the current Page:

<?php $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0'); if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?>

List subpages even if on a subpage

The above examples will only show the children from the parent page, but not when actually on a child page. This code will show the childpages, and only the child pages, when on a parent or on one of the children.

This code will not work if placed after a widget block in the sidebar.

<?php if($post->post_parent) $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?>

Markup and styling of page items

By default, wp_list_pages() generates a nested, unordered list of WordPress Pages created with the Write > Page admin panel. You canremove the outermost item (li.pagenav) and list (ul) by setting the title_li parameter to an empty string.

All list items (li) generated by wp_list_pages() are marked with the class page_item. When wp_list_pages() is called while displaying a Page,the list item for that Page is given the additional class current_page_item.

<li class="pagenav">Pages <ul> <li class="page_item current_page_parent"> [parent of the current page] <ul> <li class="page_item current_page_item"> [the current page] </li> </ul> </li> <li class="page_item"> [another page] </li> </ul></li>

Page 168: wp-api

They can be styled with CSS selectors:

.pagenav { ... }

.page_item { ... }

.current_page_item { ... }

.current_page_parent { ... }

Parameters

sort_column (string)Sorts the list of Pages in a number of different ways. The default setting is sort alphabetically by Page title.

'post_title' - Sort Pages alphabetically (by title) - default'menu_order' - Sort Pages by Page Order. N.B. Note the difference between Page Order and Page ID. The Page ID is a uniquenumber assigned by WordPress to every post or page. The Page Order can be set by the user in the Write>Pagesadministrative panel. See the example below.'post_date' - Sort by creation time.'post_modified' - Sort by time last modified.'ID' - Sort by numeric Page ID.'post_author' - Sort by the Page author's numeric ID.'post_name' - Sort alphabetically by Post slug.

Note: The sort_column parameter can be used to sort the list of Pages by the descriptor of any field in the wp_post table of the WordPressdatabase. Some useful examples are listed here.

sort_order (string)Change the sort order of the list of Pages (either ascending or descending). The default is ascending. Valid values:

'asc' - Sort from lowest to highest (Default).'desc' - Sort from highest to lowest.

exclude (string)Define a comma-separated list of Page IDs to be excluded from the list (example: 'exclude=3,7,31'). There is no default value. See theExclude Pages from List example below.

exclude_tree (string)Define a comma-separated list of parent Page IDs to be excluded. Use this parameter to exclude a parent and all of that parent's childPages. So 'exclude_tree=5' would exclude the parent Page 5, and its child (all descendant) Pages. This parameter was available atVersion 2.7.

include (string)Only include certain Pages in the list generated by wp_list_pages. Like exclude, this parameter takes a comma-separated list of PageIDs. There is no default value. See the Include Pages in List example below.

depth (integer)This parameter controls how many levels in the hierarchy of pages are to be included in the list generated by wp_list_pages. Thedefault value is 0 (display all pages, including all sub-pages).

0 - Pages and sub-pages displayed in hierarchical (indented) form (Default).-1 - Pages in sub-pages displayed in flat (no indent) form.1 - Show only top level Pages2 - Value of 2 (or greater) specifies the depth (or level) to descend in displaying Pages.

child_of (integer)Displays the sub-pages of a single Page only; uses the ID for a Page as the value. Note that the child_of parameter will also fetch"grandchildren" of the given ID, not just direct descendants. Defaults to 0 (displays all Pages).

show_date (string)Display creation or last modified date next to each Page. The default value is the null value (do not display dates). Valid values:

'' - Display no date (Default).'modified' - Display the date last modified.'xxx' - Any value other than modified displays the date (post_date) the Page was first created. See the example below.

date_format (string)Controls the format of the Page date set by the show_date parameter (example: "l, F j, Y"). This parameter defaults to the date formatconfigured in your WordPress options. See Formatting Date and Time and the date format page on the php web site.

title_li (string)Set the text and style of the Page list's heading. Defaults to '__('Pages')', which displays "Pages" (the __('') is used for localizationpurposes). If passed a null or empty value (''), no heading is displayed, and the list will not be wrapped with <ul>, </ul> tags. See the

Page 169: wp-api

example for Headings.

echo (boolean)Toggles the display of the generated list of links or return the list as an HTML text string to be used in PHP. The default value is 1(display the generated list items). Valid values:

1 (true) - default0 (false)

hierarchical (boolean) Display sub-Pages in an indented manner below their parent or list the Pages inline. The default is true (display sub-Pagesindented below the parent list item). Valid values:

1 (true) - default0 (false)

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 conjuntion with the meta_key field).

link_before (string)Sets the text or html that proceeds the link text inside <a> tag. (Version 2.7.0 or newer.)

link_after (string)Sets the text or html that follows the link text inside <a> tag. (Version 2.7.0 or newer.)

Related

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags with query-string-style parameters

Go to Template Tag index

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Template_Tags/wp_list_pages"Categories: Template Tags | Copyedit

Function Reference/WP Cache

Contents1 Role of WP_Cache2 wp_cache functions3 Examples4 Additional Resources

Role of WP_Cache

WP_Object_Cache is WordPress' class for caching data which may be computationally intensive to regenerate dynamically on every pageload. It's defined in wp-includes/cache.php.

Do not use the class directly in your code when writing plugins, but use the wp_cache functions listed here.

Caching to file to store the information across page loads is not enabled by default - this can be enabled by adding define('WP_CACHE', true);to your wp-config.php file.

Tip: Make sure define('WP_CACHE', true); is above this block:

/* That's all, stop editing! Happy blogging. */ if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); require_once(ABSPATH . 'wp-settings.php');

Within a single page loading caching does still occur so as to reduce the number of database queries as much as possible

wp_cache functions

Page 170: wp-api

Almost all of these functions take a:

key: the key to indicate the value$data: the value you want to storeflag: optional: this is a way of grouping your cache data. If you use a flag, your data will be stored in a subdirectory of your cachedirectoryexpire: number of seconds (by default 900)

wp_cache_add($key, $data, $flag = '', $expire = 0)

This function first checks if there is a cached object on the given $key. If not, then it is saved, otherwise returns false.

wp_cache_delete($id, $flag = '')

Clears a given file.

wp_cache_get($id, $flag = '')

Gives back the value of the cached object if it did not expired. Otherwise gives back false.

wp_cache_replace($key, $data, $flag = '', $expire = 0)

Replaces the given cache if it exists, returns false otherwise.

wp_cache_set($key, $data, $flag = '', $expire = 0)

Sets the value of the cache object. If the object already exists, then it will be overwritten, if the object does not exists it will be created.

wp_cache_init()

Initializes a new cache object. This function is called by Wordpress at initialization if cacheing is enabled.

wp_cache_flush()

Clears all the cache files.

wp_cache_close()

Saves the cached object. This function is called by Wordpress at the shutdown action hook.

Examples

You can use WP_Object_Cache and Snoopy to cache offsite includes:

$news = wp_cache_get('news');if($news == false) {

$snoopy = new Snoopy;$snoopy->fetch('http://example.com/news/'); $news = $snoopy->results;wp_cache_set('news', $news);

} echo $news;

Additional Resources

Dougal Campbell wrote a short guide on how to use the Wordpress Cache object from within your own plugins : Using the WordpressObject CacheJeff Starr discusses different caching options and explains how to enable the default WordPress Object Cache : How to Enable theDefault WordPress Object CachePeter Westwood has a plugin to help people analyse the behaviour of the cache, provides the administrator with a quick overview ofhow the cache is performming and what queries are cached : WP Cache Inspect

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/WP_Cache"Categories: Stubs | Functions

Function Reference/WP Query

Page 171: wp-api

Contents1 Role of WP_Query2 Methods and Properties

2.1 Properties2.2 Methods

3 Interacting with WP_Query

Role of WP_Query

WP_Query is a class defined in wp-includes/query.php that deals with the intricacies of a request to a WordPress blog. The wp-blog-header.php (or the WP class in Version 2.0) gives the $wp_query object information defining the current request, and then $wp_querydetermines what type of query it's dealing with (category archive? dated archive? feed? search?), and fetches the requested posts. It retains alot of information on the request, which can be pulled at a later date.

Methods and Properties

This is the formal documentation of WP_Query. You shouldn't alter the properties directly, but instead use the methods to interact with them.Also see Interacting with WP_Query for some useful functions that avoid the need to mess around with class internals and global variables.

Properties

$queryHolds the query string that was passed to the $wp_query object by wp-blog-header.php (or the WP class in Version 2.0). Forinformation on the construction of this query string (in WP1.5 with wp-blog-header.php - the following link is fairly outdated now), seeWordPress Code Flow.

$query_varsAn associative array containing the dissected $query: an array of the query variables and their respective values.

$queried_objectApplicable if the request is a category, author, permalink or Page. Holds information on the requested category, author, post or Page.

$queried_object_idSimply holds the ID of the above property.

$postsGets filled with the requested posts from the database.

$post_countThe number of posts being displayed.

$current_post(available during The Loop) Index of the post currently being displayed.

$post(available during The Loop) The post currently being displayed.

$is_single, $is_page, $is_archive, $is_preview, $is_date, $is_year, $is_month, $is_time, $is_author, $is_category, $is_tag, $is_tax, $is_search,$is_feed, $is_comment_feed, $is_trackback, $is_home, $is_404, $is_comments_popup, $is_admin, $is_attachment, $is_singular, $is_robots,$is_posts_page, $is_paged

Booleans dictating what type of request this is. For example, the first three represent 'is it a permalink?', 'is it a Page?', 'is it any type ofarchive page?', respectively.

Methods

(An ampersand (&) before a method name indicates it returns by reference.)

init()Initialise the object, set all properties to null, zero or false.

parse_query($query)Takes a query string defining the request, parses it and populates all properties apart from $posts, $post_count, $post and$current_post.

parse_query_vars()Reparse the old query string.

get($query_var)Get a named query variable.

set($query_var, $value)Set a named query variable to a specific value.

&get_posts()Fetch and return the requested posts from the database. Also populate $posts and $post_count.

next_post()(to be used when in The Loop) Advance onto the next post in $posts. Increment $current_post and set $post.

the_post()(to be used when in The Loop) Advance onto the next post, and set the global $post variable.

have_posts()(to be used when in The Loop, or just before The Loop) Determine if we have posts remaining to be displayed.

Page 172: wp-api

rewind_posts()Reset $current_post and $post.

&query($query)Call parse_query() and get_posts(). Return the results of get_posts().

get_queried_object()Set $queried_object if it's not already set and return it.

get_queried_object_id()Set $queried_object_id if it's not already set and return it.

WP_Query($query = '') (constructor)If you provide a query string, call query() with it.

Interacting with WP_Query

Most of the time you can find the information you want without actually dealing with the class internals and globals variables. There are a wholebunch of functions that you can call from anywhere that will enable you to get the information you need.

There are two main scenarios you might want to use WP_Query in. The first is to find out what type of request WordPress is currently dealingwith. The $is_* properties are designed to hold this information: use the Conditional Tags to interact here. This is the more common scenario toplugin writers (the second normally applies to theme writers).

The second is during The Loop. WP_Query provides numerous functions for common tasks within The Loop. To begin with, have_posts(),which calls $wp_query->have_posts(), is called to see if there are any posts to show. If there are, a while loop is begun, using have_posts() asthe condition. This will iterate around as long as there are posts to show. In each iteration, the_post(), which calls $wp_query->the_post() iscalled, setting up internal variables within $wp_query and the global $post variable (which the Template Tags rely on), as above. These are thefunctions you should use when writing a theme file that needs a loop. See also The Loop and The Loop in Action for more information.

Retrieved from "http://codex.wordpress.org/Function_Reference/WP_Query"Category: Functions

Function Reference/WP Rewrite

This document assumes familiarity with Apache's mod_rewrite. If you've never heard of this before, try reading Sitepoint's Beginner's Guide toURL Rewriting. Also see Otto's explanation of hierarchy of rewrite rules in the wp-hackers email list.

Contents1 Role of WP_Rewrite2 Methods and Properties

2.1 Properties2.2 Methods

3 Plugin Hooks3.1 Examples

4 Non-Wordpress rewrite rules

Role of WP_Rewrite

WP_Rewrite is WordPress' class for managing the rewrite rules that allow you to use Pretty Permalinks feature. It has several methods thatgenerate the rewrite rules from values in the database. It is used internally when updating the rewrite rules, and also to find the URL of aspecific post, Page, category archive, etc.. It's defined in wp-includes/rewrite.php as a single instance global variable, $wp_rewrite, is initialisedin wp-settings.php.

Methods and Properties

This is the formal documentation of WP_Rewrite. Try not to access or set the properties directly, instead use the methods to interact with the$wp_rewrite object.

Properties

$permalink_structure The permalink structure as in the database. This is what you set on the Permalink Options page, and includes 'tags'like %year%, %month% and %post_id%.

$category_base Anything to be inserted before category archive URLs. Defaults to 'category/'.

$category_structure Structure for category archive URLs. This is just the $category_base plus '%category%'.

$author_base Anything to be inserted before author archive URLs. Defaults to 'author/'.

$author_structure Structure for author archive URLs. This is just the $author_base plus '%author%'.

$feed_base

Page 173: wp-api

Anything to be inserted before feed URLs. Defaults to 'feed/'.$feed_structure

Structure for feed URLs. This is just the $feed_base plus '%feed%'.$search_base

Anything to be inserted before searchs. Defaults to 'search/'.$search_structure

Structure for search URLs. This is just the $search_base plus '%search%'.$comments_base

Anything to be inserted just before the $feed_structure to get the latest comments feed. Defaults to 'comments'.$comments_feed_structure

The structure for the latest comments feed. This is just $comments_base plus $feed_base plus '%feed%'.$date_structure

Structure for dated archive URLs. Tries to be '%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%' or'%monthnum%/%day%/%year%', but if none of these are detected in your $permalink_structure, defaults to '%year%/%monthnum%/%day%'. Various functions use this structure to obtain less specific structures: for example, get_year_permastruct() simply removes the'%monthnum%' and '%day%' tags from $date_structure.

$page_structure Structure for Pages. Just '%pagename%'.

$front Anything up to the start of the first tag in your $permalink_structure.

$root The root of your WordPress install. Prepended to all structures.

$matches Used internally when calculating back references for the redirect part of the rewrite rules.

$rules The rewrite rules. Set when rewrite_rules() is called.

$non_wp_rules Associative array of "rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)" roughly in the form'Pattern' => 'Substitution' (see below).

$rewritecode An array of all the tags available for the permalink structure. See Using Permalinks for a list.

$rewritereplace What each tag will be replaced with for the regex part of the rewrite rule. The first element in $rewritereplace is the regex for the firstelement in $rewritecode, the second corresponds to the second, and so on.

$queryreplace What each tag will be replaced with in the rewrite part of the rewrite rule. The same correspondance applies here as with$rewritereplace.

Methods

add_rewrite_tag($tag, $pattern, $query) add an element to the $rewritecode, $rewritereplace and $queryreplace arrays using each parameter respectively. If $tag already existsin $rewritecode, the existing value will be overwritten.

flush_rules() Regenerate the rewrite rules and save them to the database

generate_rewrite_rule($permalink_structure, $walk_dirs = false) Generates a no-frills rewrite rule from the permalink structure. No rules for extra pages or feeds will be created.

generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $page = true, $feed = true, $forcomments = false, $walk_dirs = true) A large function that generates the rewrite rules for a given structure, $permalink_structure. If $page is true, an extra rewrite rule will begenerated for accessing different pages (e.g. /category/tech/page/2 points to the second page of the 'tech' category archive). If $feed istrue, extra rewrite rules will be generated for obtaining a feed of the current page, and if $forcomments is true, this will be a commentfeed. If $walk_dirs is true, then a rewrite rule will be generated for each directory of the structure provided, e.g. if you provide it with'/%year%/%month%/%day/', rewrite rules will be generated for '/%year%/', /%year%/%month%/' and '/%year%/%month%/%day%/'.This returns an associative array using the regex part of the rewrite rule as the keys and redirect part of the rewrite rule as the value.

get_date_permastruct(), get_category_permastruct(), get_date_permastruct() etc. Populates the corresponding property (e.g., $date_structure for get_date_permastruct()) if it's not already set and returns it. Thefunctions get_month_permastruct() and get_year_permastruct() don't have a corresponding property: they work out the structure bytaking the $date_structure and removing tags that are more specific than they need (i.e., get_month_permastruct() removes the'%day%' tag, as it only needs to specify the year and month).

init() Set up the object, set $permalink_structure and $category_base from the database. Set $root to $index plus '/'. Set $front to everythingup to the start of the first tag in the permalink structure. Unset all other properties.

mod_rewrite_rules() returns a string (not an array) of all the rules. They are wrapped in an Apache <IfModule> block, to ensure mod_rewrite is enabled.

page_rewrite_rules() Returns the set of rules for any Pages you have created.

rewrite_rules() populate and return the $rules variable with an associative array as in generate_rewrite_rules(). This is generated from the post, date,

Page 174: wp-api

comment, search, category, authors and page structures.set_category_base($category_base)

Change the category base.set_permalink_structure($permalink_structure)

Change the permalink structure.using_index_permalinks()

Returns true if your blog is using PATHINFO permalinks.using_mod_rewrite_permalinks

Returns true your blog is using "pretty" permalinks via mod_rewrite.using_permalinks()

Returns true if your blog is using any permalink structure (i.e. not the default query URIs ?p=n, ?cat=n).WP_Rewrite (constructor)

Call init().wp_rewrite_rules()

returns the array of rewrite rules as in rewrite_rules(), but using $matches[xxx] in the (where xxx is a number) instead of the normalmod_rewrite backreferences, $xxx (where xxx is a number). This is useful when you're going to be using the rules inside PHP, ratherthan writing them out to a .htaccess file.

Plugin Hooks

As the rewrite rules are a crucial part of your weblog functionality, WordPress allows plugins to hook into the generation process at severalpoints. rewrite_rules(), specifically, contains nine filters and one hook for really precise control over the rewrite rules process. Here's what youcan filter in rewrite_rules():

To filter the rewrite rules generated for permalink URLs, use post_rewrite_rules.To filter the rewrite rules generated for dated archive URLs, use date_rewrite_rules.To filter the rewrite rules generated for category archive URLs, use category_rewrite_rules.To filter the rewrite rules generated for search URLs, use search_rewrite_rules.To filter the rewrite rules generated for the latest comment feed URLs, use comments_rewrite_rules.To filter the rewrite rules generated for author archive URLs, use author_rewrite_rules.To filter the rewrite rules generated for your Pages, use page_rewrite_rules.To filter the rewrite rules generated for the root of your weblog, use root_rewrite_rules.To filter the whole lot, use rewrite_rules_array.The action hook generate_rewrite_rules runs after all the rules have been created. If your function takes a parameter, it will be passeda reference to the entire $wp_rewrite object.

mod_rewrite_rules() is the function that takes the array generated by rewrite_rules() and actually turns it into a set of rewrite rules for the.htaccess file. This function also has a filter, mod_rewrite_rules, which will pass functions the string of all the rules to be written out to.htaccess, including the <IfModule> surrounding section. (Note: you may also see plugins using the rewrite_rules hook, but this is deprecated).

Examples

(See also: Permalinks for Custom Archives)

The most obvious thing a plugin would do with the $wp_rewrite object is add its own rewrite rules. This is remarkably simple. Filter the genericrewrite_rules_array. The Jerome's Keywords plugin does this to enable URLs like http://example.com/tag/sausages.

function keywords_createRewriteRules($rewrite) {global $wp_rewrite;

// add rewrite tokens$keytag_token = '%tag%';$wp_rewrite->add_rewrite_tag($keytag_token, '(.+)', 'tag=');

$keywords_structure = $wp_rewrite->root . "tag/$keytag_token";$keywords_rewrite = $wp_rewrite->generate_rewrite_rules($keywords_structure);

return ( $rewrite + $keywords_rewrite );}

Instead of inserting the rewrite rules into the $rewrite array itself, Jerome chose to create a second array, $keywords_rewrite, using theWP_Rewrite function generate_rewrite_rules(). Using that function means that the plugin doesn't have to create rewrite rules for extra pages(like page/2), or feeds (like feed/atom), etc. This array is then appended onto the $rewrite array and returned.

A simpler example of this is Ryan Boren's Feed Director plugin. This simply redirects URLs like http://example.com/feed.xml tohttp://example.com/feed/rss2:

function feed_dir_rewrite($wp_rewrite) { $feed_rules = array( 'index.rdf' => 'index.php?feed=rdf',

Page 175: wp-api

'index.xml' => 'index.php?feed=rss2', '(.+).xml' => 'index.php?feed=' . $wp_rewrite->preg_index(1) );

$wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;}

// Hook in.add_filter('generate_rewrite_rules', 'feed_dir_rewrite');

As the array is so simple here, there is no need to call generate_rewrite_rules(). Again, the plugin's rules are added to WordPress'. Notice thatas this function filters generate_rewrite_rules, it accepts a reference to the entire $wp_rewrite object as a parameter, not just the rewrite rules.

Of course, as you're adding your rewrite rules to the array before WordPress does anything with them, your plugins rewrite rules will beincluded in anything WordPress does with the rewrite rules, like write them to the .htaccess file.

Non-Wordpress rewrite rules

<?php $wp_rewrite->non_wp_rules = array( 'Pattern' => 'Substitution' ); print_r($wp_rewrite->mod_rewrite_rules());?>

prints

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /wp_home/ RewriteRule ^Pattern /wp_home/Substitution [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wp_home/index.php [L] </IfModule>

where /wp_home/ is Wordpress's home directory (or the root URL / if Wordpress is installed in your web root.)

Retrieved from "http://codex.wordpress.org/Function_Reference/WP_Rewrite"Category: Functions

Function Reference/Walker Class

Contents1 Role of Walker2 Methods and Properties

2.1 Properties2.1.1 Example

2.2 Methods3 Examples

Role of Walker

The walker class encapsulates the basic functionality necessary to output HTML representing WordPress objects with a tree structure. Forinstance pages and categories are the two types of objects that the WordPress 2.2 code uses the walker class to enumerate. While one couldalways display categories as you wished by using right func and looping through them using it takes a great deal of work to arrangesubcategories below their parents with proper formatting. The walker class takes care of most of this work for you.

Methods and Properties

Note that the properties of the Walker class are intended to be set by the extending class and probably should not vary over the lifetime of aninstance.

Also the method definitions of start_el, end_el, start_lvl, end_lvl only list one argument but are called using call_user_func_array and it is thesearguments that are listed.

Properties

$tree_type The classes extending Walker in the WordPress 2.2 distribution set this either to 'category' or 'page'. The code makes no use of thisvalue.

Page 176: wp-api

$db_fields An array with keys: parent and id. The value for these keys should be the name of the property in the objects walker will be applied toholding the id of the current object and parent object respectively.

Example

class Walker_Page extends Walker {var $tree_type = 'page';var $db_fields = array ('parent' =>

'post_parent', 'id' => 'ID');

Thus the Walker_Page class (part of wordpress 2.2) expects that if page is a page object then page->post_parent will give the id of that page'sparent and page->ID will give the id of that page.

Methods

walk($elements, $to_depth) Takes an array of elements ordered so that children occur below their parents and an integer $to_depth. A non-zero $to_depth caps themaximum depth to which the method will descend. If $to_depth is -1 the array is processed as if it was flat (no element is the child ofanother). Any additional arguments passed to walk will be passed unchanged to the other methods walk calls.

walk steps through the array $elements one by one. Each time an element is the child of the prior element walk calls start_lvl. Every time anelement is processed walk calls start_el and then end_el. Each time an element is no longer below one of the current parents walk callsend_lvl.

start_el($output, $element, $depth, \[optional args\]) Classes extending Walker should define this function to return $output concatenated with the markup starting an element.

end_el($output, $element, $depth, \[optional args\]) Classes extending Walker should define this function to return $output concatenated with the markup ending an element. Note thatelements are not ended until after all of their children have been added.

start_lvl($output, $depth, \[optional args\]) Classes extending Walker should define this function to return $output concatenated with the markup that should precede any of thechild elements. For instance this often outputs a ul or ol tag.

end_lvl($output, $depth, \[optional args\]) Classes extending Walker should define this function to return $output concatenated with the markup that should end any of the childelements. For instance this often ends a ul or ol tag.

Examples

See Function_Reference/Walker_Page, Function_Reference/Walker_PageDropDown, Function_Reference/Walker_Category,Function_Reference/Walker_CategoryDropdown

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/Walker_Class"Categories: Functions | New page created | Copyedit

Function Reference/ 2

This page is named incorrectly due to a limitation of Mediawiki page naming. The function name is __ not _2.

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Page 177: wp-api

Retrieves the translated string from the translate().

Usage

<?php __( $text, $domain ) ?>

Parameters

$text(string) (required) Text to translate

Default: None

$domain(string) (optional) Domain to retrieve the translated text

Default: 'default'

Return Values

(string) Translated text

ExamplesNotes

See translate() An alias of translate()l10n is an abbreviation for localization.The function name is two underscores in a row. In some fonts it looks like one long underscore. (Who says programmers don't have asense of humor.)

Change Log

Since: 2.1.0

Source File

__() is located in wp-includes/l10n.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/_2"Categories: Functions | New page created

Function Reference/ e

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Displays the returned translated text from translate().

Usage

<?php _e( $text, $domain ) ?>

Parameters

$text(string) (required) Text to translate

Default: None

$domain(string) (optional) Domain to retrieve the translated text

Default: 'default'

Page 178: wp-api

Return Values

(void) This function does not return a value.

ExamplesNotes

Echos returned translate() string.l10n is an abbreviation for localization.

Change Log

Since: 1.2.0

Source File

_e() is located in wp-includes/l10n.php.

Related

__()

Retrieved from "http://codex.wordpress.org/Function_Reference/_e"Categories: Functions | New page created

Function Reference/ get category link

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples

5.1 Category Link6 Notes7 Change Log8 Source File9 Related

Description

Retrieve category link URL.

Usage

<?php get_category_link( $category_id ) ?>

Parameters

$category_id(integer) (required) Category ID.

Default: None

Return Values

(string) Category URI.

ExamplesCategory Link

<?php // Get the ID of a given category $category_id = get_cat_ID( 'Category Name' );

// Get the URI of this category $category_link = get_category_link( $category_id );?>

<!-- Print a link to this category -->

Page 179: wp-api

<a href="<?php echo $category_link; ?>" title="Category Name">Category Name</a>

Notes

Uses: apply_filters() Calls 'category_link' filter on category link and category ID.Uses global: (unknown) $wp_rewrite

Change Log

Since: 1.0.0

Source File

get_category_link() is located in wp-includes/category-template.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/_get_category_link"Categories: Functions | New page created

Function Reference/ ngettext

This page is named incorrectly due to a limitation of Mediawiki page naming. The function name is __ngettext not _ngettext.

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the plural or single form based on the amount.

If the domain is not set in the $l10n list, then a comparsion will be made and either $plural or $single parameters returned.

If the domain does exist, then the parameters $single, $plural, and $number will first be passed to the domain's ngettext method. Then it will bepassed to the 'ngettext' filter hook along with the same parameters. The expected type will be a string.

Usage

<?php __ngettext( $single, $plural, $number, $domain ) ?>

Parameters

$single(string) (required) The text that will be used if $number is 1

Default: None

$plural(string) (required) The text that will be used if $number is not 1

Default: None

$number(integer) (required) The number to compare against to use either $single or $plural

Default: None

$domain(string) (optional) The domain identifier the text should be retrieved in

Default: 'default'

Return Values

(string) Either $single or $plural translated text

Examples

Page 180: wp-api

Notes

Uses: apply_filters() Calls 'ngettext' hook on domains text returned, along with $single, $plural, and $number parameters. Expected toreturn string.Uses global: (array) $l10n Gets list of domain translated string (gettext_reader) objects.l10n is an abbreviation for localization.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

Source File

__ngettext() is located in wp-includes/l10n.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/_ngettext"Categories: Functions | New page created

Function Reference/add action

Contents1 Description2 Usage3 Examples4 Parameters

Description

Hooks a function on to a specific action.

See Plugin API/Action Reference for a list of hooks for action. Actions are (usually) triggered when the Wordpress core calls do_action().

Usage

<?php add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1); ?>

Examples

To email some friends whenever an entry is posted on your blog:

function email_friends($post_ID) { $friends = '[email protected], [email protected]'; mail($friends, "sally's blog updated" , 'I just put something on my blog: http://blog.example.com'); return $post_ID;}

add_action('publish_post', 'email_friends');

Parameters

$tag (string) The name of the action you wish to hook onto. (See Plugin API/Action Reference for a list of action hooks)

$function_to_add (callback) The name of the function you wish to be called. Note: any of the syntaxes explained in the PHP documentation for the'callback' type are valid.

$priority How important your function is. Alter this to make your function be called before or after other functions. The default is 10, so (forexample) setting it to 5 would make it run earlier and setting it to 12 would make it run later.

$accepted_args How many arguments your function takes. In WordPress 1.5.1+, hooked functions can take extra arguments that are set when thematching do_action() or apply_filters() call is run. For example, the action comment_id_not_found will pass any functions that hook ontoit the ID of the requested comment.

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/add_action"Categories: Functions | Copyedit

Page 181: wp-api

Function Reference/add custom image header

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Add callbacks for image header display.

The parameter $header_callback callback will be required to display the content for the 'wp_head' action. The parameter$admin_header_callback callback will be added to Custom_Image_Header class and that will be added to the 'admin_menu' action.

Usage

<?php add_custom_image_header( $header_callback, $admin_header_callback ) ?>

Parameters

$header_callback(callback) (required) Call on 'wp_head' action.

Default: None

$admin_header_callback(callback) (required) Call on administration panels.

Default: None

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: Custom_Image_Header. Sets up for $admin_header_callback for administration panel display.

Change Log

Since: 2.1.0

Source File

add_custom_image_header() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/add_custom_image_header"Categories: Functions | New page created

Function Reference/add filter

Contents1 Description2 Usage3 Parameters4 Return

Description

Hooks a function to a specific filter action.

Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browserscreen. Plugins can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter

Page 182: wp-api

API. See the Plugin API for a list of filter hooks.

Usage

<?php add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1); ?>

Parameters

$tag(string) (required) The name of the filter to hook the $function_to_add to.

Default: None

$function_to_add(callback) (required) The name of the function to be called when the filter is applied.

Default: None

$priority(integer) (option) Used to specify the order in which the functions associated with a particular action are executed. Lower numberscorrespond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.

Default: 10

$accepted_args(integer) (required) The number of arguments the function(s) accept(s). In WordPress 1.5.1 and newer. hooked functions can take extraarguments that are set when the matching do_action() or apply_filters() call is run.

Default: None

You may need to supply a pointer to the function's namespace for some filter callbacks, e.g.

<?php add_filter('media_upload_newtab', array(&$this, 'media_upload_mycallback')); ?>

Otherwise WordPress looks in its own namespace for the function, which can cause abnormal behaviour.

Return

true if the $function_to_add is added successfully to filter $tag. How many arguments your function takes. In WordPress 1.5.1+, hookedfunctions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. For example, the actioncomment_id_not_found will pass any functions that hook onto it the ID of the requested comment.

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/add_filter"Categories: Functions | New page created | Copyedit

Function Reference/add magic quotes

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Walks an array while sanitizing the contents.

Usage

<?php add_magic_quotes( $array ) ?>

Parameters

$array(array) (required) Array to used to walk while sanitizing contents.

Default: None

Return Values

Page 183: wp-api

(array) Sanitized $array.

ExamplesNotes

Uses global: (object) $wpdb to sanitize values

Change Log

Since: 0.71

Source File

add_magic_quotes() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/add_magic_quotes"Categories: Functions | New page created

Function Reference/add meta box

Contents1 Description2 Usage3 Example4 Parameters5 Further Reading

Description

The add_meta_box() function was introduced in WordPress 2.5. It allows plugin developers to add sections to the Write Post, Write Page, andWrite Link editing pages.

Usage

<?php add_meta_box('id', 'title', 'callback', 'page', 'context', 'priority'); ?>

Example

Here is an example that adds a custom section to the post and page editing screens. It will will work with WordPress 2.5 and also with earlierversions of WordPress (when the add_meta_box function did not exist).

<?php/* Use the admin_menu action to define the custom boxes */add_action('admin_menu', 'myplugin_add_custom_box');

/* Use the save_post action to do something with the data entered */add_action('save_post', 'myplugin_save_postdata');

/* Adds a custom section to the "advanced" Post and Page edit screens */function myplugin_add_custom_box() {

if( function_exists( 'add_meta_box' )) { add_meta_box( 'myplugin_sectionid', __( 'My Post Section Title', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'post', 'advanced' ); add_meta_box( 'myplugin_sectionid', __( 'My Post Section Title', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'page', 'advanced' ); } else { add_action('dbx_post_advanced', 'myplugin_old_custom_box' ); add_action('dbx_page_advanced', 'myplugin_old_custom_box' ); }} /* Prints the inner fields for the custom post/page section */function myplugin_inner_custom_box() {

// Use nonce for verification

Page 184: wp-api

echo '<input type="hidden" name="myplugin_noncename" id="myplugin_noncename" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" />';

// The actual fields for data entry

echo '<label for="myplugin_new_field">' . __("Description for this field", 'myplugin_textdomain' ) . '</label> '; echo '<input type="text" name="myplugin_new_field" value="whatever" size="25" />';}

/* Prints the edit form for pre-WordPress 2.5 post/page */function myplugin_old_custom_box() {

echo '<div class="dbx-b-ox-wrapper">' . "\n"; echo '<fieldset id="myplugin_fieldsetid" class="dbx-box">' . "\n"; echo '<div class="dbx-h-andle-wrapper"><h3 class="dbx-handle">' . __( 'My Post Section Title', 'myplugin_textdomain' ) . "</h3></div>"; echo '<div class="dbx-c-ontent-wrapper"><div class="dbx-content">';

// output editing form

myplugin_inner_custom_box();

// end wrapper

echo "</div></div></fieldset></div>\n";}

/* When the post is saved, saves our custom data */function myplugin_save_postdata( $post_id ) {

// verify this came from the our screen and with proper authorization, // because save_post can be triggered at other times

if ( !wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__) )) { return $post_id; }

if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_page', $post_id )) return $post_id; } else { if ( !current_user_can( 'edit_post', $post_id )) return $post_id; }

// OK, we're authenticated: we need to find and save the data

$mydata = $_POST['myplugin_new_field'];

// TODO: Do something with $mydata // probably using add_post_meta(), update_post_meta(), or // a custom table (see Further Reading section below)

return $mydata;}?>

Parameters

$id (string) HTML 'id' attribute of the edit screen section

title (string) Title of the edit screen section, visible to user

callback (string) Function that prints out the HTML for the edit screen section.

page (string) The type of Write screen on which to show the edit screen section ('post', 'page', or 'link')

Page 185: wp-api

context (string) The part of the page where the edit screen section should be shown ('normal', 'advanced' or (since 2.7) 'side')

priority (string) The priority within the context where the boxes should show ('high' or 'low')

Further Reading

Migrating Plugins and ThemesFunction ReferenceCreating Tables with Pluginsupdate_post_meta() functionadd_post_meta() function

Retrieved from "http://codex.wordpress.org/Function_Reference/add_meta_box"Category: Functions

Function Reference/add option

Contents1 Description2 Usage for wp 2.3.X or newer3 Example for wp 2.3.X or newer4 Parameters for wp 2.3.X or newer5 Usage before $description deprecated6 Example7 Parameters before $description deprecated

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 issaved, it can be accessed with get_option(), changed with update_option(), and deleted with delete_option().

The data is escaped with $wpdb->escape before the INSERT statement.

Usage for wp 2.3.X or newer

In the lasts versions of WordPress (2.3.X) the parameter $description is deprecated and remove the values from the wp_options table. Theusage is the same but the second parameter its unused.

See below for older version of this reference

<?php add_option($name, $value = '', $deprecated = '', $autoload = 'yes'); ?>

Example for wp 2.3.X or newer

<?php add_option("myhack_extraction_length", '255', '', 'yes'); ?>

Parameters for wp 2.3.X or newer

$name(string) (required) Name of the option to be added. Use underscores to separate words, and do not use uppercase—this is going to beplaced into the database.

Default: None

$value(string) (optional) Value for this option name.

Default: Empty

$deprecated(string) (optional) Unused.

Default: Empty

$autoload(string) (optional) Should this option be automatically loaded by the function wp_load_alloptions (puts options into object cache on eachpage load)? Valid values: yes or no.

Default: yes

Usage before $description deprecated

In the last versions of wordpress (2.3.X) the parameter $description is deprecated and remove the values from the wp_options table.The usage its the same but the seccond parameter its unused.

Page 186: wp-api

WP 2.3.X or newer <?php add_option($name, $value = '', $deprecated = '', $autoload = 'yes'); ?>

<?php add_option($name, $value = '', $description = '', $autoload = 'yes'); ?>

Example

<?php add_option("myhack_extraction_length", '255', 'Max length of extracted text in characters.', 'yes'); ?>

Parameters before $description deprecated

$name(string) (required) Name of the option to be added. Use underscores to separate words, and do not use uppercase—this is going to beplaced into the database.

Default: None

$value(string) (optional) Value for this option name.

Default: Empty

$description(string) (optional) Descriptive text for the option. The description can be used in backend labels.

Default: Empty

$autoload(string) (optional) Should this option be automatically loaded? Valid values: yes or no.

Default: yes

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/add_option"Categories: Functions | Copyedit

Function Reference/add ping

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Add a URL to those already pung.

Usage

<?php add_ping( $post_id, $uri ) ?>

Parameters

$post_id(integer) (required) Post ID.

Default: None

$uri(string) (required) Ping URI.

Default: None

Return Values

(integer) Count of updated rows.

Examples

Page 187: wp-api

Notes

Uses global: (object) $wpdb to read and to update the _posts table in database.Uses: apply_filters() on 'add_ping'

Change Log

Since: 1.5.0

Source File

add_ping() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/add_ping"Categories: Functions | New page created

Function Reference/add post meta

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Adding or updating a unique field3.3 Other Examples3.4 Making a "Hidden" Custom Field

4 Parameters5 Related

Description

add_post_meta adds a custom (meta) field to the specified post.

If the $unique parameter is set to true and the specified meta key already exists, the function returns false and makes no changes; otherwise, itreturns true.

Usage

<?php add_post_meta($post_id, $meta_key, $meta_value, $unique); ?>

ExamplesDefault Usage

<?php add_post_meta(68, 'my_key', 47); ?>

Adding or updating a unique field

Adds a new field if the key doesn't exist, or updates the existing field. (UPDATE: If the forth parameter of add_post_meta is set to true, the fieldwill not be update if it already exists (tested on WP 2.6.2). Use if (!update_post_meta(...)) add_post_meta(...))

<?php add_post_meta(7, 'fruit', 'banana', true) or update_post_meta(7, 'fruit', 'banana'); ?>

Other Examples

If you wanted to make sure that there were no fields with the key "my_key", before adding it:

<?php add_post_meta(68, 'my_key', '47', true); ?>

To add several values to the key "my_key":

<?php add_post_meta(68, 'my_key', '47'); ?><?php add_post_meta(68, 'my_key', '682'); ?><?php add_post_meta(68, 'my_key', 'The quick, brown fox jumped over the lazy dog.'); ?>...

For a more detailed example, go to the post_meta Functions Examples page.

Making a "Hidden" Custom Field

If you are a plugin / theme developer and you are planning to use custom fields to store parameters related to your plugin or template, it isinteresting to note that WordPress wont show keys starting with an "_" (underscore) in the custom fields list at the page / post editing page.

Page 188: wp-api

That being said, it is a good practice to use an underscore as the first character in your custom parameters, that way your settings are storedas custom fields, but they won't display in the custom fields list in the admin UI.

The following example:

<?php add_post_meta(68, '_color', 'red', true); ?>

will add a unique custom field with the key name "_color" and the value "red" but this custom field will not display in the page / post editingpage.

Parameters

$post_id(integer) (required) The ID of the post to which you will add a custom field.

Default: None

$meta_key(string) (required) The key of the custom field you will add.

Default: None

$meta_value(string) (required) The value of the custom field you will add.

Default: None

$unique(boolean) (optional) Whether or not you want the key to be unique. When set to true, this will ensure that there is not already a customfield attached to the post with $meta_key as it's key, and, if such a field already exists, the key will not be added.

Default: false

Related

delete_post_meta(), get_post_meta(), update_post_meta(), get_post_custom(), get_post_custom_values(), get_post_custom_keys()

Retrieved from "http://codex.wordpress.org/Function_Reference/add_post_meta"Categories: Functions | New page created | Needs Review

Function Reference/add query arg

This is the information found in the source about this function.

Retrieve a modified URL query string.

You can rebuild the URL and append a new query variable to the URL query by using this function. You can also retrieve the full URL with query data.

Adding a single key & value or an associative array. Setting a key value to emptystring removes the key. Omitting oldquery_or_uri uses the $_SERVER value.

@since 1.5.0

@param mixed $param1 Either newkey or an associative_array @param mixed $param2 Either newvalue or oldquery or uri @param mixed $param3 Optional. Old query or uri @return string New URL query string.

Retrieved from "http://codex.wordpress.org/Function_Reference/add_query_arg"

Function Reference/addslashes gpc

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Page 189: wp-api

Description

Adds slashes to escape strings.

Slashes will first be removed if magic-quotes-gpc is set, see magic_quotes for more details.

Usage

<?php addslashes_gpc( $gpc ) ?>

Parameters

$gpc(string) (required) The string returned from HTTP request data.

Default: None

Return Values

(string) Returns a string escaped with slashes.

ExamplesNotes

Uses global: (object) $wpdbIn this context, this: '\' is a slash.

Change Log

Since: 0.71

Source File

addslashes_gpc() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/addslashes_gpc"Categories: Functions | New page created

Function Reference/antispambot

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Converts email addresses characters to HTML entities to block spam bots.

Usage

<?php antispambot( $emailaddy, $mailto ) ?>

Parameters

$emailaddy(string) (required) Email address.

Default: None

$mailto(integer) (optional) 0 or 1. Used for encoding.

Default: 0

Return Values

Page 190: wp-api

(string) Converted email address.

ExamplesNotesChange Log

Since: 0.71

Source File

antispambot() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/antispambot"Categories: Functions | New page created

Function Reference/apply filters

Contents1 Description2 Usage3 Parameters4 Return

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 $tag are invoked by calling this function. This function can be used to create a new filter hook bysimply calling this function with the name of the new hook specified using the $tag parameter.

Usage

<?php apply_filters($tag, $value); ?>

Parameters

$tag(string) (required) The name of the filter hook.

Default: None

$value(mixed) (required) The value which the filters hooked to $tag may modify.

Default: None

Return

(mixed) The result of $value 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.

Retrieved from "http://codex.wordpress.org/Function_Reference/apply_filters"Categories: Functions | New page created

Function Reference/attribute escape

← Return to function reference.

Description

This function escapes or encodes HTML special characters (including single and double quotes) for use in HTML attriutes. It works like thestandard PHP htmlspecialchars except that it doesn't double-encode HTML entities (i.e. it replaces &&, for example, with &#038;&).

attribute_escape can be found in /wp-includes/formatting.php.

Usage

<?php echo attribute_escape($text); ?>

Page 191: wp-api

Parameters

$text(string) Text to be escaped.

Retrieved from "http://codex.wordpress.org/Function_Reference/attribute_escape"Category: Functions

Function Reference/auth redirectDescription

auth_redirect() is a simple function that requires that the user be logged in before they can access a page.

Default Usage

<?php auth_redirect() ?>

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 redirectedto 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 toaccess.

Parameters

This function accepts no parameters.

Related

is_user_logged_in(), wp_redirect()

Retrieved from "http://codex.wordpress.org/Function_Reference/auth_redirect"Categories: Needs Review | Functions | New page created

Function Reference/backslashit

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Adds backslashes before letters and before a number at the start of a string.

Usage

<?php backslashit( $string ) ?>

Parameters

$string(string) (required) Value to which backslashes will be added.

Default: None

Return Values

(string) String with backslashes inserted.

ExamplesNotes

This: '\' is a backslash.

Page 192: wp-api

Change Log

Since: 0.71

Source File

backslashit() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/backslashit"Categories: Functions | New page created

Function Reference/balanceTags

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Will only balance the tags if forced to and the option is set to balance tags.

The option 'use_balanceTags' is used for whether the tags will be balanced. Both the $force parameter and 'use_balanceTags' option will haveto be true before the tags will be balanced.

Usage

<?php balanceTags( $text, $force ) ?>

Parameters

$text(string) (required) Text to be balanced

Default: None

$force(boolean) (optional) Forces balancing, ignoring the value of the option.

Default: false

Return Values

(string) Balanced text

ExamplesNotesChange Log

Since: 0.71

Source File

balanceTags() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/balanceTags"Categories: Functions | New page created

Function Reference/bloginfo rss

Contents1 Description

Page 193: wp-api

2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display RSS container for the bloginfo function.

You can retrieve anything that you can using the get_bloginfo() function. Everything will be stripped of tags and characters converted, when thevalues are retrieved for use in the feeds.

Usage

<?php bloginfo_rss( $show ) ?>

Parameters

$show(string) (optional) See get_bloginfo() for possible values.

Default: ''

Return Values

(void) This function does not return a value.

ExamplesNotes

See get_bloginfo() For the list of possible values to display.Uses: apply_filters() Calls 'bloginfo_rss' hook with two parameters.

Change Log

Since: 0.71

Source File

bloginfo_rss() is located in wp-includes/feed.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/bloginfo_rss"Categories: Functions | New page created

Function Reference/bool from yn

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Whether input is yes or no. Must be 'y' to be true.

Usage

<?php bool_from_yn( $yn ) ?>

Parameters

Page 194: wp-api

$yn(string) (required) Character string containing either 'y' or 'n'

Default: None

Return Values

(boolean) True if yes, false on anything else

ExamplesNotes

'y' returns true,'Y' returns true,Everything else returns false.

Change Log

Since: 1.0.0

Source File

bool_from_yn() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/bool_from_yn"Categories: Functions | New page created

Function Reference/cache javascript headers

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Set the headers for caching for 10 days with JavaScript content type.

Usage

<?php cache_javascript_headers() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotesChange Log

Since: 2.1.0

Source File

cache_javascript_headers() is located in wp-includes/functions.php.

Related

Page 195: wp-api

Retrieved from "http://codex.wordpress.org/Function_Reference/cache_javascript_headers"Categories: Functions | New page created

Function Reference/cat is ancestor of

Contents1 Description2 Usage3 Notes4 Further Reading

Description

This is a simple function for evaluating if the second category is a child of another category.

Usage

<?php cat_is_ancestor_of(cat1, cat2); ?>

Returns true if cat1 is an ancestor of cat2. Any level of ancestry will return true.

Arguments should be either integer category IDs or category objects.

Notes

If arguments are string representations of integers and not true integers cat_is_ancestor_of will return false.

Further Reading

Function_Reference

Retrieved from "http://codex.wordpress.org/Function_Reference/cat_is_ancestor_of"Categories: Functions | Conditional Tags

Function Reference/check admin referer

Contents1 Description2 Parameters3 Usage4 See also

Description

Makes sure that a user was referred from another admin page, to avoid security exploits. Nonces related.

Parameters

$action(string) (defaults to int -1) Action nonce

Default: -1

$query_arg(string) (optional) where to look for nonce in $_REQUEST (since 2.5)

Default: '_wpnonce'

Usage

<?php check_admin_referer('bcn_admin_options'); ?>

See also

wp_verify_noncedo_actionWordpress Nonce ImplementationFunction Reference

This page is marked as incomplete. You can help Codex by expanding it.

Page 196: wp-api

Retrieved from "http://codex.wordpress.org/Function_Reference/check_admin_referer"Categories: Stubs | Functions

Function Reference/check ajax referer

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Verifies the AJAX request to prevent processing requests external of the blog.

Usage

<?php check_ajax_referer( $action, $query_arg, $die ) ?>

Parameters

$action(string) (optional) Action nonce

Default: -1

$query_arg(string) (optional) where to look for nonce in $_REQUEST (since 2.5)

Default: false

$die(unknown) (optional)

Default: true

Return Values

(void) This function does not return a value.

ExamplesNotes

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Change Log

Since: 2.0.4

Source File

check_ajax_referer() is located in wp-includes/pluggable.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/check_ajax_referer"Categories: Functions | New page created

Function Reference/check comment

This article is marked as in need of editing. You can help Codex by editing it.

Contents1 Description2 Usage3 Parameters

Page 197: wp-api

4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

check_comment() checks whether a comment passes internal checks set by WordPress Comment_Moderation.

Usage

<?php check_comment( $author, $email, $url, $comment, $user_ip, $user_agent, $comment_type ) ?>

Parameters

$author(string) (required) Comment author name.

Default: None

$email(string) (required) Comment author email.

Default: None

$url(string) (required) Comment author URL.

Default: None

$comment(string) (required) Comment contents.

Default: None

$user_ip(string) (required) Comment author IP address.

Default: None

$user_agent(string) (required) Comment author user agent.

Default: None

$comment_type(string) (required) Comment type (comment, trackback, or pingback).

Default: None

Return Values

(boolean) This function returns a single boolean value of either true or false.

Returns false if in Comment_Moderation:

The Administrator must approve all messages,The number of external links is too high, orAny banned word, name, URL, e-mail, or IP is found in any parameter except $comment_type.

Returns true if the Administrator does not have to approve all messages and:

$comment_type parameter is a trackback or pingback and part of the blogroll, or$author and $email parameters have been approved previously.

Returns true in all other cases.

ExamplesNotes

Uses: $wpdbUses: get_option()

Change Log

Since: WordPress Version 1.2

Page 198: wp-api

Source File

check_comment() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/check_comment"Categories: Copyedit | Functions | New page created

Function Reference/clean pre

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Accepts matches array from preg_replace_callback in wpautop() or a string.

Ensures that the contents of a <pre>...</pre> HTML block are not converted into paragraphs or line-breaks.

Usage

<?php clean_pre( $matches ) ?>

Parameters

$matches(array|string) (required) The array or string

Default: None

Return Values

(string) The pre block without paragraph/line-break conversion.

ExamplesNotes

Note: If $matches is an array the array values are concatenated into a string.

Change Log

Since: 1.2.0

Source File

clean_pre() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/clean_pre"Categories: Functions | New page created

Function Reference/clean url

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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 (&) are also replaced. The'clean_url' filter is applied to the returned cleaned URL.

Usage

<?php clean_url( $url, $protocols, $context ) ?>

Page 199: wp-api

Parameters

$url(string) (required) The URL to be cleaned.

Default: None

$protocols(array) (optional) An array of acceptable protocols. Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet'if not set.

Default: null

$context(string) (optional) How the URL will be used. Default is 'display'.

Default: 'display'

Return Values

(string) The cleaned $url after the 'cleaned_url' filter is applied.

ExamplesNotes

Uses: wp_kses_bad_protocol() to only permit protocols in the URL set via $protocols or the common ones set in the function.

Change Log

Since: 1.2.0

Source File

clean_url() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/clean_url"Categories: Functions | New page created

Function Reference/comment author rss

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display the current comment author in the feed.

Usage

<?php comment_author_rss() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotes

Page 200: wp-api

Echos the return from get_comment_author_rss().

Change Log

Since: 1.0.0

Source File

comment_author_rss() is located in wp-includes/feed.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/comment_author_rss"Categories: Functions | New page created

Function Reference/comment link

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display the link to the comments.

Usage

<?php comment_link() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotes

Echos the return value of get_comment_link().

Change Log

Since: 1.5.0

Source File

comment_link() is located in wp-includes/feed.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/comment_link"Categories: Functions | New page created

Function Reference/comment text rss

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log

Page 201: wp-api

8 Source File9 Related

Description

Display the current comment content for use in the feeds.

Usage

<?php comment_text_rss() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: apply_filters() Calls 'comment_text_rss' filter on comment content.Uses: get_comment_text()

Change Log

Since: 1.0.0

Source File

comment_text_rss() is located in wp-includes/feed.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/comment_text_rss"Categories: Functions | New page created

Function Reference/convert chars

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Converts a number of characters from a string.

Metadata tags <title> and <category> are removed, <br> and <hr> are converted into correct XHTML and Unicode characters are converted tothe valid range.

Usage

<?php convert_chars( $content, $deprecated ) ?>

Parameters

$content(string) (required) String of characters to be converted.

Default: None

$deprecated(string) (optional) Not used.

Default: ''

Page 202: wp-api

Return Values

(string) Converted string.

ExamplesNotesChange Log

Since: 0.71

Source File

convert_chars() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/convert_chars"Categories: Functions | New page created

Function Reference/convert smilies

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Convert text equivalent of smilies to images.

Will only convert smilies if the option 'use_smilies' is true and the globals used in the function aren't empty.

Usage

<?php convert_smilies( $text ) ?>

Parameters

$text(string) (required) Content to convert smilies from text.

Default: None

Return Values

(string) Converted content with text smilies replaced with images.

ExamplesNotes

Uses: $wp_smiliessearch, $wp_smiliesreplace Smiley replacement arrays.Uses global: (array) $wp_smiliessearchUses global: (array) $wp_smiliesreplace

Change Log

Since: 0.71

Source File

convert_smilies() is located in wp-includes/formatting.php.

Related

Page 203: wp-api

Using_SmiliesGlossary: Smileys

Retrieved from "http://codex.wordpress.org/Function_Reference/convert_smilies"Categories: Functions | New page created

Function Reference/current time

Contents1 Description2 Usage3 Example

3.1 Usage4 Parameters

Description

Returns the current time or timestamp. The time returned will be the server time + the offset in the options page, and it will be equivalent to thetime displayed on the options page itself.

Usage

<?php echo current_time($type, $gmt = 0); ?>

Example

This example gets the current time and assigns the parameters to variables.

<?php $blogtime = current_time('mysql'); list( $today_year, $today_month, $today_day, $hour, $minute, $second ) = split( '([^0-9])', $blogtime );?>

Usage

Get the current system time in two formats.

<?php echo('Current time: ' . current_time('mysql') . '<br />'); ?><?php echo('Current timestamp: ' . current_time('timestamp')); ?>

Current time: 2005-08-05 10:41:13Current timestamp: 1123238473

Parameters

$type(string) (required) The time format to return. Possible values:

mysqltimestampDefault: None

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/current_time"Categories: Functions | Copyedit

Function Reference/date i18n

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Page 204: wp-api

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 stringwill be used instead.

i18n is an abbreviation for Internationalization. (There are 18 letters between the first "i" and last "n".)

Usage

<?php date_i18n( $dateformatstring, $unixtimestamp, $gmt ) ?>

Parameters

$dateformatstring(string) (required) Format to display the date

Default: None

$unixtimestamp(integer) (optional) Unix timestamp

Default: false

$gmt(unknown) (optional)

Default: false

Return Values

(string) The date, translated if locale specifies it.

ExamplesNotes

See Also: i18nUses global: (object) $wp_locale handles the date and time locales.

Change Log

Since: 0.71

Source File

date_i18n() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/date_i18n"Categories: Functions | New page created

Function Reference/delete option

Contents1 Description2 Usage3 Example

3.1 Usage4 Parameters

Description

A safe way of removing a named option/value pair from the options database table.

Usage

<?php delete_option($name); ?>

ExampleUsage

Page 205: wp-api

<?php delete_option("myhack_extraction_length"); ?>

Parameters

$name(string) (required) Name of the option to be deleted. A list of valid default options can be found at the Option Reference.

Default: None

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/delete_option"Categories: Functions | Copyedit

Function Reference/delete post meta

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Other Examples

4 Parameters5 Related

Description

This function deletes all custom fields with the specified key from the specified post. See also update_post_meta(), get_post_meta() andadd_post_meta().

Usage

<?php delete_post_meta($post_id, $key, $value); ?>

ExamplesDefault Usage

<?php delete_post_meta(76, 'my_key', 'Steve'); ?>

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 thepost meta keys that the plugin added. Assuming the plugin added the keys related_posts and post_inspiration.

To delete all the keys, this would be added to the "uninstall" function:

<?php $allposts = get_posts('numberposts=0&post_type=post&post_status=');

foreach( $allposts as $postinfo) { delete_post_meta($postinfo->ID, 'related_posts'); delete_post_meta($postinfo->ID, 'post_inspiration'); }?>

Or, if you wanted to delete all the keys except where post_inspiration was "Sherlock Holmes":

<?php $allposts = get_posts('numberposts=0&post_type=post&post_status=');

foreach( $allposts as $postinfo) { delete_post_meta($postinfo->ID, 'related_posts'); $inspiration = get_post_meta( $postinfo->ID, 'post_inspiration ); foreach( $inspiration as $value ) { if( $value != "Sherlock Holmes" ) delete_post_meta($postinfo->ID, 'post_inspiration', $value); } }?>

Or maybe post number 185 was just deleted, and you want to remove all related_posts keys that reference it:

Page 206: wp-api

<?php $allposts = get_posts('numberposts=0&post_type=post&post_status=');

foreach( $allposts as $postinfo) { delete_post_meta($postinfo->ID, 'related_posts', '185'); }?>

For a more detailed example, go to the post_meta Functions Examples page.

Note: Unlike update_post_meta(), This function will delete all fields that match the criteria.

Parameters

$post_id(integer) (required) The ID of the post from which you will delete a field.

Default: None

$key(string) (required) The key of the field you will delete.

Default: None

$value(string) (optional) The value of the field you will delete. This is used to differentiate between several fields with the same key. If leftblank, all fields with the given key will be deleted.

Default: None

Related

update_post_meta(), get_post_meta(), add_post_meta(), get_post_custom(), get_post_custom_values(), get_post_custom_keys()

Retrieved from "http://codex.wordpress.org/Function_Reference/delete_post_meta"Categories: Functions | New page created | Needs Review

Function Reference/delete usermeta

Contents1 Description2 Usage3 Example4 Parameters

Description

Removes a user meta record from the wp_usermeta database table for a specific user ID.

Usage

<?php delete_usermeta($user_id, $meta_key, $meta_value); ?>

Example

<?php if (delete_usermeta(7, 'first_name')) { echo 'User meta key successfully removed!';} else { echo 'User meta record could not be removed!';} ?>

Parameters

$user_id(integer) (required) The ID of the WordPress user

Default: None

$meta_key(string) (required) The meta_key field value

Default: None

$meta_value(string) (required) The meta_value field value

Default: None

Page 207: wp-api

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/delete_usermeta"Categories: Functions | New page created | Copyedit

Function Reference/did actionDescription

Returns the number times an action is fired.

Parameters

$tag (string) The name of the action hook to check.

Return

(int) The number of times the given action hook, $tag, is fired.

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/did_action"Categories: Stubs | Functions | New page created

Function Reference/discover pingback server uri

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Finds a pingback server URI based on the given URL.

Checks the xhtml for the rel="pingback" link and x-pingback headers. It does a check for the x-pingback headers first and returns that, ifavailable. The check for the rel="pingback" has more overhead than just the header.

Usage

<?php discover_pingback_server_uri( $url, $deprecated ) ?>

Parameters

$url(string) (required) URL to ping.

Default: None

$deprecated(integer) (Not Used.)

Default: None

Return Values

(boolean|string) False on failure, string containing URI on success.

ExamplesNotes

Uses: wp_remote_get()Uses: is_wp_error()

Page 208: wp-api

Change Log

Since: 1.5.0

Source File

discover_pingback_server_uri() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/discover_pingback_server_uri"Categories: Functions | New page created

Function Reference/do actionDescription

Creates a hook for attaching actions via add_action.

Usage

<?php do_action($tag, $arg = ); ?>

Parameters

$tag (string) The name of the hook you wish to create.

$arg (string) The list of arguments this hook accepts.

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/do_action"Categories: Stubs | Functions

Function Reference/do action ref arrayDescription

Execute functions hooked on a specific action hook, specifying arguments in a array.

This function is identical to do_action, but the arguments passed to the functions hooked to $tag are supplied using an array.

Parameters

$tag (string) The name of the action to be executed.

$args (array) The arguments supplied to the functions hooked to $tag

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/do_action_ref_array"Categories: Stubs | Functions

Function Reference/do all pings

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Page 209: wp-api

Perform all pingbacks, enclosures, trackbacks, and send to pingback services.

Usage

<?php do_all_pings() ?>

ParametersReturn Values

(void) This function does not return a value.

ExamplesNotes

See Reads from the _posts table from the database.Uses: $wpdbUses: pingback()Uses: do_enclose()Uses: do_trackbacks()Uses: generic_ping()Uses global: (object) $wpdb

Change Log

Since: 2.1.0

Source File

do_all_pings() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/do_all_pings"Categories: Functions | New page created

Function Reference/do enclose

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Check content for video and audio links to add as enclosures.

Will not add enclosures that have already been added.

Usage

<?php do_enclose( $content, $post_ID ) ?>

Parameters

$content(string) (required) Post Content

Default: None

$post_ID(integer) (required) Post ID

Default: None

Return Values

Page 210: wp-api

(void) This function does not return a value.

ExamplesNotes

Uses global: (object) $wpdb to read and condtionally insert records on _postmeta table in the database.Uses: debug_fopen() to open 'enclosures.log' file.Uses: debug_fwrite() to write to 'enclosures.log' file.Uses: get_enclosed()Uses: wp_get_http_headers()

Change Log

Since: 1.5.0

Source File

do_enclose() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/do_enclose"Categories: Functions | New page created

Function Reference/do feed

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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

<?php do_feed() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: get_query_var() to get 'feed' from $wp_query.Uses: do_action() Calls 'do_feed_$feed' hook, if a hook exists for the feed where $feed is the 'feed' property from $wp_query.Uses global: (object) $wp_query Used to tell if the use a comment feed.

Change Log

Since: 2.1.0

Page 211: wp-api

Source File

do_feed() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/do_feed"Categories: Functions | New page created

Function Reference/do feed atom

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Load either Atom comment feed or Atom posts feed.

Usage

<?php do_feed_atom( $for_comments ) ?>

Parameters

$for_comments(boolean) (required) true for the comment feed, false for normal feed.

Default: None

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: load_template() to load feed templates.

Change Log

Since: 2.1.0

Source File

do_feed_atom() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/do_feed_atom"Categories: Functions | New page created

Function Reference/do feed rdf

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Page 212: wp-api

Description

Load the RDF RSS 0.91 Feed template.

Usage

<?php do_feed_rdf() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: load_template() to load feed template.

Change Log

Since: 2.1.0

Source File

do_feed_rdf() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/do_feed_rdf"Categories: Functions | New page created

Function Reference/do feed rss

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Load the RDF RSS 1.0 Feed template.

Usage

<?php do_feed_rss() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: load_template() to load feed template.

Change Log

Page 213: wp-api

Since: 2.1.0

Source File

do_feed_rss() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/do_feed_rss"Categories: Functions | New page created

Function Reference/do feed rss2

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Load either the RSS2 comment feed or the RSS2 posts feed.

Usage

<?php do_feed_rss2( $for_comments ) ?>

Parameters

$for_comments(boolean) (required) true for the comment feed, false for normal feed.

Default: None

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: load_template() to load feed template.

Change Log

Since: 2.1.0

Source File

do_feed_rss2() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/do_feed_rss2"Categories: Functions | New page created

Function Reference/do robots

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display the robot.txt file content.

The echo content should be with usage of the permalinks or for creating the robot.txt file.

Usage

<?php do_robots() ?>

Page 214: wp-api

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: do_action() Calls 'do_robotstxt' hook for displaying robot.txt rules.

Change Log

Since: 2.1.0

Source File

do_robots() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/do_robots"Categories: Functions | New page created

Function Reference/do trackbacks

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Perform trackbacks.

Usage

<?php do_trackbacks( $post_id ) ?>

Parameters

$post_id(integer) (required) Post ID to do trackbacks on.

Default: None

Return Values

(void) This function does not return a value.

ExamplesNotes

See Reads from and may update the _posts table from the database.Uses global: (object) $wpdbUses: get_to_ping()Uses: get_pung()Uses: wp_html_excerpt()Uses: apply_filters() on 'the_content' on 'post_content'Uses: apply_filters() on 'the_excerpt' on 'post_excerpt'Uses: apply_filters() on 'the_title' on 'post_title'Uses: trackback()

Page 215: wp-api

Change Log

Since: 1.5.0

Source File

do_trackbacks() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/do_trackbacks"Categories: Functions | New page created

Function Reference/email exists

Contents1 Description2 Examples

2.1 Default Usage2.2 Detailed Example

3 Parameter4 Return

Description

This function will check whether or not a given email address ($email) has already been registered to a username, and returns that users ID (orfalse if none exists). See also username_exists.

ExamplesDefault Usage

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 notalready been registered.

<?php if ( email_exists($email) ) { . . . } ?>

Detailed Example

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.

<?php $email = '[email protected]'; if ( email_exists($email) ) echo "That E-mail is registered to user number " . email_exists($email); else echo "That E-mail doesn't belong to any registered users on this site";?>

Parameter

$email(string) (required) The E-mail address to check

Default: None

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 false.

Retrieved from "http://codex.wordpress.org/Function_Reference/email_exists"Categories: Functions | New page created | Needs Review

Function Reference/ent2ncr

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes

Page 216: wp-api

7 Change Log8 Source File9 Related

Description

Converts named entities into numbered entities.

Usage

<?php ent2ncr( $text ) ?>

Parameters

$text(string) (required) The text within which entities will be converted.

Default: None

Return Values

(string) Text with converted entities.

ExamplesNotesChange Log

Since: 1.5.1

Source File

ent2ncr() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/ent2ncr"Categories: Functions | New page created

Function Reference/fetch rss

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

Retrieves an RSS feed and parses it. Uses the MagpieRSS and RSSCache functions for parsing and automatic caching and the Snoopy HTTPclient for the actual retrieval.

Usage

<?phpinclude_once(ABSPATH . WPINC . '/rss.php');$rss = fetch_rss($uri);?>

Example

To get and display a list of links for an existing RSS feed, limiting the selection to the most recent 5 items:

<h2><?php _e('Headlines from AP News'); ?></h2><?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->items, 0, $maxitems);

Page 217: wp-api

?>

<ul><?php if (empty($items)) echo '<li>No items</li>';elseforeach ( $items as $item ) : ?><li><a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'><?php echo $item['title']; ?></a></li><?php endforeach; ?></ul>

Parameters

$uri(URI) (required) The URI of the RSS feed you want to retrieve. The resulting parsed feed is returned, with the more interesting anduseful bits in the items array.

Default: Nonerray.

Related

wp_rss

Retrieved from "http://codex.wordpress.org/Function_Reference/fetch_rss"Category: Functions

Function Reference/force balance tagsDescription

Balances tags of string using a modified stack.

Usage

<?php force_balance_tags($text); ?>

Parameters

$text (string) Text to be balanced

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/force_balance_tags"Categories: Stubs | Functions

Function Reference/form option

Similar to get_option, but removes attributes from result

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/form_option"Categories: New page created | Functions | Stubs

Function Reference/format to edit

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Page 218: wp-api

Description

Acts on text which is about to be edited.

Unless $richedit is set, it is simply a holder for the 'format_to_edit' filter. If $richedit is set true htmlspecialchars will be run on the content,converting special characters to HTML entities.

Usage

<?php format_to_edit( $content, $richedit ) ?>

Parameters

$content(string) (required) The text about to be edited.

Default: None

$richedit(boolean) (optional) Whether or not the $content should pass through htmlspecialchars.

Default: false

Return Values

(string) The text after the filter (and possibly htmlspecialchars.) has been run.

ExamplesNotesChange Log

Since: 0.71

Source File

format_to_edit() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/format_to_edit"Categories: Functions | New page created

Function Reference/format to post

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Holder for the 'format_to_post' filter.

Usage

<?php format_to_post( $content ) ?>

Parameters

$content(string) (required) The text to pass through the filter.

Default: None

Return Values

(string)

Page 219: wp-api

Text returned from the 'format_to_post' filter.

ExamplesNotesChange Log

Since: 0.71

Source File

format_to_post() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/format_to_post"Categories: Functions | New page created

Function Reference/funky javascript fix

funky_javascript_fix (line 626)

Fixes javascript bugs in browsers.

Converts unicode characters to HTML numbered entities.

* return: Fixed text. * since: 1.5.0 * uses: $is_winIE * uses: $is_macIE

string funky_javascript_fix (string $text)

* string $text: Text to be made safe.

http://phpdoc.ftwr.co.uk/wordpress/WordPress/_wp-includes---formatting.php.html

Retrieved from "http://codex.wordpress.org/Function_Reference/funky_javascript_fix"

Function Reference/generic ping

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Sends pings to all of the ping site services.

Usage

<?php generic_ping( $post_id ) ?>

Parameters

$post_id(integer) (optional) Post ID. Only used as a return velue.

Default: 0

Return Values

(integer) Returns $post_id unaltered.

Examples

Page 220: wp-api

Notes

The $post_id and return values do not have to be an integer data types, but in WordPress $post_id is always an integer data type.Uses: get_option() to get all ping sites.Uses: weblog_ping() for each ping site.

Change Log

Since: 1.2.0

Source File

generic_ping() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/generic_ping"Categories: Functions | New page created

Function Reference/get 404 template

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve path of 404 template in current or parent template.

Usage

<?php get_404_template() ?>

Parameters

None.

Return Values

(string) Returns result from get_query_template('404').

ExamplesNotes

Uses: get_query_template()

Change Log

Since: 1.5.0

Source File

get_404_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_404_template"Categories: Functions | New page created

Function Reference/get all category ids

Contents1 Description2 Usage

Page 221: wp-api

3 Examples3.1 Default Usage

4 Parameters

Description

Returns an array containing IDs for all categories.

Usage

<?php $category_ids = get_all_category_ids(); ?>

ExamplesDefault Usage

Parameters

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_all_category_ids"Categories: Stubs | Functions

Function Reference/get all page ids

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Get a list of page IDs.

Usage

<?php get_all_page_ids() ?>

Parameters

None

Return Values

(array) List of page IDs.

ExamplesNotes

Uses: $wpdb

Change Log

Since: 2.0.0

Source File

get_all_page_ids() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_all_page_ids"Categories: Functions | New page created

Page 222: wp-api

Function Reference/get alloptions

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve all autoload options or all options, if no autoloaded ones exist.

This is different from wp_load_alloptions() in that this function does not cache its results and will retrieve all options from the database everytime it is called.

Usage

<?php get_alloptions() ?>

Parameters

None.

Return Values

(array) List of all options.

ExamplesNotes

Uses: apply_filters() Calls 'pre_option_$optionname' hook with option value as parameter.Uses: apply_filters() Calls 'all_options' on options list.Uses global: (object) $wpdb

Change Log

Since: 1.0.0

Source File

get_alloptions() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_alloptions"Categories: Functions | New page created

Function Reference/get approved comments

Contents1 Description

1.1 Usage2 Example3 Parameters

Description

Takes post ID and returns an array of objects that represent comments that have been submitted and approved.

Usage

<?php $comment_array = get_approved_comments($post_id); ?>

Page 223: wp-api

Example

In this example we will output a simple list of comment IDs and corresponding post IDs.

<?php $postID = 1; $comment_array = get_approved_comments(1);

foreach($comment_array as $comment){ echo $comment->comment_ID." => ".$comment->comment_post_ID."\n"; }?>

Parameters

$post_id(integer) (required) The ID of the post to retrieve comments from.

Default: None

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_approved_comments"Categories: Functions | Copyedit

Function Reference/get archive template

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve path of archive template in current or parent template.

Usage

<?php get_archive_template() ?>

Parameters

None.

Return Values

(string) Returns result from get_query_template('archive')

ExamplesNotes

Uses: get_query_template()

Change Log

Since: 1.5.0

Source File

get_archive_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_archive_template"Categories: Functions | New page created

Page 224: wp-api

Function Reference/get attached file

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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 '_wp_attached_file' and returning it. This is a convenience function to preventlooking up the meta name and provide a mechanism for sending the attached file name through a filter.

Usage

<?php get_attached_file( $attachment_id, $unfiltered ) ?>

Parameters

$attachment_id(integer) (required) Attachment ID.

Default: None

$unfiltered(boolean) (optional) Whether to apply filters or not.

Default: false

Return Values

(string) The file path to the attached file.

ExamplesNotes

Uses: apply_filters() to call get_attached_file() on file path and $attachment_id.Uses: get_post_meta() on $attachment_id, the '_wp_attached_file' meta name.

Change Log

Since: 2.0.0

Source File

get_attached_file() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_attached_file"Categories: Functions | New page created

Function Reference/get attachment template

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve path of 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 lastcheck is for both types separated by an underscore. If neither are found then the file 'attachment.php' is checked and returned.

Some examples for the 'text/plain' mime type are 'text.php', 'plain.php', and finally 'text_plain.php'.

Usage

Page 225: wp-api

<?php get_attachment_template() ?>

Parameters

None.

Return Values

(string) Returns path of attachment template in current or parent template.

ExamplesNotes

Uses: get_query_template()Uses global: (object) $posts a property of the WP_Query object.

Change Log

Since: 2.0.0

Source File

get_attachment_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_attachment_template"Categories: Functions | New page created

Function Reference/get author feed link

Contents1 Description2 Usage3 Examples

3.1 Default Usage4 Parameters5 Note

Description

Returns a link to the feed for all posts by the specified author. A particular feed can be requested, but if the feed parameter is left blank, itreturns the 'rss2' feed link.

Usage

<?php get_author_feed_link('author_id', 'feed'); ?>

ExamplesDefault Usage

Returns the rss2 feed link for post by author 2

<?php get_author_feed_link('2', ''); ?>

Parameters

author_id (string) Author ID of feed link to return.

feed (string) Type of feed; possible values: rss, atom, rdf. Default: blank (returns rss2)

Note

Currently the parameter 'feed' is not evaluted by the function.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_author_feed_link"

Function Reference/get author template

Page 226: wp-api

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve path of author template in current or parent template.

Usage

<?php get_author_template() ?>

Parameters

None.

Return Values

(string) Returns result from get_query_template('author')

ExamplesNotes

Uses: get_query_template();

Change Log

Since: 1.5.0

Source File

get_author_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_author_template"Categories: Functions | New page created

Function Reference/get bloginfo rss

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

RSS container for the bloginfo function.

You can retrieve anything that you can using the get_bloginfo() function. Everything will be stripped of tags and characters converted, when thevalues are retrieved for use in the feeds.

Usage

<?php get_bloginfo_rss( $show ) ?>

Page 227: wp-api

Parameters

$show(string) (optional) See get_bloginfo() for possible values.

Default: ''

Return Values

(string)

ExamplesNotes

See get_bloginfo() for the list of possible values to display.Uses: apply_filters() Calls 'get_bloginfo_rss' hook with two parameters.

Change Log

Since: 1.5.1

Source File

get_bloginfo_rss() is located in wp-includes/feed.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_bloginfo_rss"Categories: Functions | New page created

Function Reference/get bookmark

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve Bookmark data based on bookmark link ID.

Usage

<?php get_bookmark( $bookmark, $output, $filter ) ?>

Parameters

$output(string) (optional) Either OBJECT, ARRAY_N, or ARRAY_A constant

Default: OBJECT

$filter(string) (optional) default is 'raw'.

Default: 'raw'

Return Values

(array|object) Type returned depends on $output value.

ExamplesNotes

Uses global: (object) $wpdb Database Object

Change Log

Page 228: wp-api

Since: 2.1.0

Source File

get_bookmark() is located in wp-includes/bookmark.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_bookmark"Category: Functions

Function Reference/get cat ID

The get_cat_id() function is used to retrieve the ID of a category from its associated name (not the slug). This function accepts the categoryname (in string format) and returns the corresponding numerical ID.

This is a very basic example of how to use the function.

<?php $id = get_cat_id('Category Name'); $q = "cat=" . $id; query_posts($q); if (have_posts()) : while (have_posts()) : the_post(); the_content(); endwhile; endif; ?>

Code example taken from an article from Curtis henson

Retrieved from "http://codex.wordpress.org/Function_Reference/get_cat_ID"

Function Reference/get cat name

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the name of a category from its ID.

Usage

<?php get_cat_name( $cat_id ) ?>

Parameters

$cat_id(integer) (required) Category ID

Default: None

Return Values

(string) Category name

ExamplesNotesChange Log

Since: 1.0.0

Page 229: wp-api

Source File

get_cat_name() is located in wp-includes/category.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_cat_name"Categories: Functions | New page created

Function Reference/get categories

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Dropdown Box

4 Parameters

Description

Returns an array of category objects matching the query parameters.

Arguments are pretty much the same as wp_list_categories and can be passed as either array or in query syntax.

Usage

<?php $categories = get_categories(parameters); ?>

ExamplesDefault Usage

<?php $defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, 'exclude' => , 'include' => , 'number' => , 'pad_counts' => false);?>

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 theexample of the dropdown example of 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 "nicename" is "archives".

<select name="event-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo attribute_escape(__('Select Event')); ?></option> <?php $categories= get_categories('child_of=10'); foreach ($categories as $cat) { $option = '<option value="/category/archives/'.$cat->category_nicename.'">';

$option .= $cat->cat_name;$option .= ' ('.$cat->category_count.')';$option .= '</option>';echo $option;

} ?></select>

Parameters

type (string) Type of category to retreive

post - default

Page 230: wp-api

link

child_of (integer) Only display categories that are children of the category identified by its ID. There is no default for this parameter. If the parameter isused, the hide_empty parameter is set to false.

orderby (string)Sort categories alphabetically or by unique category ID. The default is sort by Category ID. Valid values:

ID - defaultname

order (string)Sort order for categories (either ascending or descending). The default is ascending. Valid values:

asc - defaultdesc

hide_empty (boolean)Toggles the display of categories with no posts. The default is true (hide empty categories). Valid values:

1 (true) - default0 (false)

include_last_update_time (boolean)Uncertain what this doesies|the example]].

1 (true)0 (false) -- default

hierarchical (boolean)Display sub-categories as inner list items (below the parent list item) or inline. The default is true (display sub-categories below theparent list item). Valid values:

1 (true) - default0 (false)

exclude (string)Excludes one or more categories from the list generated by wp_list_categories. This parameter takes a comma-separated list ofcategories by unique ID, in ascending order. See the example.

include (string)Only include certain categories in the list generated by wp_list_categories. This parameter takes a comma-separated list of categoriesby unique ID, in ascending order. See the example.

list - default.none

number (string) The number of categories to return

pad_counts (boolean)Calculates link or post counts by including items from child categories. Valid values:

1 (true)0 (false) - default

Retrieved from "http://codex.wordpress.org/Function_Reference/get_categories"Category: Functions

Function Reference/get category

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieves category data given a category ID or category object.

If you pass the $category parameter an object, which is assumed to be the category row object retrieved the database. It will cache thecategory data.

Page 231: wp-api

If you pass $category an integer of the category ID, then that category will be retrieved from the database, if it isn't already cached, and pass itback.

If you look at get_term(), then both types will be passed through several filters and finally sanitized based on the $filter parameter value.

The category will converted to maintain backwards compatibility.

Usage

<?php &get_category( $category, $output, $filter ) ?>

Parameters

$category(integer|object) (required) Category ID or Category row object

Default: None

$output(string) (optional) Constant OBJECT, ARRAY_A, or ARRAY_N

Default: OBJECT

$filter(string) (optional) Default is raw or no WordPress defined filter will applied.

Default: 'raw'

Return Values

(mixed) Category data in type defined by $output parameter.

ExamplesNotes

Uses: get_term() Used to get the category data from the taxonomy.

Change Log

Since: 1.5.1

Source File

&get_category() is located in wp-includes/category.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_category"Categories: Functions | New page created

Function Reference/get category by path

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve category based on URL containing the category slug.

Breaks the $category_path 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 $full_match, is set tofalse. If it does not, then it will return null.

It is also possible that it will return a WP_Error object on failure. Check for it when using this function.

Page 232: wp-api

Usage

<?php get_category_by_path( $category_path, $full_match, $output ) ?>

Parameters

$category_path(string) (required) URL containing category slugs.

Default: None

$full_match(boolean) (optional) Whether should match full path or not.

Default: true

$output(string) (optional) Constant OBJECT, ARRAY_A, or ARRAY_N

Default: OBJECT

Return Values

(null|object|array) Null on failure. Type is based on $output value.

ExamplesNotesChange Log

Since: 2.1.0

Source File

get_category_by_path() is located in wp-includes/category.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_category_by_path"Categories: Functions | New page created

Function Reference/get category by slug

This page is marked as incomplete. You can help Codex by expanding it.

The get_category_by_slug() function is used to retrieve the ID of a category from its associated slug. This function accepts the category slug(in string format) and returns the corresponding numerical ID in the term_id property.

<?php $idObj = get_category_by_slug('category-name'); $id = $idObj->term_id;?>

Practical Use:

<?php echo category_description(get_category_by_slug('category-slug')->term_id); ?>

Retrieved from "http://codex.wordpress.org/Function_Reference/get_category_by_slug"Categories: Stubs | Functions | New page created

Function Reference/get category feed link

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Parameters

4 Deprecated Function

Description

Page 233: wp-api

Released with Version 2.5, this function returns a link to the feed for all posts in the specified category. A particular feed can be requested, butif the feed parameter is left blank, it returns the 'rss2' feed link. This function replaces the deprecated get_category_rss_link function.

Usage

<?php get_category_feed_link('cat_id', 'feed'); ?>

ExamplesDefault Usage

Return the rss2 feed link for post in category 2

<?php get_category_feed_link('2', ''); ?>

Parameters

cat_id (string) Category ID of feed link to return.

feed (string) Type of feed, if left blank uses, by default, the 'rss2' feed.

Deprecated Function

get_category_rss_link

Retrieved from "http://codex.wordpress.org/Function_Reference/get_category_feed_link"Categories: Functions | New page created

Function Reference/get category template

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve path of category template in current or parent template.

Works by retrieving the current category ID, for example 'category-1.php' and will fallback to category.php template, if the category ID filedoesn't exist.

Usage

<?php get_category_template() ?>

Parameters

None.

Return Values

(string) Returns path of category template in current or parent template.

ExamplesNotes

Uses: apply_filters() Calls 'category_template' on file path of category template.Uses: locate_template()Uses: get_query_var() on 'cat'.

Change Log

Page 234: wp-api

Since: 1.5.0

Source File

get_category_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_category_template"Categories: Functions | New page created

Function Reference/get children

get_children() retrieves attachments, revisions, or sub-Pages, possibly by post parent.

It works similarly to get_posts().

Contents1 Synopsis2 Return values3 Examples4 Default parameters (Version 2.7)5 Parameters6 Related

Synopsis

array|false $children =& get_children( mixed $args = "", constant $output = OBJECT);

Return values

Returns an associative array of posts (of variable type set by `$output` parameter) with post IDs as array keys, or false if no posts are found.

Examples

$images =& get_children( 'post_type=attachment&post_mime_type=image' );

$videos =& get_children( 'post_type=attachment&post_mime_type=video/mp4' );

if ( empty($images) ) {// no attachments here

} else {foreach ( $images as $attachment_id => $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 => $attachment ) {echo wp_get_attachment_link( $attachment_id );

}

Default parameters (Version 2.7)

$defaults = array( 'post_parent' => 0,'post_type' => 'any',

'numberposts' => -1, 'post_status' => 'any',);

Parameters

See get_posts() for a full list of parameters.

As of Version 2.6, you must pass a non-empty post_type parameter (either attachment or page).

$args(mixed) Passing a query-style string or array sets several parameters (below). Passing an integer post ID or a post object will retrievechildren of that post; passing an empty value will retrieve children of the current post or Page.

Page 235: wp-api

$args['numberposts'](integer) Number of child posts to retrieve. Optional; default: -1 (unlimited)

$args['post_parent'](integer) Pass the ID of a post or Page to get its children. Pass null to get any child regardless of parent. Optional; default: 0 (anyparent?)

$args['post_type'](string) Any value from post_type column of the posts table, such as attachment, page, or revision; or the keyword any. Default: any

$args['post_status'](string) Any value from the post_status column of the wp_posts table, such as publish, draft, or inherit; or the keyword any. Default: any

$args['post_mime_type'](string) A full or partial mime-type, e.g. image, video, video/mp4, which is matched against a post's post_mime_type field

$output(constant) Variable type of the array items returned by the function: one of OBJECT, ARRAY_A, ARRAY_N. Optional; default: OBJECT

Related

get_children() calls get_posts(), which calls $WP_Query->get_posts().

wp_get_attachment_link()

Retrieved from "http://codex.wordpress.org/Function_Reference/get_children"Categories: Functions | Attachments

Function Reference/get comment

Contents1 Description2 Usage3 Example4 Parameters5 Return6 References

Description

Takes a comment ID and returns the database record for that post. You can specify, by means of the $output parameter, how you would like theresults returned.

Usage

<?php get_comment($id, $output); ?>

Example

To get the author's name of a comment with ID 7:

<?php$my_id = 7;$comment_id_7 = get_comment($my_id); $name = $comment_id_7->comment_author;?>

Alternatively, specify the $output parameter:

<?php$my_id = 7;$comment_id_7 = get_comment($my_id, ARRAY_A);$name = $comment_id_7['comment_author'];?>

<?php## Correct: pass a dummy variable as post_id$the_comment = & get_comment( $dummy_id = 7 ); ## Incorrect: literal integer as post_id$the_comment = & get_comment( 7 );// Fatal error: 'Only variables can be passed for reference' or 'Cannot pass parameter 1 by reference'?>

Parameters

Page 236: wp-api

$comment(integer) (required) The ID of the comment you'd like to fetch. You must pass a variable containing an integer (e.g. $id). A literal integer(e.g. 7) will cause a fatal error (Only variables can be passed for reference or Cannot pass parameter 1 by reference).

Default: None

$output(string) (required) How you'd like the result. OBJECT = as an object, ARRAY_A = as an associative array of field names to values, andARRAY_N = a scalar array of field values.

Default: None

Return

The fields returned are:

comment_ID (integer) The comment ID

comment_post_ID (integer) The post ID of the associated post

comment_author (string) The comment author's name

comment_author_email (string) The comment author's email

comment_author_url (string) The comment author's webpage

comment_author_IP (string) The comment author's IP

comment_date (string) The datetime of the comment (YYYY-MM-DD HH:MM:SS)

comment_date_gmt (string) The GMT datetime of the comment (YYYY-MM-DD HH:MM:SS)

comment_content (string) The comment's contents

comment_karma (integer) The comment's karma

comment_approved (string) The comment approbation (0, 1 or 'spam')

comment_agent (string) The comment's agent (browser, Operating System, etc.)

comment_type (string) The comment's type if meaningfull (pingback|trackback), and empty for normal comments

comment_parent (string) The parent comment's ID

user_id (integer) The comment author's ID if he is registered (0 otherwise)

References

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_comment"Categories: Copyedit | Functions

Function Reference/get comment author rss

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the current comment author for use in the feeds.

Usage

Page 237: wp-api

<?php get_comment_author_rss() ?>

Parameters

None.

Return Values

(string) Comment Author

ExamplesNotes

Uses: apply_filters() Calls 'comment_author_rss' hook on comment author.Uses: get_comment_author()

Change Log

Since: 2.0.0

Source File

get_comment_author_rss() is located in wp-includes/feed.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_comment_author_rss"Categories: Functions | New page created

Function Reference/get comment link

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the link to a given comment.

Usage

<?php get_comment_link( $comment, $args ) ?>

Parameters

$comment(object|string|integer) (optional) Comment to retrieve.

Default: null

$args(array) (optional) Optional args.

Default: array

Return Values

(string) The permalink to the current comment

ExamplesNotes

Uses: get_comment() to retrieve $comment.Uses global: (unknown) $wp_rewrite

Page 238: wp-api

Uses global: (unknown) $in_comment_loop

Change Log

Since: 1.5.0

Source File

get_comment_link() is located in wp-includes/comment-template.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_comment_link"Categories: Functions | New page created

Function Reference/get comments popup template

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve path of comment popup template in current or parent template.

Checks for comment popup template in current template, if it exists or in the parent template. If it doesn't exist, then it retrieves the comment-popup.php file from the default theme. The default theme must then exist for it to work.

Usage

<?php get_comments_popup_template() ?>

Parameters

None.

Return Values

(string) Returns the template path.

ExamplesNotes

Uses: apply_filters() Calls 'comments_popup_template' filter on path.Uses: locate_template() to locate 'comments-popup.php' file.Uses: get_theme_root()

Change Log

Since: 1.5.0

Source File

get_comments_popup_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_comments_popup_template"Categories: Functions | New page created

Function Reference/get current theme

Contents1 Description

Page 239: wp-api

2 Usage3 Example

3.1 Usage

Description

Returns the name of the current theme.

Usage

<?php $theme_name = get_current_theme(); ?>

ExampleUsage

Get the name of the current theme.

<?php $theme_name = get_current_theme(); echo $theme_name;?>

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_current_theme"Categories: Functions | Copyedit

Function Reference/get currentuserinfo

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Using Separate Globals

4 Parameters

Description

Retrieves the information pertaining to the currently logged in user, and places it in the global variable $userdata. Properties map directly to thewp_users table in the database (see Database Description).

Also places the individual attributes into the following separate global variables:

$user_login$user_level$user_ID$user_email$user_url (User's website, as entered in the user's Profile)$user_pass_md5 (A md5 hash of the user password -- a type of encoding that is very nearly, if not entirely, impossible todecode, but useful for comparing input at a password prompt with the actual user password.)$display_name (User's name, displayed according to the 'How to display name' User option)

Usage

<?php get_currentuserinfo(); ?>

ExamplesDefault Usage

The call to get_currentuserinfo() places the current user's info into $userdata, where it can be retrieved using member variables.

<?php global $current_user; get_currentuserinfo();

echo('Username: ' . $current_user->user_login . "\n"); echo('User email: ' . $current_user->user_email . "\n"); echo('User level: ' . $current_user->user_level . "\n"); echo('User first name: ' . $current_user->user_firstname . "\n");

Page 240: wp-api

echo('User last name: ' . $current_user->user_lastname . "\n"); echo('User display name: ' . $current_user->display_name . "\n"); echo('User ID: ' . $current_user->ID . "\n");?>

Username: Zedd

User email: [email protected] level: 10User first name: JohnUser last name: DoeUser display name: John Doe

User ID: 1

Using Separate Globals

Much of the user data is placed in separate global variables, which can be accessed directly.

<?php global $display_name , $user_email; get_currentuserinfo();

echo($display_name . "'s email address is: " . $user_email);?>

Zedd's email address is: [email protected]

: NOTE: $display_name does not appear to work in 2.5+? $user_login works fine.

<?php global $user_login , $user_email; get_currentuserinfo();

echo($user_login . "'s email address is: " . $user_email);?>

Parameters

This function does not accept any parameters.

To determine if there is a user currently logged in, do this:

<?php global $user_ID; get_currentuserinfo();

if ('' == $user_ID) { //no user logged in }?>

Here is another IF STATEMENT Example. It was used in the sidebar, in reference to the "My Fav" plugin at http://www.kriesi.at/archives/wordpress-plugin-my-favorite-posts

<?php if ( $user_ID ) { ?><!-- enter info that logged in users will see --><!-- in this case im running a bit of php to a plugin -->

<?php mfp_display(); ?>

<?php } else { ?><!-- here is a paragraph that is shown to anyone not logged in -->

<p>By <a href="<?php bloginfo('url'); ?>/wp-register.php">registering</a>, you can save your favorite posts for future reference.</p>

<?php } ?>

Page 241: wp-api

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_currentuserinfo"Categories: Functions | Copyedit

Function Reference/get date from gmt

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Converts a GMT date into the correct format for the blog.

Requires and returns in the Y-m-d H:i:s format. Simply adds the value of the 'gmt_offset' option.

Usage

<?php get_date_from_gmt( $string ) ?>

Parameters

$string(string) (required) The date to be converted.

Default: None

Return Values

(string) Formatted date relative to the GMT offset.

ExamplesNotes

Uses: get_option() to retrieve the value of 'gmt_offset'.

Change Log

Since: 1.2.0

Source File

get_date_from_gmt() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_date_from_gmt"Categories: Functions | New page created

Function Reference/get date template

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Page 242: wp-api

Retrieve path of date template in current or parent template.

Usage

<?php get_date_template() ?>

Parameters

None.

Return Values

(string) Result of get_query_template('date').

ExamplesNotes

Uses: get_query_template()

Change Log

Since: 1.5.0

Source File

get_date_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_date_template"Categories: Functions | New page created

Function Reference/get enclosed

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve enclosures already enclosed for a post.

Usage

<?php get_enclosed( $post_id ) ?>

Parameters

$post_id(integer) (required) Post ID.

Default: None

Return Values

(array) List of enclosures.

ExamplesNotes

Uses: get_post_custom() on $post_id.Uses: apply_filters() on 'get_enclosed' on enclosures.

Change Log

Page 243: wp-api

Since: 1.5.0

Source File

get_enclosed() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_enclosed"Categories: Functions | New page created

Function Reference/get extended

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Get extended entry info ( <!--more--> ).

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'tbe referenced.

The returned array has 'main' and 'extended' keys. Main has the text before the <code><!--more--></code> . The 'extended' key has thecontent after the <code><!--more--></code> comment.

Usage

<?php get_extended( $post ) ?>

Parameters

$post(string) (required) Post content.

Default: None

Return Values

(array) Post before ('main') and after ('extended').

ExamplesNotesChange Log

Since: 1.0.0

Source File

get_extended() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_extended"Categories: Functions | New page created

Function Reference/get gmt from date

Contents1 Description2 Usage3 Parameters4 Return Values

Page 244: wp-api

5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Returns a date in the GMT equivalent.

Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the value of the 'gmt_offset' option.

Usage

<?php get_gmt_from_date( $string ) ?>

Parameters

$string(string) (required) The date to be converted.

Default: None

Return Values

(string) GMT version of the date provided.

ExamplesNotes

Uses: get_option() to retrieve the value of the 'gmt_offset' option.

Change Log

Since: 1.2.0

Source File

get_gmt_from_date() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_gmt_from_date"Categories: Functions | New page created

Function Reference/get header image

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve header image for custom header.

Usage

<?php get_header_image() ?>

Parameters

None.

Return Values

(string)

Page 245: wp-api

Returns header image path.

ExamplesNotes

Uses: HEADER_IMAGE

Change Log

Since: 2.1.0

Source File

get_header_image() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_header_image"Categories: Functions | New page created

Function Reference/get header textcolor

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve text color for custom header.

Usage

<?php get_header_textcolor() ?>

Parameters

None.

Return Values

(string)

ExamplesNotes

Uses: HEADER_TEXTCOLOR

Change Log

Since: 2.1.0

Source File

get_header_textcolor() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_header_textcolor"Categories: Functions | New page created

Function Reference/get home template

Contents1 Description2 Usage

Page 246: wp-api

3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve path of home template in current or parent template.

Attempts to locate 'home.php' first before falling back to 'index.php'.

Usage

<?php get_home_template() ?>

Parameters

None.

Return Values

(string) Returns path of home template in current or parent template.

ExamplesNotes

Uses: apply_filters() Calls 'home_template' on file path of home template.Uses: locate_template() on 'home.php' and 'index.php'.

Change Log

Since: 1.5.0

Source File

get_home_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_home_template"Categories: Functions | New page created

Function Reference/get lastcommentmodified

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

The date the last comment was modified. If $cache_lastcommentmodified is set this function returns its value from the cache without hitting thedatabase.

Usage

<?php get_lastcommentmodified( $timezone ) ?>

Parameters

$timezone(string) (optional) Which timezone to use in reference to 'gmt', 'blog', or 'server' locations.

Default: 'server'

Page 247: wp-api

Return Values

(string) Last comment modified date as a MySQL DATETIME.

ExamplesNotes

Uses: $wpdb to read from the comments table.Uses global: array $cache_lastcommentmodified

Change Log

Since: 1.5.0

Source File

get_lastcommentmodified() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_lastcommentmodified"Categories: Functions | New page created

Function Reference/get lastpostdate

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the date the the last post was published.

The server timezone is the default and is the difference between GMT and server time. The 'blog' value is the date when the last post wasposted. The 'gmt' is when the last post was posted in GMT formatted date.

Usage

<?php get_lastpostdate( $timezone ) ?>

Parameters

$timezone(string) (optional) The location to get the time. Can be 'gmt', 'blog', or 'server'.

Default: 'server'

Return Values

(string) The date of the last post.

ExamplesNotes

Uses: apply_filters() Calls 'get_lastpostdate' filterUses global: (mixed) $cache_lastpostdate Stores the date the last post.Uses global: (object) $wpdbUses global: (integer) $blog_id The Blog ID.

Change Log

Since: 0.71

Page 248: wp-api

Source File

get_lastpostdate() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_lastpostdate"Categories: Functions | New page created

Function Reference/get lastpostmodified

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve last post modified date depending on timezone.

The server timezone is the default and is the difference between GMT and server time. The 'blog' value is just when the last post was modified.The 'gmt' is when the last post was modified in GMT time.

Usage

<?php get_lastpostmodified( $timezone ) ?>

Parameters

$timezone(string) (optional) The location to get the time. Can be 'gmt', 'blog', or 'server'.

Default: 'server'

Return Values

(string) The date the post was last modified.

ExamplesNotes

Uses: apply_filters() Calls 'get_lastpostmodified' filterUses global: (mixed) $cache_lastpostmodified Stores the date the last post was last modified.Uses global: (object) $wpdbUses global: (integer) $blog_id The Blog ID.

Change Log

Since: 1.2.0

Source File

get_lastpostmodified() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_lastpostmodified"Categories: Functions | New page created

Function Reference/get locale

Contents1 Description2 Usage3 Parameters4 Return Values

Page 249: wp-api

5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Gets the current locale.

If the locale is set, then it will filter the locale in the 'locale' 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 'locale' filter hook and the valuefor 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 'locale' hook.

Usage

<?php get_locale() ?>

Parameters

None.

Return Values

(string) The locale of the blog or from the 'locale' hook.

ExamplesNotes

Uses: apply_filters() Calls 'locale' hook on locale value.Uses: $locale Gets the locale stored in the global.Uses global: (unknown) $localel10n is an abbreviation for localization.

Change Log

Since: 1.5.0

Source File

get_locale() is located in wp-includes/l10n.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_locale"Categories: Functions | New page created

Function Reference/get locale stylesheet uri

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve localized stylesheet URI.

The stylesheet directory for the localized stylesheet files are located, by default, in the base theme directory. The name of the locale file will bethe locale followed by '.css'. If that does not exist, then the text direction stylesheet will be checked for existence, for example 'ltr.css'.

The theme may change the location of the stylesheet directory by either using the 'stylesheet_directory_uri' filter or the 'locale_stylesheet_uri'

Page 250: wp-api

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 thelocale in a separate folder, then change the latter.

Usage

<?php get_locale_stylesheet_uri() ?>

Parameters

None.

Return Values

(string) Returns localized stylesheet URI.

ExamplesNotes

Uses global: (object) $wp_locale handles the date and time locales.Uses: apply_filters() Calls 'locale_stylesheet_uri' filter on stylesheet URI path and stylesheet directory URI.Uses: get_stylesheet_directory_uri()Uses: get_stylesheet_directory()Uses: get_locale()

Change Log

Since: 2.1.0

Source File

get_locale_stylesheet_uri() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_locale_stylesheet_uri"Categories: Functions | New page created

Function Reference/get num queries

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the number of database queries during the WordPress execution.

Usage

<?php get_num_queries() ?>

Parameters

None.

Return Values

(integer) Number of database queries

ExamplesNotes

Uses global: (object) $wpdb

Page 251: wp-api

Change Log

Since: 2.0.0

Source File

get_num_queries() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_num_queries"Categories: Functions | New page created

Function Reference/get option

Contents1 Description2 Usage3 Examples

3.1 Show Blog Title3.2 Show Character Set3.3 Retrieve Administrator E-mail

4 Parameters5 Related

Description

A safe way of getting values for a named option from the options database table. If the desired option does not exist, or no value is associatedwith it, FALSE will be returned.

Usage

<?php echo get_option('show'); ?>

ExamplesShow Blog Title

Displays your blog's title in a <h1> tag.

<h1><?php echo get_option('blogname'); ?></h1>

Show Character Set

Displays the character set your blog is using (ex: UTF-8)

<p>Character set: <?php echo get_option('blog_charset'); ?> </p>

Retrieve Administrator E-mail

Retrieve the e-mail of the blog administrator, storing it in a variable.

<?php $admin_email = get_option('admin_email'); ?>

Parameters

$show(string) (required) Name of the option to retrieve. A list of valid default options can be found at the Option Reference.

Default: None

Related

add_option, update_option

bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_page_menu,wp_dropdown_pages, wp_loginout, wp_register, wp_logout_url, query_posts, rss_enclosure

How to pass parameters to tags

Go to Template Tag index

Page 252: wp-api

Retrieved from "http://codex.wordpress.org/Function_Reference/get_option"Categories: Template Tags | Functions

Function Reference/get page

This page is marked as incomplete. You can help Codex by expanding it.

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 orarchives, or any other blog entry features of wordpress. Its simply a way to turn a blog entry into static content.

Wrong way: $p = get_page(2); // Error: Only variables can be passed by reference

Right Way: $n = 2; $p = get_page($n);

Why? I think it's a PHP bug

Get title: $p->post_title

Get Content $p->post_content

Retrieved from "http://codex.wordpress.org/Function_Reference/get_page"Categories: Stubs | Functions

Function Reference/get page by path

This page is marked as incomplete. You can help Codex by expanding it.

Description

This is the equivalent of the "pagename" query, as in: "index.php?pagename=parent-page/sub-page".

Example for wp 2.3.X or newer

Code for the above would be:

get_page_by_path('parent-page/sub-page');

Retrieved from "http://codex.wordpress.org/Function_Reference/get_page_by_path"Categories: Stubs | Functions

Function Reference/get page by titleDescription

The Function, get_page_by_title(), returns a page object when given a string parameter containing the page name. The page name correlatesto the Title text field when creating or editing a page in the administration panel.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_page_by_title"Categories: Functions | New page created

Function Reference/get page children

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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

Page 253: wp-api

make any SQL queries to get the children.

Usage

<?php &get_page_children( $page_id, $pages ) ?><?php get_page_children( $page_id, $pages ) ?>

Parameters

$page_id(integer) (required) Page ID.

Default: None

$pages(array) (required) List of pages' objects.

Default: None

Return Values

(array)

ExamplesNotes

This function calls itself recursively.

Change Log

Since: 1.5.1

Source File

&get_page_children() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_page_children"Categories: Functions | New page created

Function Reference/get page hierarchyDescription

This function, get_page_hierarchy(), returns an array sorted by the page sort order. It takes two parameters, a page listing object and a parentid (optional)

It is defined in the wp-includes/post.php file.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_page_hierarchy"

Function Reference/get page template

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve path of page template in current or parent template.

First attempt is to look for the file in the '_wp_page_template' page meta data. The second attempt, if the first has a file and is not empty, is tolook for 'page.php'.

Usage

<?php get_page_template() ?>

Page 254: wp-api

Parameters

None.

Return Values

(string) Returns path of page template in current or parent template.

ExamplesNotes

Uses: get_post_meta()Uses: validate_file()Uses: apply_filters() on 'page_template' on result of locate_template().Uses: locate_template()Uses global: (object) $wp_query

Change Log

Since: 1.5.0

Source File

get_page_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_page_template"Categories: Functions | New page created

Function Reference/get page uri

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Builds URI for a page.

Sub pages will be in the "directory" under the parent page post name.

Usage

<?php get_page_uri( $page_id ) ?>

Parameters

$page_id(integer) (required) Page ID.

Default: None

Return Values

(string) Page URI.

ExamplesNotesChange Log

Since: 1.5.0

Page 255: wp-api

Source File

get_page_uri() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_page_uri"Categories: Functions | New page created

Function Reference/get paged template

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve path of paged template in current or parent template.

Usage

<?php get_paged_template() ?>

Parameters

None.

Return Values

(string) Result of get_query_template('paged').

ExamplesNotes

Uses: get_query_template()

Change Log

Since: 1.5.0

Source File

get_paged_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_paged_template"Categories: Functions | New page created

Function Reference/get pages

Contents1 Description2 Usage3 Example

3.1 Displaying pages in dropdown list3.2 Displaying Child pages of the current page in post format

4 Parameters5 Return6 Related

Description

Function get_pages() is used to get a list of all the pages that are defined in the blog. Here is a typical usage.

Page 256: wp-api

Usage

<?php get_pages('arguments'); ?>

ExampleDisplaying 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_linkpassing the ID of the page.

<select name=\"page-dropdown\" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=\"\"><?php echo attribute_escape(__('Select page')); ?></option> <?php $pages = get_pages(); foreach ($pages as $pagg) { $option = '<option value=\"'.get_page_link($pagg->ID).'\">'; $option .= $pagg->post_title; $option .= '</option>'; echo $option; } ?></select>

Displaying Child pages of the current page in post format

<?php $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc'); $count = 0; foreach($pages as $page) { $content = $page->post_content; if(!$content) continue; if($count >= 2) break; $count++; $content = apply_filters('the_content', $content); ?> <h2><a href=\"<?php echo get_page_link($page->ID) ?>\"><?php echo $page->post_title ?></a></h2> <div class=\"entry\"><?php echo $content ?></div> <?php } ?>

Parameters

sort_column (string)Sorts the list of Pages in a number of different ways. The default setting is sort alphabetically by Page title.

'post_title' - Sort Pages alphabetically (by title) - default'menu_order' - Sort Pages by Page Order. N.B. Note the difference between Page Order and Page ID. The Page ID is a uniquenumber assigned by WordPress to every post or page. The Page Order can be set by the user in the Write>Pagesadministrative panel.'post_date' - Sort by creation time.'post_modified' - Sort by time last modified.'ID' - Sort by numeric Page ID.'post_author' - Sort by the Page author's numeric ID.'post_name' - Sort alphabetically by Post slug.

Note: The sort_column parameter can be used to sort the list of Pages by the descriptor of any field in the wp_post table of the WordPressdatabase. Some useful examples are listed here.

Page 257: wp-api

sort_order (string)Change the sort order of the list of Pages (either ascending or descending). The default is ascending. Valid values:

'asc' - Sort from lowest to highest (Default).'desc' - Sort from highest to lowest.

exclude (string)Define a comma-separated list of Page IDs to be excluded from the list (example: 'exclude=3,7,31'). There is no default value.

include (string)Only include certain Pages in the list generated by get_pages. Like exclude, this parameter takes a comma-separated list of Page IDs.There is no default value.

child_of (integer)Displays the sub-pages of a single Page only; uses the ID for a Page as the value. Defaults to 0 (displays all Pages). Note that thechild_of parameter will also fetch "grandchildren" of the given ID, not just direct descendants.

0 - default, no child of restriction

parent (integer)Displays those pages that have this ID as a parent. Defaults to -1 (displays all Pages regardless of parent). Note that this can be usedto limit the 'depth' of the child_of parameter, so only one generation of descendants might be retrieved.

-1 - default, no parent restriction

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 givenpage. Can also be used to hide grandchildren in conjunction with a 'child_of' value. This parameter was available at Version 2.7.

hierarchical (boolean) Display sub-Pages in an indented manner below their parent or list the Pages inline. The default is true (display sub-Pagesindented below the parent list item). Valid values:

1 (true) - default0 (false)

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 conjuntion with the meta_key field).

authors (string)Only include the Pages written by the given author(s)

Return

An array containing all the Pages matching the request

Related

Function Reference

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_pages"Categories: Copyedit | Functions | New page created

Function Reference/get post

Contents1 Description2 Usage3 Example4 Parameters5 Return6 References

Description

Takes a post ID and returns the database record for that post. You can specify, by means of the $output parameter, how you would like theresults returned.

Usage

<?php get_post($post, $output); ?>

Page 258: wp-api

Example

To get the title for a post with ID 7:

<?php$my_id = 7;$post_id_7 = get_post($my_id); $title = $post_id_7->post_title;?>

Alternatively, specify the $output parameter:

<?php$my_id = 7;$post_id_7 = get_post($my_id, ARRAY_A);$title = $post_id_7['post_title'];?>

<?php## Correct: pass a dummy variable as post_id$the_post = & get_post( $dummy_id = 7 ); ## Incorrect: literal integer as post_id$the_post = & get_post( 7 );// Fatal error: 'Only variables can be passed for reference' or 'Cannot pass parameter 1 by reference'?>

Parameters

$post(integer) (required) The ID of the post you'd like to fetch. You must pass a variable containing an integer (e.g. $id). A literal integer (e.g.7) will cause a fatal error (Only variables can be passed for reference or Cannot pass parameter 1 by reference).

Default: None

$output(string) (optional) How you'd like the result.

OBJECT - returns an objectARRAY_A - Returns an associative array of field names to valuesARRAY_N - returns a numeric array of field valuesDefault: OBJECT

Return

The fields returned are:

ID (integer) The post ID

post_author (integer) The post author's ID

post_date (string) The datetime of the post (YYYY-MM-DD HH:MM:SS)

post_date_gmt (string) The GMT datetime of the post (YYYY-MM-DD HH:MM:SS)

post_content (string) The post's contents

post_title (string) The post's title

post_category (integer) The post category's ID. Note that this will always be 0 (zero) from wordpress 2.1 onwards. To determine a post's category orcategories, use get_the_category().

post_excerpt (string) The post excerpt

post_status (string) The post status (publish|pending|draft|private|static|object|attachment|inherit|future)

comment_status (string) The comment status (open|closed|registered_only)

ping_status (string) The pingback/trackback status (open|closed)

post_password (string) The post password

Page 259: wp-api

post_name (string) The post's URL slug

to_ping (string) URLs to be pinged

pinged (string) URLs already pinged

post_modified (string) The last modified datetime of the post (YYYY-MM-DD HH:MM:SS)

post_modified_gmt (string) The last modified GMT datetime of the post (YYYY-MM-DD HH:MM:SS)

post_content_filtered (string)

post_parent (integer) The parent post's ID (for attachments, etc)

guid (string) A link to the post. Note: One cannot rely upon the GUID to be the permalink (as it previously was in pre-2.5), Nor can youexpect it to be a valid link to the post. It's mearly a unique identifier, which so happens to be a link to the post at present.

menu_order (integer)

post_type (string) (post|page|attachment)

post_mime_type (string) Mime Type (for attachments, etc)

comment_count (integer) Number of comments

References

get_post method not working NB: "This topic has been closed to new replies."

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_post"Categories: Copyedit | Functions

Function Reference/get post comments feed link

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the permalink for the post comments feed.

Usage

<?php get_post_comments_feed_link( $post_id, $feed ) ?>

Parameters

$post_id(integer) (optional) Post ID.

Default: ''

$feed(string) (optional) Feed type.

Default: ''

Return Values

(string)

Examples

Page 260: wp-api

Notes

Uses global: (integer) $id

Change Log

Since: 2.2.0

Source File

get_post_comments_feed_link() is located in wp-includes/link-template.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_post_comments_feed_link"Categories: Functions | New page created

Function Reference/get post custom

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Retrieving data from the array

4 Parameters5 Related

Description

Returns a multidimensional array with all custom fields of a particular post or page. See also get_post_custom_keys() andget_post_custom_values()

Usage

<?php get_post_custom($post_id); ?>

ExamplesDefault Usage

Use the following example to set a variable ($custom_fields) as a multidimensional array containing all custom fields of the current post.

<?php $custom_fields = get_post_custom(); ?>

Retrieving data from the array

The following example will retrieve all custom field values with the key my_custom_field from the post with the ID 72 (assuming there are threecustom fields with this key, and the values are "dogs", "47" and "This is another value").

<?php

$custom_fields = get_post_custom('72'); $my_custom_field = $custom_fields['my_custom_field']; foreach ( $my_custom_field as $key => $value ) echo $key . " => " . $value . "<br />";

?>

0 => dogs1 => 472 => This is another value

Parameters

$post_id(integer) (optional) The post ID whose custom fields will be retrieved.

Page 261: wp-api

Default: Current post

Related

add_post_meta(), delete_post_meta(), get_post_meta(), update_post_meta(), get_post_custom_values(), get_post_custom_keys()

Retrieved from "http://codex.wordpress.org/Function_Reference/get_post_custom"Categories: Functions | Needs Review

Function Reference/get post custom keys

Contents1 Description2 Usage3 Examples

3.1 Default Usage4 Parameters5 Related

Description

Returns an array containing the keys of all custom fields of a particular post or page. See also get_post_custom() andget_post_custom_values()

Usage

<?php get_post_custom_keys($post_id); ?>

ExamplesDefault Usage

The following example will set a variable ($custom_field_keys) as an array containing the keys of all custom fields in the current post, and thenprint it. Note: the if test excludes values for WordPress internally maintained custom keys such as _edit_last and _edit_lock.

<?php

$custom_field_keys = get_post_custom_keys(); foreach ( $custom_field_keys as $key => $value ) { $valuet = trim($value); if ( '_' == $valuet{0} ) continue; echo $key . " => " . $value . "<br />"; }?>

If the post contains custom fields with the keys mykey and yourkey, the output would be something like:

0 => mykey1 => yourkey

Note: Regardless of how many values (custom fields) are assigned to one key, that key will only appear once in this array.

Parameters

$post_id(integer) (optional) The post ID whose custom field keys will be retrieved.

Default: Current post

Related

add_post_meta(), delete_post_meta(), get_post_meta(), update_post_meta(), get_post_custom(), get_post_custom_values()

Retrieved from "http://codex.wordpress.org/Function_Reference/get_post_custom_keys"Categories: Functions | Needs Review

Page 262: wp-api

Function Reference/get post custom values

Contents1 Description2 Usage3 Examples

3.1 Default Usage4 Parameters5 Related

Description

This function is useful if you wish to access a custom field that is not unique, ie. has more than 1 value associated with it. Otherwise, you mightwish to look at get_post_meta()

Returns an array containing all the values of the custom fields with a particular key ($key) of a post with ID $post_id (defaults to the currentpost if unspecified).

Returns nothing if no such key exists, or none is entered.

See also get_post_custom() and get_post_custom_keys().

Usage

<?php get_post_custom_values($key, $post_id); ?>

ExamplesDefault Usage

Let's assume the current post has 3 values associated with the (custom) field my_key.

You could show them through:

<?php

$mykey_values = get_post_custom_values('my_key'); foreach ( $mykey_values as $key => $value ) { echo "$key => $value ('my_key')<br />"; }

?>

0 => First value ('my_key')1 => Second value ('my_key')2 => Third value ('my_key')

Parameters

$key(string) (required) The key whose values you want returned.

Default: None

$post_id(integer) (optional) The post ID whose custom fields will be retrieved.

Default: Current post

Related

add_post_meta(), delete_post_meta(), get_post_meta(), update_post_meta(), get_post_custom(), get_post_custom_keys()

Retrieved from "http://codex.wordpress.org/Function_Reference/get_post_custom_values"Categories: Functions | Needs Review

Function Reference/get post meta

Contents1 Description2 Usage3 Examples

3.1 Default Usage

Page 263: wp-api

3.2 Other Example4 Parameters5 Return6 Related

Description

This function returns the values of the custom fields with the specified key from the specified post. See also update_post_meta(),delete_post_meta() and add_post_meta().

Usage

<?php $meta_values = get_post_meta($post_id, $key, $single); ?>

ExamplesDefault Usage

<?php $key_1_values = get_post_meta(76, 'key_1'); ?>

Other Example

To retrieve only the first value of a given key:

<?php $key_1_value = get_post_meta(76, 'key_1', true); ?>

For a more detailed example, go to the post_meta Functions Examples page.

Parameters

$post_id(integer) (required) The ID of the post from which you want the data. Use $post->ID to get a post's ID.

Default: None

$key(string) (required) A string containing the name of the meta value you want.

Default: None

$single(boolean) (optional) If set to true then the function will return a single result, as a string. If false, or not set, then the function returns anarray of the custom fields.

Default: false

Return

If $single is set to false, or left blank, the function returns an array containing all values of the specified key.If $single is set to true, the function returns the first value of the specified key (not in an array)

The function returns an empty string if the key has not yet been set, regardless of the value of $single.

Related

update_post_meta(), delete_post_meta(), add_post_meta(), get_post_custom(), get_post_custom_values(), get_post_custom_keys()

Retrieved from "http://codex.wordpress.org/Function_Reference/get_post_meta"Categories: Functions | New page created | Needs Review

Function Reference/get post mime type

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Page 264: wp-api

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

<?php get_post_mime_type( $ID ) ?>

Parameters

$ID(integer) (optional) Post ID.

Default: ''

Return Values

(boolean|string) False on failure or returns the mime type

ExamplesNotesChange Log

Since: 2.0.0

Source File

get_post_mime_type() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_post_mime_type"Categories: Functions | New page created

Function Reference/get post status

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the post status based on the Post ID.

If the post ID is of an attachment, then the parent post status will be given instead.

Usage

<?php get_post_status( $ID ) ?>

Parameters

$ID(integer) (optional) Post ID. This function will will return false if $ID is not provided.

Default: ''

Return Values

(string|boolean) Post status or false on failure.

ExamplesNotes

Page 265: wp-api

Change Log

Since: 2.0.0

Source File

get_post_status() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_post_status"Categories: Functions | New page created

Function Reference/get post type

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the post type of the current post or of a given post.

Usage

<?php get_post_type( $post ) ?>

Parameters

$post(mixed) (optional) Post object or post ID.

Default: false

Return Values

(boolean|string) post type or false on failure.

ExamplesNotes

Uses: $wpdbUses: $posts The Loop post global

Change Log

Since: 2.1.0

Source File

get_post_type() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_post_type"Categories: Functions | New page created

Function Reference/get profile

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes

Page 266: wp-api

7 Change Log8 Source File9 Related

Description

Retrieve user data based on field.

Use get_profile() will make a database query to get the value of the table column. The value might be cached using the query cache, but careshould be taken when using the function to not make a lot of queries for retrieving user profile information.

If the $user parameter is not used, then the user will be retrieved from a cookie of the user. Therefore, if the cookie does not exist, then novalue might be returned. Sanity checking must be done to ensure that when using get_profile() that (empty|null|false) values are handled andthat something is at least displayed.

Usage

<?php get_profile( $field, $user ) ?>

Parameters

$field(string) (required) User field to retrieve. See users table for possible $field values.

Default: None

$user(string) (optional) User username. Uses user cookie to determine user if this is false or omitted.

Default: false

Return Values

(string) The value in the field.

ExamplesNotes

Uses: $wpdb Reads from the users table.

Change Log

Since: 1.5.0

Source File

get_profile() is located in wp-includes/user.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_profile"Categories: Functions | New page created

Function Reference/get pung

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve URLs already pinged for a post.

Usage

<?php get_pung( $post_id ) ?>

Page 267: wp-api

Parameters

$post_id(integer) (required) Post ID.

Default: None

Return Values

(array) Returns array of pinged URLs.

ExamplesNotes

Uses global: (object) $wpdb to retrieve pinged URLs from the _posts table in the database.Uses: apply_filters() on 'get_pung' on pinged URLs.

Change Log

Since: 1.5.0

Source File

get_pung() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_pung"Categories: Functions | New page created

Function Reference/get query template

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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 oflocate_template(). Allows for more generic file location without the use of the other get_*_template() functions.

Can be used with include() or require() to retrieve path.

if ( '' != get_query_template( '404' ) ) include( get_query_template( '404' ) );

or the same can be accomplished with

if ( '' != get_404_template() ) include( get_404_template() );

Usage

<?php get_query_template( $type ) ?>

Parameters

$type(string) (required) Filename without extension.

Default: None

Return Values

Page 268: wp-api

(string) Full path to file.

ExamplesNotes

Uses: apply_filters() on "{$type}_template" on result from locate_template().Uses: locate_template() on "{$type}.php".

Change Log

Since: 1.5.0

Source File

get_query_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_query_template"Categories: Functions | New page created

Function Reference/get rss

Contents1 Description2 Usage3 Example4 Parameters5 Output6 Further reading

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 listtags itself.

Uses the MagpieRSS and RSSCache functions for parsing and automatic caching and the Snoopy HTTP client for the actual retrieval.

Usage

<?phprequire_once(ABSPATH . WPINC . '/rss-functions.php');get_rss($uri, $num = 5);?>

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 anexisting RSS feed:

<?php require_once(ABSPATH . WPINC . '/rss-functions.php');echo '<ol>';get_rss('http://example.com/rss/feed/goes/here');echo '</ol>';?>

Parameters

$uri(URI) (required) The URI of the RSS feed you want to retrieve. The resulting parsed feed is returned, with the more interesting anduseful bits in the items array.

Default: None

$num(integer) (optional) The number of items to display.

Default: 5

Page 269: wp-api

Output

The output from the above example will look like the following:

<ol><li><a href='LINK FROM FEED' title='DESCRIPTION FROM FEED'>TITLE FROM FEED</a><br /></li>(repeat for number of links specified)</ol>

Further reading

Function_Reference

Retrieved from "http://codex.wordpress.org/Function_Reference/get_rss"Category: Functions

Function Reference/get search comments feed link

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the permalink for the comments feed of the search results.

Usage

<?php get_search_comments_feed_link( $search_query, $feed ) ?>

Parameters

$search_query(string) (optional) Url search query.

Default: ''

$feed(string) (optional) Feed type.

Default: ''

Return Values

(string)

ExamplesNotes

Uses: get_search_query() if no query supplied.

Change Log

Since: 2.5.0

Source File

get_search_comments_feed_link() is located in wp-includes/link-template.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_search_comments_feed_link"Categories: Functions | New page created

Function Reference/get search feed link

Page 270: wp-api

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the permalink for the feed of the search results.

Usage

<?php get_search_feed_link( $search_query, $feed ) ?>

Parameters

$search_query(string) (optional) URL search query.

Default: ''

$feed(string) (optional) Feed type.

Default: ''

Return Values

(string) Returns a url after the 'search_feed_link' filters have been applied.

ExamplesNotes

Uses: get_search_query() if no query supplied.

Change Log

Since: 2.5.0

Source File

get_search_feed_link() is located in wp-includes/link-template.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_search_feed_link"Categories: Functions | New page created

Function Reference/get search template

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve path of search template in current or parent template.

Usage

Page 271: wp-api

<?php get_search_template() ?>

Parameters

None.

Return Values

(string) Result of get_query_template('search').

ExamplesNotes

Uses: get_query_template()

Change Log

Since: 1.5.0

Source File

get_search_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_search_template"Categories: Functions | New page created

Function Reference/get single template

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve path of single template in current or parent template.

Usage

<?php get_single_template() ?>

Parameters

None.

Return Values

(string) Result of get_query_template('single').

ExamplesNotes

Uses: get_query_template()

Change Log

Since: 1.5.0

Source File

get_single_template() is located in wp-includes/theme.php.

Page 272: wp-api

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_single_template"Categories: Functions | New page created

Function Reference/get stylesheet

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve name of the current stylesheet.

The theme name that the administrator has currently set the front end theme as.

For all extensive purposes, the template name and the stylesheet name are going to be the same for most cases.

Usage

<?php get_stylesheet() ?>

Parameters

None.

Return Values

(string) Stylesheet name.

ExamplesNotes

Uses: apply_filters() Calls 'stylesheet' filter on stylesheet name.Uses: get_option() to retrieve the 'stylesheet' option.

Change Log

Since: 1.5.0

Source File

get_stylesheet() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_stylesheet"Categories: Functions | New page created

Function Reference/get stylesheet directory

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Page 273: wp-api

Retrieve stylesheet directory path for current theme.

Usage

<?php get_stylesheet_directory() ?>

Parameters

None.

Return Values

(string) Path to current theme directory.

ExamplesNotes

Uses: apply_filters() Calls 'stylesheet_directory' filter on stylesheet path and name.Uses: get_stylesheet()Uses: get_theme_root()

Change Log

Since: 1.5.0

Source File

get_stylesheet_directory() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_stylesheet_directory"Categories: Functions | New page created

Function Reference/get stylesheet directory uri

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve stylesheet directory URI.

Usage

<?php get_stylesheet_directory_uri() ?>

Parameters

None.

Return Values

(string) Returns stylesheet directory URI.

ExamplesNotes

Uses: apply_filters() Calls 'stylesheet_directory_uri' filter on stylesheet path and name.Uses: get_stylesheet()Uses: get_theme_root()

Page 274: wp-api

Change Log

Since: 1.5.0

Source File

get_stylesheet_directory_uri() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri"Categories: Functions | New page created

Function Reference/get stylesheet uri

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve URI of current theme stylesheet.

The stylesheet file name is 'style.css' which is appended to get_stylesheet_directory_uri() path.

Usage

<?php get_stylesheet_uri() ?>

Parameters

None.

Return Values

(string) Returns URI of current theme stylesheet.

ExamplesNotes

Uses: apply_filters() Calls 'stylesheet_uri' filter on stylesheet URI path and stylesheet directory URI.Uses: get_stylesheet_directory_uri()

Change Log

Since: 1.5.0

Source File

get_stylesheet_uri() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_stylesheet_uri"Categories: Functions | New page created

Function Reference/get tag

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes

Page 275: wp-api

7 Change Log8 Source File9 Related

Description

Retrieve post tag by tag ID or tag object.

If you pass the $tag parameter an object, which is assumed to be the tag row object retrieved the database. It will cache the tag data.

If you pass $tag 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 get_term(), then both types will be passed through several filters and finally sanitized based on the $filter parameter value.

Usage

<?php &get_tag( $tag, $output, $filter ) ?>

Parameters

$tag(integer|object) (required)

Default: None

$output(string) (optional) Constant OBJECT, ARRAY_A, or ARRAY_N

Default: OBJECT

$filter(string) (optional) Default is raw or no WordPress defined filter will applied.

Default: 'raw'

Return Values

(object|array) Return type based on $output value.

ExamplesNotesChange Log

Since: 2.3.0

Source File

&get_tag() is located in wp-includes/category.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_tag"Categories: Functions | New page created

Function Reference/get tags

Taken and slightly altered from the notes in the taxonomy.php file for get_terms, on which this function relies:

Retrieves a list of post tags based on the criteria provided in $args. The list of arguments that $args can contain, which will overwrite thedefaults:

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.

Page 276: wp-api

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 "slug" 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 begin with the value of 'name__like', case-insensitive. Default is empty string.

The argument 'pad_counts', if set to true will include the quantity of a term's children in the quantity of each term's "count" object variable.

The 'get' argument, if set to 'all' instead of its default empty string, returns terms regardless of ancestry or whether the terms are empty.

The 'child_of' argument, 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 willbe 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.

The 'parent' argument, when used, should be set to the integer of a term ID. Its default is the empty string, which has a different meaning fromthe 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 integeraccording 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 termX is the father of term Y, not its grandfather or great-grandfather, etc.

Related

the_tagsget_the_tagsget_the_tag_list

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_tags"Categories: Functions | Copyedit

Function Reference/get template

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve name of the current theme.

Usage

<?php get_template() ?>

Parameters

None.

Return Values

(string) Template name.

ExamplesNotes

Uses: apply_filters() Calls 'template' filter on template option.Uses: get_option() to retrieve 'template' option.

Page 277: wp-api

Change Log

Since: 1.5.0

Source File

get_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_template"Categories: Functions | New page created

Function Reference/get template directory

Contents1 Description2 Usage3 Possible Arguments4 Returns

Description

Retrieves the absolute path to the template directory.

Usage

echo get_template_directory();

Possible Arguments

None

Returns

The path to the template directory e.g. /yourpathhere/wp-content/themes/theme_name

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_template_directory"Categories: Functions | New page created | Copyedit

Function Reference/get template directory uri

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve template directory URI.

Usage

<?php get_template_directory_uri() ?>

Parameters

None.

Return Values

(string) Template directory URI.

Page 278: wp-api

ExamplesNotes

Uses: apply_filters() Calls 'template_directory_uri' filter on template directory URI path and template name.Uses: get_template()Uses: get_theme_root_uri()

Change Log

Since: 1.5.0

Source File

get_template_directory_uri() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_template_directory_uri"Categories: Functions | New page created

Function Reference/get term by

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Get all Term data from database by Term field and data.

Warning: $value is not escaped for 'name' $field. You must do it yourself, if required.

The default $field is 'id', therefore it is possible to also use null for field, but not recommended that you do so.

If $value does not exist, the return value will be false. If $taxonomy exists and $field and $value combinations exist, the Term will be returned.

Usage

<?php get_term_by( $field, $value, $taxonomy, $output, $filter ) ?>

Parameters

$field(string) (required) Either 'slug', 'name', or 'id'

Default: None

$value(string|integer) (required) Search for this term value

Default: None

$taxonomy(string) (required) Taxonomy Name

Default: None

$output(string) (optional) Constant OBJECT, ARRAY_A, or ARRAY_N

Default: OBJECT

$filter(string) (optional) default is raw or no WordPress defined filter will applied.

Default: 'raw'

Return Values

(mixed)

Page 279: wp-api

Term Row from database. Will return false if $taxonomy does not exist or $term was not found.

ExamplesNotes

Warning: $value is not escaped for 'name' $field. You must do it yourself, if required.See sanitize_term_field() The $context param lists the available values for 'get_term_by' $filter param.Uses: sanitize_term() Cleanses the term based on $filter context before returning.Uses global: (object) $wpdb

Change Log

Since: 2.3.0

Source File

get_term_by() is located in wp-includes/taxonomy.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_term_by"Categories: Functions | New page created

Function Reference/get term children

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Merge all term children into a single array.

This recursive function will merge all of the children of $term into the same array. Only useful for taxonomies which are hierarchical.

Will return an empty array if $term does not exist in $taxonomy.

Usage

<?php get_term_children( $term, $taxonomy ) ?>

Parameters

$term(string) (required) Name of Term to get children

Default: None

$taxonomy(string) (required) Taxonomy Name

Default: None

Return Values

(array|WP_Error) List of Term Objects. WP_Error returned if $taxonomy does not exist

ExamplesNotes

Uses: $wpdbUses: _get_term_hierarchy()Uses: get_term_children Used to get the children of both $taxonomy and the parent $term

Change Log

Page 280: wp-api

Since: 2.3.0

Source File

get_term_children() is located in wp-includes/taxonomy.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_term_children"Categories: Functions | New page created

Function Reference/get terms

Contents1 WARNING2 Description3 Usage4 Possible Arguments5 Details

WARNING

This is a new article, there may be problems. Please consult the function itself in /wp-includes/taxonomy.php if you are having problems.

Description

Retrieve the terms in taxonomy or list of taxonomies.

Usage

get_terms($taxonomies, $args = )

Possible Arguments

Arguments are passed in the format used by wp_parse_args(). e.g.

$myterms = get_terms("orderby=count&hide_empty=false");

Any arguments you don't specify will use the default (specified below). The list 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.fields - Default is all.slug - Any terms that has this value. Default is empty string.hierarchical - Whether to return hierarchical taxonomy. Default is true.name__like - Default is empty string.pad_counts - Default is FALSE. If true, count all of the children along with the $terms.get - Default is nothing . Allow for overwriting 'hide_empty' and 'child_of', which can be done by setting the value to 'all'.child_of - Default is 0. Get all descendents of this term.parent - Default is 0. Get direct children of this term (only terms who's explicit parent is this value)

Details

You can fully inject any customizations to the query before it is sent, as well as control the output with a filter.

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.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_terms"Categories: Functions | New page created

Function Reference/get the category rss

Contents

Page 281: wp-api

1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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 theRSS2, Atom, or RSS1 and RSS0.91 RDF feeds.

Usage

<?php get_the_category_rss( $type ) ?>

Parameters

$type(string) (optional) default is 'rss'. Either 'rss', 'atom', or 'rdf'.

Default: 'rss'

Return Values

(string) All of the post categories for displaying in the feed.

ExamplesNotes

Uses: apply_filters()

Change Log

Since: 2.1.0

Source File

get_the_category_rss() is located in wp-includes/feed.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_the_category_rss"Categories: Functions | New page created

Function Reference/get the content

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the post content.

Usage

<?php get_the_content( $more_link_text, $stripteaser, $more_file ) ?>

Parameters

Page 282: wp-api

$more_link_text(string) (optional) Content for when there is more text.

Default: null

$stripteaser(string) (optional) Teaser content before the more text.

Default: 0

$more_file(string) (optional) Not used.

Default: ''

Return Values

(string)

ExamplesNotes

Uses: post_password_required()Uses: get_the_password_form() if post_password_required() failsUses: wp_kses_no_null() while processing the tag.Uses: balanceTags()Uses: get_permalink()Uses global: $idUses global: $postUses global: $moreUses global: $pageUses global: $pagesUses global: $multipageUses global: $previewUses global: $pagenow

Change Log

Since: 0.71

Source File

get_the_content() is located in wp-includes/post-template.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_the_content"Categories: Functions | New page created

Function Reference/get the title rss

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the current post title for the feed.

Usage

<?php get_the_title_rss() ?>

Parameters

None.

Page 283: wp-api

Return Values

(string) Current post title.

ExamplesNotes

Uses: apply_filters() Calls 'the_title_rss' on the post title.Uses: get_the_title() to get the post title.

Change Log

Since: 2.0.0

Source File

get_the_title_rss() is located in wp-includes/feed.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_the_title_rss"Categories: Functions | New page created

Function Reference/get theme

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve theme data.

Usage

<?php get_theme( $theme ) ?>

Parameters

$theme(string) (required) Theme name.

Default: None

Return Values

(array|null) Null, if theme name does not exist. Theme data, if exists.

ExamplesNotes

Uses: get_themes()

Change Log

Since: 1.5.0

Source File

get_theme() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_theme"

Page 284: wp-api

Categories: Functions | New page created

Function Reference/get theme data

Contents1 Description2 Usage3 Example

3.1 Usage4 Parameters5 Return values

Description

Returns an array of information about a theme file.

Usage

<?php $theme_data = get_theme_data($theme_filename); ?>

ExampleUsage

Get the information from the default themes style.css and display the Name and author linked with there respective URIs if they exist.

<?php $theme_data = get_theme_data(ABSPATH . 'wp-content/themes/default/style.css'); echo $theme_data['Title']; echo $theme_data['Author'];?>

Parameters

$theme_filename(string) (required) Path and filename of the theme's style.css.

Default: None

Return values

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 isdefined.

'Description' (string) A HTML fragment containg the Themes description after it has passed through wptexturize.

'Author' (string) Either the Author's name or a HTML fragment containg the Author's name linked to the Author's URI if the Author's URI isdefined.

'Version' (string) The Theme's version number.

'Template' (string) The name of the parent Theme if one exists.

'Status' (string) defaults to 'publish'

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_theme_data"Categories: Functions | Copyedit

Function Reference/get theme mod

Contents1 Description2 Usage3 Parameters

Page 285: wp-api

4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve theme modification value for the current theme.

If the modification name does not exist, then the $default will be passed through sprintf() with the first string the template directory URI and thesecond string the stylesheet directory URI.

Usage

<?php get_theme_mod( $name, $default ) ?>

Parameters

$name(string) (required) Theme modification name.

Default: None

$default(boolean|string) (optional)

Default: false

Return Values

(string)

ExamplesNotes

Uses: apply_filters() Calls 'theme_mod_$name' filter on the value.

Change Log

Since: 2.1.0

Source File

get_theme_mod() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_theme_mod"Categories: Functions | New page created

Function Reference/get theme root

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve path to themes directory.

Does not have trailing slash.

Usage

<?php get_theme_root() ?>

Page 286: wp-api

Parameters

None.

Return Values

(string) Theme path.

ExamplesNotes

Uses: apply_filters() Calls 'theme_root' filter on path.

Change Log

Since: 1.5.0

Source File

get_theme_root() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_theme_root"Categories: Functions | New page created

Function Reference/get theme root uri

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve URI for themes directory.

Does not have trailing slash.

Usage

<?php get_theme_root_uri() ?>

Parameters

None.

Return Values

(string) Themes URI.

ExamplesNotes

Uses: apply_filters() Calls 'theme_root_uri' filter on uri.Uses: content_url() to retrieve the 'themes' uri.Uses: get_option() to retrieve 'siteurl' option.

Change Log

Since: 1.5.0

Source File

Page 287: wp-api

get_theme_root_uri() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_theme_root_uri"Categories: Functions | New page created

Function Reference/get themes

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve list of themes with theme data in theme directory.

The theme is broken if it doesn't have a parent theme and is missing either style.css or index.php. If the theme has a parent theme then it isbroken, if it is missing style.css; index.php is optional. The broken theme list is saved in the $wp_broken_themes global, which is displayed onthe theme list in the administration panels.

Usage

<?php get_themes() ?>

Parameters

None.

Return Values

(array) Theme list with theme data.

ExamplesNotes

Uses: get_theme_root()Uses: get_theme_data()Uses: wptexturize()Uses global: (array) $wp_themes holds working themes list.Uses global: (array) $wp_broken_themes holds broken themes list.

Change Log

Since: 1.5.0

Source File

get_themes() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_themes"Categories: Functions | New page created

Function Reference/get to ping

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes

Page 288: wp-api

7 Change Log8 Source File9 Related

Description

Retrieve URLs that need to be pinged.

Usage

<?php get_to_ping( $post_id ) ?>

Parameters

$post_id(integer) (required) Post ID

Default: None

Return Values

(array) Returns array of URLs that need to be pinged.

ExamplesNotes

Uses global: (object) $wpdb to read 'to_ping' field from _posts table from database.Uses: apply_filters() on 'get_to_ping' on the URLs that need to be pinged.

Change Log

Since: 1.5.0

Source File

get_to_ping() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_to_ping"Categories: Functions | New page created

Function Reference/get user option

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve user option that can be either global, user, or blog.

If the user ID is not given, then the current user will be used instead. If the user ID is given, then the user data will be retrieved. The filter for theresult will also pass the original option name and finally the user data object as the third parameter.

The option will first check for the non-global name, then the global name, and if it still doesn't find it, it will try the blog option. The option caneither be modified or set by a plugin.

Usage

<?php get_user_option( $option, $user, $check_blog_options ) ?>

Parameters

$option

Page 289: wp-api

(string) (required) User option name.Default: None

$user(integer) (optional) User ID.

Default: 0

$check_blog_options(boolean) (optional) Whether to check for an option in the options table if a per-user option does not exist.

Default: true

Return Values

(mixed)

ExamplesNotes

Uses: apply_filters() Calls 'get_user_option_$option' hook with result, option parameter, and user data object.Uses global: (object) $wpdb WordPress database object for queries.

Change Log

Since: 2.0.0

Source File

get_user_option() is located in wp-includes/user.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_user_option"Categories: Functions | New page created

Function Reference/get userdata

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Accessing Usermeta Data

4 Parameters5 Values in users & user_meta table

5.1 users5.2 useful in user_meta

6 See Also

Description

Returns an object with the information pertaining to the user whose ID is passed to it. Properties map directly to wp_users table in the database(see Database Description).

Usage

<?php get_userdata(userid); ?>

ExamplesDefault Usage

The call to get_userdata() returns the user's data, where it can be retrieved using member variables.

<?php $user_info = get_userdata(1);

echo('Username: ' . $user_info->user_login . "\n"); echo('User level: ' . $user_info->user_level . "\n"); echo('User ID: ' . $user_info->ID . "\n");?>

Username: admin

Page 290: wp-api

User level: 10User ID: 1

Accessing Usermeta Data

<?php $user_info = get_userdata(1);

echo($user_info->last_name . ", " . $user_info->first_name . "\n");?>

Blow, Joe

Parameters

$userid(integer) (required) The ID of the user whose data should be retrieved.

Default: None

Values in users & user_meta table

Here are the values in the users table you can access via this function:

users

IDuser_loginuser_passuser_nicenameuser_emailuser_urluser_registereduser_activation_keyuser_statusdisplay_name

useful in user_meta

first_namelast_namenicknameuser_leveladmin_color (Theme of your admin page. Default is fresh.)closedpostboxes_pagenicknameprimary_blogrich_editingsource_domain

See Also

Function_Reference/get_currentuserinfo, Author_Templates

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_userdata"Categories: Functions | Copyedit

Function Reference/get userdatabylogin

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File

Page 291: wp-api

9 Related

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Retrieve user info by login name.

Usage

<?php get_userdatabylogin( $user_login ) ?>

Parameters

$user_login(string) (required) User's username

Default: None

Return Values

(boolean|object) False on failure. User DB row object on success.

ExamplesNotes

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Change Log

Since: 0.71

Source File

get_userdatabylogin() is located in wp-includes/pluggable.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_userdatabylogin"Categories: Functions | New page created

Function Reference/get usermeta

Contents1 Description2 Usage3 Example4 Parameters

Description

This function returns the value of a specific metakey pertaining to the user whose ID is passed via the userid parameter.

Usage

<?php get_usermeta(userid,'metakey'); ?>

Example

This example returns and then displays the last name for user id 9.

<?php $user_last = get_usermeta(9,'last_name'); ?><?php echo('User ID 9's last name: ' . $user_last . '\n'); ?>

User ID 9's last name: Jones

Parameters

$userid(integer) (required) The ID of the user whose data should be retrieved.

Page 292: wp-api

Default: None

$metakey(string) (required) The metakey value to be returned.

'metakey' The meta_key in the wp_usermeta table for the meta_value to be returned.Default: None

Retrieved from "http://codex.wordpress.org/Function_Reference/get_usermeta"Category: Functions

Function Reference/get usernumposts

Contents1 Description2 Usage3 Example

3.1 Default Usage4 Parameters

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 DatabaseDescription).

Usage

<?php get_usernumposts(userid); ?>

ExampleDefault Usage

The call to get_usernumposts returns the number of posts made by the user.

<?php echo('Posts made: ' . get_usernumposts(1)); ?>

Posts made: 143

Parameters

$userid(integer) (required) The ID of the user whose post count should be retrieved.

Default: None

Retrieved from "http://codex.wordpress.org/Function_Reference/get_usernumposts"Category: Functions

Function Reference/get weekstartend

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Get the week start and end from the MySQL DATETIME or date string.

Usage

<?php get_weekstartend( $mysqlstring, $start_of_week ) ?>

Parameters

Page 293: wp-api

$mysqlstring(string) (required) Date or MySQL DATETIME field type.

Default: None

$start_of_week(integer) (optional) Start of the week as an integer.

Default: ''

Return Values

(array) Keys are 'start' and 'end'.

ExamplesNotes

Uses: get_option() to retrieve the 'start_of_week' option if $start_of_week is not numeric.

Change Log

Since: 0.71

Source File

get_weekstartend() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/get_weekstartend"Categories: Functions | New page created

Function Reference/header image

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display header image path.

Usage

<?php header_image() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotesChange Log

Since: 2.1.0

Source File

header_image() is located in wp-includes/theme.php.

Page 294: wp-api

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/header_image"Categories: Functions | New page created

Function Reference/htmlentities2

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Convert entities, while preserving already-encoded entities.

Usage

<?php htmlentities2( $myHTML ) ?>

Parameters

$myHTML(string) (required) The text to be converted.

Default: None

Return Values

(string) Converted text.

ExamplesNotes

See Also: Borrowed from the PHP Manual user notes.

Change Log

Since: 1.2.2

Source File

htmlentities2() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/htmlentities2"Categories: Functions | New page created

Function Reference/human time diff

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Determines the difference between two timestamps.

Page 295: wp-api

The difference is returned in a human readable format such as "1 hour", "5 mins", "2 days".

Usage

<?php human_time_diff( $from, $to ) ?>

Parameters

$from(integer) (required) Unix timestamp from which the difference begins.

Default: None

$to(integer) (optional) Unix timestamp to end the time difference. Default becomes time() if not set.

Default: ''

Return Values

(string) Human readable time difference.

Examples

To print an entry's time ("2 days ago"):<?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?> For comments:<?php echo human_time_diff(get_comment_time('U'), current_time('timestamp')) . ' ago'; ?>

NotesChange Log

Since: 1.5.0

Source File

human_time_diff() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/human_time_diff"Categories: Functions | New page created

Function Reference/is blog installed

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Test whether blog is already installed.

The cache will be checked first. If you have a cache plugin, which saves the cache values, then this will work. If you use the default WordPresscache, and the database goes away, then you might have problems.

Checks for the option siteurl for whether WordPress is installed.

Usage

<?php is_blog_installed() ?>

Parameters

None.

Return Values

Page 296: wp-api

(boolean) Whether blog is already installed.

ExamplesNotes

Uses global: (object) $wpdb

Change Log

Since: 2.1.0

Source File

is_blog_installed() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/is_blog_installed"Categories: Functions | New page created

Function Reference/is emailDescription

Validates an e-mail address

Usage

<?php if (is_email($address)) // do something ?>

Parameters

$user_email (string) Address to check

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/is_email"Categories: Stubs | Functions | Conditional Tags

Function Reference/is local attachment

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Check if the attachment URI is local one and is really an attachment.

Usage

<?php is_local_attachment( $url ) ?>

Parameters

$url(string) (required) URL to check

Default: None

Return Values

(boolean)

Page 297: wp-api

True on success, false on failure.

ExamplesNotesChange Log

Since: 2.0.0

Source File

is_local_attachment() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/is_local_attachment"Categories: Functions | Conditional Tags | New page created

Function Reference/is new day

Contents1 Description2 Usage3 Examples4 Parameters5 Return Values6 Notes7 Change Log8 Source File9 Related

Description

This Conditional Tag checks if today is a new day. This is a boolean function, meaning it returns TRUE (1) when new day or FALSE (0) if not anew day.

Usage

<?php is_new_day(); ?>

ExamplesParameters

This tag does not accept any parameters.

Return Values

(boolean) TRUE (1) when new day, FALSE (0) if not a new day.

Notes

Uses global: (string) $day Holds the date of the day of the current post during The_Loop.Uses global: (string) $previousday Holds the date of the day of the previous post (if any) during The_Loop.

Change Log

Since: 0.71

Source File

is_new_day() is located in wp-includes/functions.php.

Related

is_home(), is_front_page(), is_search(), is_404(), is_singular(), is_page(), is_attachment(), is_local_attachment(), is_single(), is_sticky(),is_archive(), is_category(), is_tag(), is_author(), is_date(), is_year(), is_month(), is_day(), is_time(), is_admin(), is_preview(), is_paged(),is_page_template(), is_plugin_page(), is_new_day(), is_feed(), is_trackback(), is_comments_popup(), comments_open(), pings_open(),is_taxonomy(), is_taxonomy_hierarchical()

Retrieved from "http://codex.wordpress.org/Function_Reference/is_new_day"Categories: Conditional Tags | Functions

Page 298: wp-api

Function Reference/is serialized

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Check value to find if it was serialized.

If $data is not an string, then returned value will always be false. Serialized data is always a string.

Usage

<?php is_serialized( $data ) ?>

Parameters

$data(mixed) (required) Value to check to see if was serialized.

Default: None

Return Values

(boolean) False if not serialized and true if it was.

ExamplesNotes

Data might need to be serialized 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

is_serialized() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/is_serialized"Categories: Functions | Conditional Tags | New page created

Function Reference/is serialized string

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Check whether serialized data is of string type.

Usage

<?php is_serialized_string( $data ) ?>

Page 299: wp-api

Parameters

$data(mixed) (required) Serialized data

Default: None

Return Values

(boolean) False if not a serialized string, true if it is.

ExamplesNotes

Data might need to be serialized 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

is_serialized_string() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/is_serialized_string"Categories: Functions | Conditional Tags | New page created

Function Reference/is taxonomy

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

This Conditional Tag checks if the taxonomy name exists by passing a taxonomy name as an argument to it. This is a boolean function uses aglobal $wp_taxonomies variable for checking if taxonomy name existence, meaning it returns either TRUE if the taxonomy name exist orFALSE if it doesn't exist.

Usage

<?php is_taxonomy($taxonomy); ?>

Example

$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

Parameters

$taxonomy(string) (required) The name of the taxonomy

Default: None

Related

is_home(), is_front_page(), is_search(), is_404(), is_singular(), is_page(), is_attachment(), is_local_attachment(), is_single(), is_sticky(),

Page 300: wp-api

is_archive(), is_category(), is_tag(), is_author(), is_date(), is_year(), is_month(), is_day(), is_time(), is_admin(), is_preview(), is_paged(),is_page_template(), is_plugin_page(), is_new_day(), is_feed(), is_trackback(), is_comments_popup(), comments_open(), pings_open(),is_taxonomy(), is_taxonomy_hierarchical()

Retrieved from "http://codex.wordpress.org/Function_Reference/is_taxonomy"Categories: Conditional Tags | Functions

Function Reference/is taxonomy hierarchical

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

This Conditional Tag checks if the taxonomy object is hierarchical. This is a boolean function uses a global, meaning it returns either TRUE orFALSE (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

<?php is_taxonomy_hierarchical( $taxonomy ) ?>

Parameters

$taxonomy(string) (required) Name of taxonomy object

Default: None

Return Values

(boolean) Whether the taxonomy is hierarchical

ExamplesNotes

See Also: WordPress Taxonomy.Uses: is_taxonomy() Checks whether taxonomy exists.Uses: get_taxonomy() Used to get the taxonomy object.

Change Log

Since: 2.3.0

Source File

is_taxonomy_hierarchical() is located in wp-includes/taxonomy.php.

Related

is_home(), is_front_page(), is_search(), is_404(), is_singular(), is_page(), is_attachment(), is_local_attachment(), is_single(), is_sticky(),is_archive(), is_category(), is_tag(), is_author(), is_date(), is_year(), is_month(), is_day(), is_time(), is_admin(), is_preview(), is_paged(),is_page_template(), is_plugin_page(), is_new_day(), is_feed(), is_trackback(), is_comments_popup(), comments_open(), pings_open(),is_taxonomy(), is_taxonomy_hierarchical()

Retrieved from "http://codex.wordpress.org/Function_Reference/is_taxonomy_hierarchical"Categories: Conditional Tags | Functions

Function Reference/is term

Contents

Page 301: wp-api

1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Check if Term exists.

Returns the index of a defined term, or 0 (false) if the term doesn't exist.

Usage

<?php is_term( $term, $taxonomy ) ?>

Parameters

$term(integer|string) (required) The term to check

Default: None

$taxonomy(string) (optional) The taxonomy name to use

Default: ''

Return Values

(mixed) Get the term id or Term Object, if exists.

ExamplesNotes

Uses global: (object) $wpdbUses global: (object) $term

Change Log

Since: 2.3.0

Source File

is_term() is located in wp-includes/taxonomy.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/is_term"Categories: Functions | Conditional Tags | New page created

Function Reference/is user logged in

Contents1 Description2 Usage3 Examples4 Parameters5 Further Reading

Description

Returns boolean true or false depending on whether the current visitor is logged in.

Usage

<?php if (is_user_logged_in()){ ... } ?>

Page 302: wp-api

Examples

Use is_user_logged_in() in your theme files to display different output depending on whether the user is logged in.

<?php if (is_user_logged_in()){ echo "Welcome, registered user!"; } else { echo "Welcome, visitor!"; };?>

Parameters

This function does not accept any parameters.

Further Reading

Function_Reference

Retrieved from "http://codex.wordpress.org/Function_Reference/is_user_logged_in"Categories: Functions | Conditional Tags | New page created

Function Reference/iso8601 timezone to offset

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Computes an offset in seconds from an ISO 8601 timezone.

Usage

<?php iso8601_timezone_to_offset( $timezone ) ?>

Parameters

$timezone(string) (required) Either 'Z' for 0 offset or '±hhmm'.

Default: None

Return Values

(integer|float) The offset in seconds.

ExamplesNotes

See Also: ISO 8601

Change Log

Since: 1.5.0

Source File

iso8601_timezone_to_offset() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/iso8601_timezone_to_offset"Categories: Functions | New page created

Page 303: wp-api

Function Reference/iso8601 to datetime

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Converts an iso8601 date to MySQL DATETIME format used by post_date[_gmt].

Usage

<?php iso8601_to_datetime( $date_string, $timezone ) ?>

Parameters

$date_string(string) (required) Date and time in ISO 8601 format.

Default: None

$timezone(string) (optional) If set to GMT returns the time minus gmt_offset. Default is 'user'.

Default: 'user'

Return Values

(string) The date and time in MySQL DATETIME format - Y-m-d H:i:s.

ExamplesNotes

See Also: ISO 8601

Change Log

Since: 1.5.0

Source File

iso8601_to_datetime() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/iso8601_to_datetime"Categories: Functions | New page created

Function Reference/js escape

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Escape single quotes. Convert double quotes. Fix line endings.

The filter 'js_escape' is also applied here.

Page 304: wp-api

Usage

<?php js_escape( $text ) ?>

Parameters

$text(string) (required) The text to be escaped.

Default: None

Return Values

(string) Escaped text.

ExamplesNotes

Uses: wp_specialchars() for double quote conversion.

Change Log

Since: 2.0.4

Source File

js_escape() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/js_escape"Categories: Functions | New page created

Function Reference/load default textdomain

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Loads default translated strings based on locale.

Loads the .mo file in WP_LANG_DIR constant path from WordPress root. The translated (.mo) file is named based off of the locale.

Usage

<?php load_default_textdomain() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotes

l10n is an abbreviation for localization.

Change Log

Page 305: wp-api

Since: 1.5.0

Source File

load_default_textdomain() is located in wp-includes/l10n.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/load_default_textdomain"Categories: Functions | New page created

Function Reference/load plugin textdomain

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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 with a dash followed bya dash, and then the locale exactly.

Usage

<?php load_plugin_textdomain( $domain, $abs_rel_path, $plugin_rel_path ) ?>

Parameters

$domain(string) (required) Unique identifier for retrieving translated strings.

Default: None

$abs_rel_path(string) (optional) Relative path to ABSPATH of a folder, where the .mo file resides. Deprecated, but still functional until 2.7

Default: false

$plugin_rel_path(string) (optional) Relative path to WP_PLUGIN_DIR. This is the preferred argument to use. It takes precendence over $abs_rel_path

Default: false

Return Values

(void) This function does not return a value.

ExamplesNotes

l10n is an abbreviation for localization.

Change Log

Since: 1.5.0

Source File

load_plugin_textdomain() is located in wp-includes/l10n.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/load_plugin_textdomain"Categories: Functions | New page created

Function Reference/load template

Page 306: wp-api

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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 variablesare also available.

Usage

<?php load_template( $_template_file ) ?>

Parameters

$_template_file(string) (required) Path to template file.

Default: None

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses global: (object) $wp_query to extract extract() global variables returned by the query_vars method while protecting the currentvalues in these global variables:

(unknown type) $posts(unknown type) $post(boolean) $wp_did_header Returns true if the WordPress header was already loaded. See the /wp-blog-header.php file fordetails.(boolean) $wp_did_template_redirect(object) $wp_rewrite(object) $wpdb(string) $wp_version holds the installed WordPress version number.(string) $wp(string) $id(string) $comment(string) $user_ID

Change Log

Since: 1.5.0

Source File

load_template() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/load_template"Categories: Functions | New page created

Function Reference/load textdomain

Contents1 Description2 Usage3 Parameters

Page 307: wp-api

4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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 mofile will be placed in the $l10n global by $domain and will be an gettext_reader object.

Usage

<?php load_textdomain( $domain, $mofile ) ?>

Parameters

$domain(string) (required) Unique identifier for retrieving translated strings

Default: None

$mofile(string) (required) Path to the .mo file

Default: None

Return Values

(null) On failure returns null and also on success returns nothing.

ExamplesNotes

Uses global: (array) $l10n Gets list of domain translated string gettext_reader objects.Uses: CacheFileReader() Reads the MO file.Uses: gettext_reader obect. Allows for retrieving translated strings.l10n is an abbreviation for localization.

Change Log

Since: 1.5.0

Source File

load_textdomain() is located in wp-includes/l10n.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/load_textdomain"Categories: Functions | New page created

Function Reference/load theme textdomain

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Loads the theme's translated strings.

Page 308: wp-api

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 $domain.

The .mo files must be named based on the locale exactly.

Usage

<?php load_theme_textdomain( $domain, $path ) ?>

Parameters

$domain(string) (required) Unique identifier for retrieving translated strings.

Default: None

$path(unknown) (optional)

Default: false

Return Values

(void) This function does not return a value.

ExamplesNotes

l10n is an abbreviation for localization.

Change Log

Since: 1.5.0

Source File

load_theme_textdomain() is located in wp-includes/l10n.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/load_theme_textdomain"Categories: Functions | New page created

Function Reference/locale stylesheet

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display localized stylesheet link element.

If get_locale_stylesheet_uri() returns a value, locale_stylesheet will echo a valid xhtml <link> tag like this:

<link rel="stylesheet" href="path_to_stylesheet" type="text/css" media="screen" />

If get_locale_stylesheet_uri() does not return a value then the function exits immediately.

Usage

<?php locale_stylesheet() ?>

Parameters

None.

Return Values

Page 309: wp-api

(void) This function does not return a value.

ExamplesNotes

Uses get_locale_stylesheet_uri().

Change Log

Since: 2.1.0

Source File

locale_stylesheet() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/locale_stylesheet"Categories: Functions | New page created

Function Reference/make clickable

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Convert plain text URI to HTML links.

Converts URI, www, ftp, and email addresses. Finishes by fixing links within links.

Usage

<?php make_clickable( $ret ) ?>

Parameters

$ret(string) (required) Content to convert URIs.

Default: None

Return Values

(string) Content with converted URIs.

ExamplesNotesChange Log

Since: 0.71

Source File

make_clickable() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/make_clickable"Categories: Functions | New page created

Function Reference/make url footnote

Page 310: wp-api

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Strip HTML and put links at the bottom of stripped content.

Searches for all of the links, strips them out of the content, and places them at the bottom of the content with numbers.

Usage

<?php make_url_footnote( $content ) ?>

Parameters

$content(string) (required) Content to get links

Default: None

Return Values

(string) HTML stripped out of content with links at the bottom.

ExamplesNotesChange Log

Since: 0.71

Source File

make_url_footnote() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/make_url_footnote"Categories: Functions | New page created

Function Reference/maybe serialize

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Serialize data, if needed.

Usage

<?php maybe_serialize( $data ) ?>

Parameters

Page 311: wp-api

$data(mixed) (required) Data that might be serialized.

Default: None

Return Values

(mixed) A scalar data

ExamplesNotes

Data might need to be serialized 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

maybe_serialize() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/maybe_serialize"Categories: Functions | New page created

Function Reference/maybe unserialize

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Unserialize value only if it was serialized.

Usage

<?php maybe_unserialize( $original ) ?>

Parameters

$original(string) (required) Maybe unserialized original, if is needed.

Default: None

Return Values

(mixed) Unserialized data can be any type.

ExamplesNotes

Data might need to be serialized 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

maybe_unserialize() is located in wp-includes/functions.php.

Page 312: wp-api

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/maybe_unserialize"Categories: Functions | New page created

Function Reference/merge filtersDescription

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 thefunctions attached to the all hook with the functions of a specific hoook defined by $tag.

Parameters

$tag(string) (required) The filter hook of which the functions should be merged.

Default: None

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/merge_filters"Categories: Stubs | Functions

Function Reference/mysql2dateDescription

Translates dates from mysql format to any format acceptable by the php date() function

Usage

mysql2date($dateformatstring, $mysqlstring, $translate = true)

$dateformatstring The requested output format. any format acceptable by the php date() function.

$mysqlstring the input string, probably mysql database output.

$translate not sure what this does.

Retrieved from "http://codex.wordpress.org/Function_Reference/mysql2date"Category: Functions

Function Reference/next comments link

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display link to next comments pages.

Usage

<?php next_comments_link( $label, $max_page ) ?>

Parameters

$label(string) (optional) Label for link text.

Default: ''

$max_page

Page 313: wp-api

(integer) (optional) Max page.Default: 0

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses global: (object) $wp_query

Change Log

Since: 2.7.0

Source File

next_comments_link() is located in wp-includes/link-template.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/next_comments_link"Categories: Functions | New page created

Function Reference/nocache headers

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Sets the headers to prevent caching for the different browsers.

Different browsers support different nocache headers, so several headers must be sent so that all of them get the point that no caching shouldoccur.

Usage

<?php nocache_headers() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotesChange Log

Since: 2.0.0

Source File

nocache_headers() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/nocache_headers"

Page 314: wp-api

Categories: Functions | New page created

Function Reference/page uri index

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve all pages and attachments for pages URIs.

The attachments are for those that have pages as parents and will be retrieved.

Usage

<?php page_uri_index() ?>

Parameters

None

Return Values

(array) Array of page URIs as first element and attachment URIs as second element.

ExamplesNotes

Uses: $wpdbUses: get_page_hierarchy() on db query result in posts table.Uses: get_page_uri() on each page ID.

Change Log

Since: 2.5.0

Source File

page_uri_index() is located in wp-includes/rewrite.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/page_uri_index"Categories: Functions | New page created

Function Reference/paginate comments links

In version 2.7 WordPress added the Enhanced Comment Display system to make comments.php files much simpler to write and edit. One isthe ability to easily break comments into pages so that you dont' end up with hundreds of comments all loading on every pageview.

You will need to set up the options in SETTINGS > DISCUSSION for paging to work.

The easiest way to do so is with the following function, which prints out a link to the next and previous comment pages, as well as a numberedlist of all the comment pages.

paginate_comments_links($args);

It accepts a query-style list of arguments similar to get_posts() or get_terms(). Here are the defaults:

'base' => add_query_arg( 'cpage', '%#%' ),'format' => ,'total' => $max_page,'current' => $page,

Page 315: wp-api

'echo' => true,'add_fragment' => '#comments'

These arguments are mostly to make it work though, so be careful if you change them.

If you want more control, you can also use the simpler next and previous functions:

next_comments_link($label=, $max_page = 0)

and

previous_comments_link($label=)

Retrieved from "http://codex.wordpress.org/Function_Reference/paginate_comments_links"

Function Reference/pingback

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Pings back the links found in a post.

Includes wp-include/class-IXR.php file if not already included.

Usage

<?php pingback( $content, $post_ID ) ?>

Parameters

$content(string) (required) Post content to check for links.

Default: None

$post_ID(integer) (required) Post ID.

Default: None

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses global: (string) $wp_version holds the installed WordPress version number.Uses: IXR_Client WordPress class.Uses: discover_pingback_server_uri()Uses: get_pung()Uses: url_to_postid()Uses: is_local_attachment()Uses: do_action_ref_array() on 'pre_ping' on 'post_links' and on pung() result.Uses: get_permalink()Uses: add_ping()

Change Log

Since: 0.71

Source File

Page 316: wp-api

pingback() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/pingback"Categories: Functions | New page created

Function Reference/pings open

Contents1 Description2 Usage3 Examples4 Parameters5 Related

DescriptionUsage

<?php pings_open(); ?>

ExamplesParametersRelated

is_home(), is_front_page(), is_search(), is_404(), is_singular(), is_page(), is_attachment(), is_local_attachment(), is_single(), is_sticky(),is_archive(), is_category(), is_tag(), is_author(), is_date(), is_year(), is_month(), is_day(), is_time(), is_admin(), is_preview(), is_paged(),is_page_template(), is_plugin_page(), is_new_day(), is_feed(), is_trackback(), is_comments_popup(), comments_open(), pings_open(),is_taxonomy(), is_taxonomy_hierarchical()

Retrieved from "http://codex.wordpress.org/Function_Reference/pings_open"Categories: Conditional Tags | Functions

Function Reference/plugin basename

Contents1 Description2 Usage3 Parameters4 Return5 Example

Description

Gets the basename of a plugin (extracts the name of a plugin from its filename).

Usage

<?php plugin_basename($file); ?>

Parameters

$file (string) The filename of a plugin.

Return

The basename of a plugin.

Example

If your plugin file is located at /home/www/wp-content/plugins/myplugin/myplugin.php, and you call:

$x = plugin_basename(__FILE__);

$x will equal "myplugin/myplugin.php".

If you would like to know the full url path to your plugin's directory, you can call:

Page 317: wp-api

$x = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));

$x will equal "http://[url-path-to-plugins]/[myplugin]/"

function writeCSS() { echo ( '<link rel=\"stylesheet\" type=\"text/css\" href=\"'. $x . 'myplugin.css\">' ); }add_action('wp_head', 'writeCSS');

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/plugin_basename"Categories: Stubs | Functions

Function Reference/popuplinks

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Adds target='_blank' and rel='external' to all HTML Anchor 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 atarget or rel attribute was already there and adjust its actions accordingly.

Usage

<?php popuplinks( $text ) ?>

Parameters

$text(string) (required) Content to replace links to open in a new window.

Default: None

Return Values

(string) Content that has filtered links.

ExamplesNotesChange Log

Since: 0.71

Source File

popuplinks() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/popuplinks"Categories: Functions | New page created

Function Reference/post comments feed link

Contents

Page 318: wp-api

1 Description2 Usage3 Parameters4 Related

Description

Prints out the comment feed link for a post. Link text is placed in the anchor. If no link text is specified, default text is used. If no post ID isspecified, the current post is used.

Usage

<?php post_comments_feed_link( $link_text = 'link_text', $post_id = 'post_id', $feed = 'feed_type' ) ?>

Parameters

$link_text(string) (optional) Descriptive text.

Default: none

$post_id(string) (optional) Post ID.

Default: Current post

$feed(string) (optional) Type of feed. Possible values: atom, rdf, rss, rss2.

Default: rss2

Related

get_post_comments_feed_link

How to pass parameters to tags

Go to Template Tag index

Retrieved from "http://codex.wordpress.org/Function_Reference/post_comments_feed_link"Category: Template Tags

Function Reference/preview theme

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Start preview theme output buffer.

Will only preform task if the user has permissions and 'template' and 'preview' query variables exist. Will add 'stylesheet' filter if 'stylesheet'query variable exists.

Usage

<?php preview_theme() ?>

Parameters

None.

Return Values

Page 319: wp-api

(void) This function does not return a value.

ExamplesNotesChange Log

Since: 2.5.0

Source File

preview_theme() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/preview_theme"Categories: Functions | New page created

Function Reference/preview theme ob filter

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Callback function for ob_start() to capture all links in the theme.

Usage

<?php preview_theme_ob_filter( $content ) ?>

Parameters

$content(string) (required)

Default: None

Return Values

(string)

ExamplesNotes

This is a private function. It should not be called directly. It is listed in the Codex for completeness.

Change Log

Since: unknown

Source File

preview_theme_ob_filter() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/preview_theme_ob_filter"Categories: Functions | New page created

Function Reference/preview theme ob filter callback

Contents

Page 320: wp-api

1 Description2 Usage3 Parameters4 Return Values5 Notes6 Change Log7 Source File8 Related

Description

Manipulates preview theme links in order to control and maintain location.

Callback function for preg_replace_callback() to accept and filter matches.

Usage

<?php preview_theme_ob_filter_callback( $matches ) ?>

Parameters

$matches(array) (required)

Default: None

Return Values

(string)

Notes

This is a private function. It should not be called directly. It is listed in the Codex for completeness.

Change Log

Since: unknown

Source File

preview_theme_ob_filter_callback() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/preview_theme_ob_filter_callback"Categories: Functions | New page created

Function Reference/previous comments link

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display the previous comments page link.

Usage

<?php previous_comments_link( $label ) ?>

Parameters

$label(string) (optional) Label for comments link text.

Default: ''

Page 321: wp-api

Return Values

(void) This function does not return a value.

ExamplesNotesChange Log

Since: 2.7.0

Source File

previous_comments_link() is located in wp-includes/link-template.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/previous_comments_link"Categories: Functions | New page created

Function Reference/privacy ping filter

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Check whether blog is public before returning sites.

Usage

<?php privacy_ping_filter( $sites ) ?>

Parameters

$sites(mixed) (required) Will return if blog is public, will not return if not public.

Default: None

Return Values

(mixed) Returns empty string ('') if blog is not public. Returns value in $sites if site is public.

ExamplesNotes

Uses: get_option() to check 'blog_public' option.

Change Log

Since: 2.1.0

Source File

privacy_ping_filter() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/privacy_ping_filter"Categories: Functions | New page created

Function Reference/register activation hook

Page 322: wp-api

The function register_activation_hook (introduced in WordPress 2.0) registers a plugin function to be run when the plugin is activated.

This is easier than using the activate_pluginname action.

Usage and parameters

<?php register_activation_hook($file, $function); ?>

$file(string) Path to the main plugin file inside the wp-content/plugins directory. A full path will work.

$function(callback) The function to be run when the plugin is activated. Any of PHP's callback pseudo-types will work.

Examples

If you have a function called myplugin_activate() in the main plugin file at either

wp-content/plugins/myplugin.php orwp-content/plugins/myplugin/myplugin.php

use this code:

register_activation_hook( __FILE__, 'myplugin_activate' );

This will call the myplugin_activate() function on activation of the plugin. This is a more reliable method than using the activate_pluginnameaction.

A Note on Variable Scope

If you're using global variables, you may find that the function you pass to register_activation_hook() does not have access to global variablesat the point when it is called, even though you state their global scope within the function like this:

$myvar='whatever';

function myplugin_activate() { global $myvar; echo $myvar; // this will NOT be 'whatever'}

register_activation_hook( __FILE__, 'myplugin_activate' );

This is because on that very first include, your plugin is NOT included within the global scope. It's included in the activate_plugin function, andso its "main body" 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 anywhereand 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 myplugin_activate() is called from within that function(specifically, within the activate_plugin() function) at the point where your plugin is activated. The main body variables are therefore in thescope of the activate_plugin() function and are not global, unless you explicitly declare their global scope:

global $myvar;$myvar='whatever';

function myplugin_activate() { global $myvar; echo $myvar; // this will be 'whatever'}

register_activation_hook( __FILE__, 'myplugin_activate' );

More information on this is available here: http://wordpress.org/support/topic/201309

See also register_deactivation_hook

Retrieved from "http://codex.wordpress.org/Function_Reference/register_activation_hook"Categories: Functions | New page created

Function Reference/register deactivation hook

The function register_deactivation_hook (introduced in WordPress 2.0) registers a plugin function to be run when the plugin is deactivated.

Page 323: wp-api

Usage and parameters

<?php register_deactivation_hook($file, $function); ?>

$file(string) Path to the main plugin file inside the wp-content/plugins directory. A full path will work.

$function(callback) The function to be run when the plugin is deactivated. Any of PHP's callback pseudo-types will work.

Examples

If you have a function called myplugin_deactivate() in the main plugin file at either

wp-content/plugins/myplugin.php orwp-content/plugins/myplugin/myplugin.php

use this code:

register_deactivation_hook( __FILE__, 'myplugin_deactivate' );

This will call the myplugin_deactivate() function on deactivation of the plugin.

Retrieved from "http://codex.wordpress.org/Function_Reference/register_deactivation_hook"Categories: Functions | New page created

Function Reference/register taxonomy

Contents1 WARNING2 Description3 Usage4 Example5 Parameters6 Arguments

WARNING

This is a new article, there may be problems. Please consult the function itself in /wp-includes/taxonomy.php if you are having problems.

Description

The register_taxonomy() function adds or overwrites a taxonomy. It takes in a name, an object name that it affects, and an array of parameters.It does not return anything.

Usage

<?php register_taxonomy($taxonomy, $object_type); ?>

<?php register_taxonomy($taxonomy, $object_type, $args); ?>

Example

<?php register_taxonomy('foo', 'post', array('hierarchical' => true)); ?>

Parameters

taxonomy (string) The name of the taxonomy.

object_type (array|string) A name or array of names of the object type(s) for the taxonomy object.

args (optional) (array) An array of arguements

Arguments

hierarachical (boolean) Has some defined purpose at other parts of the API.

update_count_callback (string) A function name that will be called when the count is updated.

rewrite (array|false) False to prevent rewrite, or array('slug'=>$slug) to customize permastruct; default will use $taxonomy as slug.

Page 324: wp-api

query_var (string|false) False to prevent queries, or string to customize query var (?$query_var=$term); default will use $taxonomy as queryvar.

Retrieved from "http://codex.wordpress.org/Function_Reference/register_taxonomy"Categories: Functions | New page created

Function Reference/remove accents

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Converts all accent characters to ASCII characters.

If there are no accent characters, then the string given is just returned.

Usage

<?php remove_accents( $string ) ?>

Parameters

$string(string) (required) Text that might have accent characters

Default: None

Return Values

(string) Filtered string with replaced "nice" characters.

ExamplesNotesChange Log

Since: 1.2.1

Source File

remove_accents() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/remove_accents"Categories: Functions | New page created

Function Reference/remove action

Contents1 Description2 Example3 Parameters4 Return

Description

This function removes a function attached to a specified action hook. This method can be used to remove default functions attached to aspecific action hook and possibly replace them with a substitute. See also remove_filter(), add_action() and add_filter().

Important: To remove a hook, the $function_to_remove and $priority arguments must match when the hook was added. This goes for bothfilters and actions. No warning will be given on removal failure.

Page 325: wp-api

Example

This function is identical to the remove_filter() function.

<?php remove_action($tag, $function_to_remove, $priority, $accepted_args); ?>

Parameters

$tag(string) (required) The action hook to which the function to be removed is hooked.

Default: None

$function_to_remove(string) (required) The name of the function which should be removed.

Default: None

$priority(int) (optional) The priority of the function (as defined when the function was originally hooked).

Default: 10

$accepted_args(int) (optional) The number of arguments the function accepts.

Default: 1

Return

(boolean) Whether the function is removed.

True The function was successfully removed.

False The function could not be removed.

Retrieved from "http://codex.wordpress.org/Function_Reference/remove_action"Categories: Functions | New page created

Function Reference/remove filter

Contents1 Description2 Example3 Parameters4 Return

Description

This function removes a function attached to a specified filter hook. This method can be used to remove default functions attached to a specificfilter hook and possibly replace them with a substitute. See also remove_action(), add_filter() and add_action().

Important: To remove a hook, the $function_to_remove and $priority arguments must match when the hook was added. This goes for bothfilters and actions. No warning will be given on removal failure.

Example

This function is identical to the remove_action() function.

<?php remove_filter($tag, $function_to_remove, $priority, $accepted_args); ?>

Parameters

$tag(string) (required) The action hook to which the function to be removed is hooked.

Default: None

$function_to_remove(string) (required) The name of the function which should be removed.

Default: None

$priority(int) (optional) The priority of the function (as defined when the function was originally hooked).

Default: 10

Page 326: wp-api

$accepted_args(int) (optional) The number of arguments the function accepts.

Default: 1

Return

(boolean) Whether the function is removed.

True The function was successfully removed.

False The function could not be removed.

Retrieved from "http://codex.wordpress.org/Function_Reference/remove_filter"Category: Functions

Function Reference/remove query arg

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Removes an item or list from the query string.

Usage

<?php remove_query_arg( $key, $query ) ?>

Parameters

$key(string|array) (required) Query key or keys to remove.

Default: None

$query(boolean) (optional) When false uses the $_SERVER value.

Default: false

Return Values

(string) New URL query string.

ExamplesNotesChange Log

Since: 1.5.0

Source File

remove_query_arg() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/remove_query_arg"Categories: Functions | New page created

Function Reference/rss enclosure

Contents

Page 327: wp-api

1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display the rss enclosure for the current post.

Uses the global $post to check whether the post requires a password and if the user has the password for the post. If not then it will returnbefore displaying.

Also uses the function get_post_custom() to get the post's 'enclosure' metadata field and parses the value to display the enclosure(s). Theenclosure(s) consist of enclosure HTML tag(s) with a URI and other attributes.

Usage

<?php rss_enclosure() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: apply_filters() Calls 'rss_enclosure' hook on rss enclosure.Uses: get_post_custom() To get the current post enclosure metadata.

Change Log

Since: 1.5.0

Source File

rss_enclosure() is located in wp-includes/feed.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/rss_enclosure"Categories: Functions | New page created

Function Reference/sanitize comment cookies

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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

Page 328: wp-api

<?php sanitize_comment_cookies() ?>

Parameters

None

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: apply_filters() with 'pre_comment_author_name' on 'comment_author' cookieUses: apply_filters() with 'pre_comment_author_email' on 'comment_author_email' cookieUses: apply_filters() with 'pre_comment_author_url' on 'comment_author_url' cookie

Change Log

Since: 2.0.4

Source File

sanitize_comment_cookies() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/sanitize_comment_cookies"Categories: Functions | New page created

Function Reference/sanitize email

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Strips out all characters that are not allowable in an email.

Usage

<?php sanitize_email( $email ) ?>

Parameters

$email(string) (required) Email address to filter.

Default: None

Return Values

(string) Filtered email address.

ExamplesNotes

This function uses a smaller allowable character set than the set defined by RFC 5322. Some legal email addresses may be changed.Allowed character regular expression: /[^a-z0-9+_.@-]/i.

Change Log

Since: 1.5.0

Page 329: wp-api

Source File

sanitize_email() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/sanitize_email"Categories: Functions | New page created

Function Reference/sanitize file name

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Filters certain characters from the file name.

Turns all strings to lowercase removing most characters except alphanumeric with spaces, dashes and periods. All spaces and underscoresare converted to dashes. Multiple dashes are converted to a single dash. Finally, if the file name ends with a dash, it is removed.

Usage

<?php sanitize_file_name( $name ) ?>

Parameters

$name(string) (required) The file name

Default: None

Return Values

(string) Sanitized file name

ExamplesNotesChange Log

Since: 2.1.0

Source File

sanitize_file_name() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/sanitize_file_name"Categories: Functions | New page created

Function Reference/sanitize title

Please contribute to this page.

To create URLs the same way that WordPress creates URLs, simply use:

$new_url = sanitize_title('This Long Title is what My Post or Page might be'); print $new_url;

and that will return a formatted value, the output would be this:

this-long-title-is-what-my-post-or-page-might-be

Retrieved from "http://codex.wordpress.org/Function_Reference/sanitize_title"

Page 330: wp-api

Function Reference/sanitize title with dashes

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Sanitizes title, replacing whitespace with dashes.

Limits the output to alphanumeric characters, underscore (_) and dash (-). Whitespace becomes a dash.

Usage

<?php sanitize_title_with_dashes( $title ) ?>

Parameters

$title(string) (required) The title to be sanitized.

Default: None

Return Values

(string) The sanitized title.

ExamplesNotesChange Log

Since: 1.2.0

Source File

sanitize_title_with_dashes() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/sanitize_title_with_dashes"Categories: Functions | New page created

Function Reference/sanitize user

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Sanitize username stripping out unsafe characters.

If $strict is true, only alphanumeric characters plus these: _, space, ., -, *, and @ are returned.

Removes tags, octets, entities, and if strict is enabled, will remove all non-ASCII characters. After sanitizing, it passes the username, rawusername (the username in the parameter), and the strict parameter as parameters for the filter.

Page 331: wp-api

Usage

<?php sanitize_user( $username, $strict ) ?>

Parameters

$username(string) (required) The username to be sanitized.

Default: None

$strict(boolean) (optional) If set limits $username to specific characters.

Default: false

Return Values

(string) The sanitized username, after passing through filters.

ExamplesNotes

Uses: apply_filters() Calls 'sanitize_user' hook on username, raw username, and $strict parameter.

Change Log

Since: 2.0.0

Source File

sanitize_user() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/sanitize_user"Categories: Functions | New page created

Function Reference/seems utf8

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Checks to see if a string is utf8 encoded.

Usage

<?php seems_utf8( $Str ) ?>

Parameters

$Str(string) (required) The string to be checked

Default: None

Return Values

(boolean) True if $Str fits a UTF-8 model, false otherwise.

ExamplesNotes

Page 332: wp-api

Change Log

Since: 1.2.1

Source File

seems_utf8() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/seems_utf8"Categories: Functions | New page created

Function Reference/set current user

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Changes the current user by ID or name.

Set $id to null and specify a name if you do not know a user's ID.

Usage

<?php set_current_user( $id, $name ) ?>

Parameters

$id(integer|null) (required) User ID.

Default: None

$name(string) (optional) The user's username

Default: ''

Return Values

(object) returns values returned by wp_set_current_user()

ExamplesNotes

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.Uses: wp_set_current_user()

Change Log

Since: 2.0.1

Source File

set_current_user() is located in wp-includes/pluggable.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/set_current_user"Categories: Functions | New page created

Function Reference/set theme mod

Page 333: wp-api

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Update theme modification value for the current theme.

Usage

<?php set_theme_mod( $name, $value ) ?>

Parameters

$name(string) (required) Theme modification name.

Default: None

$value(string) (required) Theme modification value.

Default: None

Return Values

(void) This function does not return a value.

ExamplesNotesChange Log

Since: 2.1.0

Source File

set_theme_mod() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/set_theme_mod"Categories: Functions | New page created

Function Reference/spawn cron

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Send request to run cron through HTTP request that doesn't halt page loading.

Usage

<?php spawn_cron( $local_time ) ?>

Page 334: wp-api

ParametersReturn Values

(null) Cron could not be spawned, because it is not needed to run.

ExamplesNotes

Cron is named after a unix program which runs unattended scheduled tasks.

Change Log

Since: 2.1.0

Source File

spawn_cron() is located in wp-includes/cron.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/spawn_cron"Categories: Functions | New page created

Function Reference/status header

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Set HTTP status header.

Usage

<?php status_header( $header ) ?>

Parameters

$header(integer) (required) HTTP status code

Default: None

Return Values

(null) Does not return anything.

ExamplesNotes

Uses: apply_filters() Calls 'status_header' on status header string, HTTP HTTP code, HTTP code description, and protocol string asseparate parameters.

Change Log

Since: 2.0.0

Source File

status_header() is located in wp-includes/functions.php.

Related

Page 335: wp-api

Retrieved from "http://codex.wordpress.org/Function_Reference/status_header"Categories: Functions | New page created

Function Reference/stripslashes deep

The function stripslashes_deep() removes slashes that result from PHP magic quotes being enabled. This function is taken verbatim, directlyfrom the PHP manual, and is documented at http://www.php.net/manual/en/security.magicquotes.disabling.php

You may want this function when developing your own PHP application intended to run within the WordPress environment. Specifically, yourprogram needs to strip slashes when data arrives via $_POST, $_GET, $_COOKIE, and $_REQUEST arrays.

An example would be a "Contact Me" page and the ancillary program that sanitizes the user-supplied text. Such user inputs typically travelfrom an HTML <form method="post" ... > to your program by way of the $_POST array. stripslashes_deep(), in that case, could be used thus:

$_POST = array_map( 'stripslashes_deep', $_POST );

This example of stripslashes_deep() is recursive and will walk through the $_POST array even when some of the elements are themselves anarray.

When you write program code for public distribution, you do not know ahead of time if the target server has magic quotes enabled. It is,therefore, best coding practice for your program to check for magic quotes and strip slashes if need be. It is worth knowing thatstripalshes_deep() does not check for the presence of slashes. Your program would, most properly, test for and remove magic quote slashes.

One possible way to use stripslashes_deep() is this:

if( get_magic_quotes_gpc() ) {$_POST = array_map( 'stripslashes_deep', $_POST );$_GET = array_map( 'stripslashes_deep', $_GET );$_COOKIE = array_map( 'stripslashes_deep', $_COOKIE );$_REQUEST = array_map( 'stripslashes_deep', $_REQUEST );}

The existence of magic quotes has been a headache for many PHP composers. Future versions of PHP may very likely deprecate them. Codewill, however, need to continue to work around them as long as PHP4 and PHP5 remain in use.

Retrieved from "http://codex.wordpress.org/Function_Reference/stripslashes_deep"

Function Reference/switch theme

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Switches current theme to new template and stylesheet names.

Usage

<?php switch_theme( $template, $stylesheet ) ?>

Parameters

$template(string) (required) Template name.

Default: None

$stylesheet(string) (required) Stylesheet name.

Default: None

Return Values

(void)

Page 336: wp-api

This function does not return a value.

ExamplesNotes

Uses: do_action() Calls 'switch_theme' action on updated theme display name.

Change Log

Since: unknown

Source File

switch_theme() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/switch_theme"Categories: Functions | New page created

Function Reference/the category rss

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display the post categories in the feed.

Usage

<?php the_category_rss( $type ) ?>

Parameters

$type(string) (optional) default is 'rss'. Either 'rss', 'atom', or 'rdf'.

Default: 'rss'

Return Values

(void) This function does not return a value.

ExamplesNotes

See get_the_category_rss() for better explanation.Echos the return from get_the_category_rss().

Change Log

Since: 0.71

Source File

the_category_rss() is located in wp-includes/feed.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/the_category_rss"Categories: Functions | New page created

Function Reference/the content rss

Page 337: wp-api

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display the post content for the feed.

For encoding the html or the $encode_html parameter, there are three possible values. '0' will make urls footnotes and usemake_url_footnote(). '1' will encode special characters and automatically display all of the content. The value of '2' will strip all HTML tags fromthe 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 2,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 anydots 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

<?php the_content_rss( $more_link_text, $stripteaser, $more_file, $cut, $encode_html ) ?>

Parameters

$more_link_text(string) (optional) Text to display when more content is available but not displayed.

Default: 'more...'

$stripteaser(integer|boolean) (optional) Default is 0.

Default: 0

$more_file(string) (optional) Optional.

Default: ''

$cut(integer) (optional) Amount of words to keep for the content.

Default: 0

$encode_html(integer) (optional) How to encode the content.

Default: 0

Return Values

(void) This function does not return a value.

ExamplesNotes

See get_the_content() For the $more_link_text, $stripteaser, and $more_file parameters.Uses: apply_filters() Calls 'the_content_rss' on the content before processing.

Change Log

Since: 0.71

Source File

the_content_rss() is located in wp-includes/feed.php.

Page 338: wp-api

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/the_content_rss"Categories: Functions | New page created

Function Reference/the excerpt rss

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display the post excerpt for the feed.

Usage

<?php the_excerpt_rss() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: apply_filters() Calls 'the_excerpt_rss' hook on the excerpt.

Change Log

Since: 0.71

Source File

the_excerpt_rss() is located in wp-includes/feed.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/the_excerpt_rss"Categories: Functions | New page created

Function Reference/the title rss

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Display the post title in the feed.

Usage

<?php the_title_rss() ?>

Page 339: wp-api

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: get_the_title_rss() Used to retrieve current post title.

Change Log

Since: 0.71

Source File

the_title_rss() is located in wp-includes/feed.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/the_title_rss"Categories: Functions | New page created

Function Reference/trackback

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Send a trackback.

Updates database when sending trackback to prevent duplicates.

Usage

<?php trackback( $trackback_url, $title, $excerpt, $ID ) ?>

Parameters

$trackback_url(string) (required) URL to send trackbacks.

Default: None

$title(string) (required) Title of post.

Default: None

$excerpt(string) (required) Excerpt of post.

Default: None

$ID(integer) (required) Post ID.

Default: None

Return Values

(mixed) Database query from update.

Page 340: wp-api

ExamplesNotes

Uses global: (object) $wpdb to update the _posts table from the database.Uses: get_permalink() on $ID.Uses: get_option() to retrieve the 'blogname' option.Uses: wp_remote_post() on $trackback_url.Uses: is_wp_error()

Change Log

Since: 0.71

Source File

trackback() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/trackback"Categories: Functions | New page created

Function Reference/trackback url list

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Do trackbacks for a list of URLs.

Usage

<?php trackback_url_list( $tb_list, $post_id ) ?>

Parameters

$tb_list(string) (required) Comma separated list of URLs

Default: None

$post_id(integer) (required) Post ID

Default: None

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses: wp_get_single_post() on $post_id.Uses: trackback() on each trackback url.

Change Log

Since: 1.0.0

Source File

trackback_url_list() is located in wp-includes/post.php.

Page 341: wp-api

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/trackback_url_list"Categories: Functions | New page created

Function Reference/trailingslashit

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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

<?php trailingslashit( $string ) ?>

Parameters

$string(string) (required) What to add the trailing slash to.

Default: None

Return Values

(string) String with trailing slash added.

ExamplesNotes

Uses: untrailingslashit() Unslashes string if it was slashed already.This: '/' is a slash.

Change Log

Since: 1.2.0

Source File

trailingslashit() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/trailingslashit"Categories: Functions | New page created

Function Reference/untrailingslashit

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Page 342: wp-api

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

<?php untrailingslashit( $string ) ?>

Parameters

$string(string) (required) What to remove the trailing slash from.

Default: None

Return Values

(string) String without the trailing slash.

ExamplesNotes

This: '/' is a slash.

Change Log

Since: 2.2.0

Source File

untrailingslashit() is located in wp-includes/formatting.php.

Related

trailingslashit()

Retrieved from "http://codex.wordpress.org/Function_Reference/untrailingslashit"Categories: Functions | New page created

Function Reference/update attached file

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Update attachment file path based on attachment ID.

Used to update the file path of the attachment, which uses post meta name '_wp_attached_file' to store the path of the attachment.

Usage

<?php update_attached_file( $attachment_id, $file ) ?>

Parameters

$attachment_id(integer) (required) Attachment ID

Default: None

$file(string) (required) File path for the attachment

Page 343: wp-api

Default: None

Return Values

(boolean) False on failure, true on success.

ExamplesNotes

Uses: apply_filters() to add update_attached_file() on $file and $attachment_id.

Change Log

Since: 2.1.0

Source File

update_attached_file() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/update_attached_file"Categories: Functions | New page created

Function Reference/update option

Contents1 Description2 Usage3 Example4 Parameters

Description

Use the function update_option to update a named option/value pair to the options database table. The option_name value is escaped with$wpdb->escape before the INSERT statement.

Proper use of this function suggests using get_option to retrieve the option and if tested for true, then use update_option. If get_option returnsfalse, then add_option should be used instead.

Note that update_option cannot be used to change whether an option is to be loaded (or not loaded) by wp_load_alloptions. In that case, adelete_option should be followed by use of the update_option function.

Usage

<?php update_option('option_name', 'newvalue'); ?>

Example

Update the option name myhack_extraction_length with the value 255. If the option does not exist then use add_option and set autoload to no.

<?php$option_name = 'myhack_extraction_length' ; $newvalue = '255' ; if ( get_option($option_name) ) { update_option($option_name, $newvalue); } else { $deprecated=' '; $autoload='no'; add_option($option_name, $newvalue, $deprecated, $autoload); }?>

Parameters

option_name(string) (required) Name of the option to update. A list of valid default options to update can be found at the Option Reference.

Default: None

newvalue

Page 344: wp-api

(string) (required) The NEW value for this option name. This value can be a string, an array, an object or a serialized value.Default: None

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/update_option"Categories: Functions | Copyedit

Function Reference/update post meta

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Other Examples

4 Parameters5 Related

Description

The function, update post meta(), updates the value of an existing meta key (custom field) for the specified post.

The function returns true upon successful updating, and returns false if the post does not have the meta key specified.

If you want to add a new meta key and value, use the add_post_meta() function instead.

Usage

<?php update_post_meta($post_id, $meta_key, $meta_value, $prev_value); ?>

ExamplesDefault Usage

<?php update_post_meta(76, 'my_key', 'Steve'); ?>

Other Examples

Assuming a post has an ID of 76, and the following 4 custom fields:

[key_1] => 'Happy'[key_1] => 'Sad'[key_2] => 'Gregory'[my_key] => 'Steve'

To change key_2's value to Hans:

<?php update_post_meta(76, 'key_2', 'Hans'); ?>

To change key_1's value from Sad to Happy:

<?php update_post_meta(76, 'key_1', 'Happy', 'Sad'); ?>

The fields would now look like this:

[key_1] => 'Happy'[key_1] => 'Happy'[key_2] => 'Hans'[my_key] => 'Steve'

Page 345: wp-api

Note: This function will update only the first field that matches the criteria.

To change the first key_1's value from Happy to Excited:

<?php update_post_meta(76, 'key_1', 'Excited', 'Happy');

//Or

update_post_meta(76, 'key_1', 'Excited');

//To change all fields with the key "key_1":

$key1_values = get_post_custom_values('key_1', 76); foreach ( $key1_values as $value ) update_post_meta(76, 'key_1', 'Excited', $value);?>

For a more detailed example, go to the post_meta Functions Examples page.

Parameters

$post_id(integer) (required) The ID of the post which contains the field you will edit.

Default: None

$meta_key(string) (required) The key of the custom field you will edit.

Default: None

$meta_value(string) (required) The new value of the custom field.

Default: None

$prev_value(string) (optional) The old value of the custom field you wish to change. This is to differentiate between several fields with the same key.

Default: None

Related

delete_post_meta(), get_post_meta(), add_post_meta(), get_post_custom(), get_post_custom_values(), get_post_custom_keys()

Retrieved from "http://codex.wordpress.org/Function_Reference/update_post_meta"Categories: Functions | New page created | Needs Review

Function Reference/update user option

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Update user option with global blog capability.

User options are just like user metadata except that they have support for global blog options. If the 'global' parameter is false, which it is byfalse it will prepend the WordPress table prefix to the option name.

Usage

<?php update_user_option( $user_id, $option_name, $newvalue, $global ) ?>

Parameters

Page 346: wp-api

$user_id(integer) (required) User ID

Default: None

$option_name(string) (required) User option name.

Default: None

$newvalue(mixed) (required) User option value.

Default: None

$global(boolean) (optional) Whether option name is blog specific or not.

Default: false

Return Values

(unknown)

ExamplesNotes

Uses global: (object) $wpdb WordPress database object for queries.

Change Log

Since: 2.0.0

Source File

update_user_option() is located in wp-includes/user.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/update_user_option"Categories: Functions | New page created

Function Reference/update usermeta

Contents1 Description2 Gotchas3 Usage4 Parameters

Description

This function updates the value of a specific metakey pertaining to the user whose ID is passed via the userid parameter. It returns true if theupdate was successful and false if it was unsuccessful.

Gotchas

If the meta_key contains a hyphen, it is automatically stripped and inserted without, e.g. "opt-in" becomes "optin". Underscores, however, willwork as expected.

Usage

<?php update_usermeta(userid,'metakey','metavalue'); ?>

Parameters

$userid(integer) (required) The ID of the user whose data should be updated.

Default: None

$metakey(string) (required) The metakey to be updated.

'metakey' The meta_key in the wp_usermeta table for the meta_value to be updated.Default: None

Page 347: wp-api

$metavalue(string) (required) The new desired value of the metakey.

Default: None

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/update_usermeta"Categories: Functions | Copyedit

Function Reference/user pass ok

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Check that the user login name and password is correct.

Usage

<?php user_pass_ok( $user_login, $user_pass ) ?>

Parameters

$user_login(string) (required) User name.

Default: None

$user_pass(string) (required) User password.

Default: None

Return Values

(boolean) False if does not authenticate, true if username and password authenticates.

ExamplesNotesChange Log

Since: 0.71

Source File

user_pass_ok() is located in wp-includes/user.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/user_pass_ok"Categories: Functions | New page created

Function Reference/username exists

Contents1 Description2 Usage3 Examples4 Paramaters5 Returns6 Further Reading

Page 348: wp-api

Description

Returns the user ID if the user exists or null if the user doesn't exist.

Usage

<?phprequire ( ABSPATH . WPINC . '/registration.php' );if (username_exists($username)){ } ?>

Examples

Use username_exists() in your scripts to decide whether the given username exists.

<?php $username = $_POST['username']; if (username_exists($username)) echo "Username In Use!"; else echo "Username Not In Use!";?>

Paramaters

$username — a string representing the username to check for existence

Returns

This function returns the user ID if the user exists or null if the user does not exist

Further Reading

For a comprehensive list of functions, take a look at the category Functions

Also, see Function_Reference

Retrieved from "http://codex.wordpress.org/Function_Reference/username_exists"Categories: Functions | New page created

Function Reference/utf8 uri encode

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Encode the Unicode values to be used in the URI.

Usage

<?php utf8_uri_encode( $utf8_string, $length ) ?>

Parameters

$utf8_string(string) (required)

Default: None

$length(integer) (optional) Max length of the string

Default: 0

Page 349: wp-api

Return Values

(string) String with Unicode encoded for URI.

ExamplesNotesChange Log

Since: 1.5.0

Source File

utf8_uri_encode() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/utf8_uri_encode"Categories: Functions | New page created

Function Reference/validate current theme

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Checks that current theme files 'index.php' and 'style.css' exists.

Does not check the 'default' theme. The 'default' theme should always exist or should have another theme renamed to that template name anddirectory path. Will switch theme to default if current theme does not validate. You can use the 'validate_current_theme' filter to return false todisable this functionality.

Usage

<?php validate_current_theme() ?>

Parameters

None.

Return Values

(boolean)

ExamplesNotesChange Log

Since: 1.5.0

Source File

validate_current_theme() is located in wp-includes/theme.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/validate_current_theme"Categories: Functions | New page created

Function Reference/validate username

Page 350: wp-api

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Checks whether username is valid.

Usage

<?php validate_username( $username ) ?>

Parameters

$username(string) (required) Username.

Default: None

Return Values

(boolean) Returns true if $username is valid, false if $username is invalid.

ExamplesNotes

Uses: apply_filters() Calls validate_username hook on $valid check and $username as parameters.Uses: sanitize_user()

Change Log

Since: 2.0.1

Source File

validate_username() is located in wp-includes/registration.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/validate_username"Categories: Functions | New page created

Function Reference/weblog ping

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Send a pingback.

Usage

<?php weblog_ping( $server, $path ) ?>

Parameters

Page 351: wp-api

$server(string) (optional) Host of blog to connect to.

Default: ''

$path(string) (optional) Path to send the ping.

Default: ''

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses global: (string) $wp_version holds the installed WordPress version number.Uses: IXR_Client WordPress class.Uses: get_option() to retrieve the 'home' option.Uses: get_option() to retrieve the 'blogname' option.Uses: get_bloginfo() to retrieve the 'rss2_url'.

Change Log

Since: 1.2.0

Source File

weblog_ping() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/weblog_ping"Categories: Functions | New page created

Function Reference/wp

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Setup the WordPress query.

Usage

<?php wp( $query_vars ) ?>

Parameters

$query_vars(string) (optional) Default WP_Query arguments.

Default: ''

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses global: (object) $wp

Page 352: wp-api

Uses global: (object) $wp_queryUses global: (object) $wp_the_query

Change Log

Since: 2.0.0

Source File

wp() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp"Categories: Functions | New page created

Function Reference/wp allow comment

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Validates whether this comment is allowed to be made or not.

Usage

<?php wp_allow_comment( $commentdata ) ?>

Parameters

$commentdata(array) (required) Contains information on the comment

Default: None

Return Values

(mixed) Signifies the approval status (0|1|'spam')

ExamplesNotes

Uses: $wpdbUses: apply_filters() Calls 'pre_comment_approved' hook on the type of commentUses: do_action() Calls 'check_comment_flood' hook on $comment_author_IP, $comment_author_email, and $comment_date_gmtUses: The WP_User object.Uses: get_userdata()Uses: check_comment()Uses: wp_blacklist_check() to find spam.

Change Log

Since: 2.0.0

Source File

wp_allow_comment() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_allow_comment"Categories: Functions | New page created

Function Reference/wp attachment is image

Page 353: wp-api

Contents1 Description2 Usage3 Example4 Parameters

Description

This function determines if a post is an image

Usage

<?php wp_attachment_is_image( $post_id ); ?>

Example

To check if post ID 37 is an image:

<?php $id = 37 if ( wp_attachment_is_image( $id ) ) echo "Post ".$id." is an image!"; else echo "Post ".$id." is not an image.";?>

Parameters

$post_id(int) (optional) Integer ID of the post.

Default: 0

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_attachment_is_image"Categories: Functions | New page created

Function Reference/wp check filetype

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the file type from the file name.

You can optionally define the mime array, if needed.

Usage

<?php wp_check_filetype( $filename, $mimes ) ?>

Parameters

$filename(string) (required) File name or path.

Default: None

$mimes(array) (optional) Key is the file extension with value as the mime type.

Default: null

Return Values

Page 354: wp-api

(array) Values with extension first and mime type.

ExamplesNotesChange Log

Since: 2.0.4

Source File

wp_check_filetype() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_check_filetype"Categories: Functions | New page created

Function Reference/wp check for changed slugs

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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 theslug 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 ('_wp_old_slug') for storing old slugs forthat post.

The most logically usage of this function is redirecting changed posts, so that those that linked to an changed post will be redirected to the newpost.

Usage

<?php wp_check_for_changed_slugs( $post_id ) ?>

Parameters

$post_id(integer) (required) Post ID.

Default: None

Return Values

(integer) Same as $post_id

ExamplesNotes

Uses: May use add_post_meta() or delete_post_meta() depending on current post data (get_post_meta()).

Change Log

Since: 2.1.0

Source File

wp_check_for_changed_slugs() is located in wp-includes/post.php.

Page 355: wp-api

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_check_for_changed_slugs"Categories: Functions | New page created

Function Reference/wp clear scheduled hookDescription

Un-schedules all previously-scheduled cron jobs using a particular hook name.

Usage

<?php wp_clear_scheduled_hook('my_schedule_hook'); ?>

See:

wp_schedule_eventwp_schedule_single_eventwp_unschedule_event

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_clear_scheduled_hook"Categories: Stubs | Functions | New page created | WP-Cron Functions

Function Reference/wp clearcookie

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Clears the authentication cookie, logging the user out.

This function is deprecated. Use wp_set_auth_cookie() instead.

Usage

<?php wp_clearcookie() ?>

Parameters

None.

Return Values

(void) This function does not return a value.

ExamplesNotes

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.This function is deprecated. Use wp_set_auth_cookie() instead.

Change Log

Since: 1.5Deprecated: 2.5.0

Page 356: wp-api

Source File

wp_clearcookie() is located in wp-includes/pluggable.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_clearcookie"Categories: Functions | New page created

Function Reference/wp count posts

Contents1 Description2 Usage3 Examples

3.1 Default Usage3.2 Get the Publish Status Post Count3.3 Count Drafts3.4 Count Pages3.5 Other Uses

4 Parameters

Description

This function was introduced in WordPress Version 2.5, and outputs the number for each post status of a post type. You can also usewp_count_posts() as a template_tag with the second parameter and include the private post status. By default, or if the user isn't logged inor 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 isset() PHP function, if youare wanting the value for the private post status. Not all post statuses will be part of the object.

Usage

<?php wp_count_posts('type'); ?>

<?php wp_count_posts('type', 'readable'); ?>

ExamplesDefault 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.

<?php$count_posts = wp_count_posts();?>

Get the Publish Status Post Count

To get the published status type, you would call the wp_count_posts() function and then access the 'publish' property.

<?php$count_posts = wp_count_posts();

$published_posts = $count_posts->publish;?>

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 wantto maintain backwards compatibility, then you must use the above code.

<?php$published_posts = wp_count_posts()->publish;?>

Count Drafts

Counting drafts is handled the same way as the publish status.

<?php$count_posts = wp_count_posts();

$draft_posts = $count_posts->draft;

Page 357: wp-api

?>

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 poststatus is done the same way as for posts.

<?php$count_pages = wp_count_posts('page');?>

Other Uses

The wp_count_posts() can be used to find the number for post statuses of any post type. This includes attachments or any post type addedin the future, either by a plugin or part of the WordPress Core.

Parameters

type (string) Type of row in wp_posts to count where type is equal to post_type. Defaults to post

perm(string) To include private post status, use 'readable' and requires that the user be logged in. Default to empty string

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_count_posts"Category: Functions

Function Reference/wp create nonce

Contents1 Description2 Parameters3 Returns4 Example5 See also

Description

Creates a random, one time use token.

Parameters

$action(string) (int) Scalar value to add context to the nonce.

Default: -1

Returns

@return string The one use form token.

Example

<?php $nonce= wp_create_nonce ('my-nonce'); ?><a href='myplugin.php?_wpnonce=<?php echo $nonce ?>'> ...

<?php $nonce=$_REQUEST['_wpnonce'];if (! wp_verify_nonce($nonce, 'my-nonce') ) die('Security check'); ?>

See also

Wordpress Nonce Implementationwp_verify_noncecheck_admin_referer

Page 358: wp-api

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_create_nonce"Categories: Stubs | Functions

Function Reference/wp create user

Contents1 Description2 Usage3 Example4 Parameters5 Returns

Description

The wp_create_user function allows you to insert a new user into the WordPress database by parsing 3 (three) parameters through to thefunction itself. It uses the $wpdb class to escape the variable values, preparing it for insertion into the database. Then the PHP compact()function is used to create an array with these values.

Usage

<?php wp_create_user($username, $password, $email ); ?>

Example

As used in wp-admin/upgrade-functions.php:

$user_id = username_exists($user_name);if ( !$user_id ) {

$random_password = substr(md5(uniqid(microtime())), 0, 6);$user_id = wp_create_user($user_name, $random_password, $user_email);

} else {$random_password = __('User already exists. Password inherited.');

}

Parameters

$username(string) (required) The username of the user to be created.

Default: None

$password(string) (required) The password of the user to be created.

Default: None

$email(string) (optional) The email address of the user to be created.

Default: None

Returns

This function returns the user ID of the created user.

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_create_user"Categories: Functions | Copyedit

Function Reference/wp cron

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log

Page 359: wp-api

8 Source File9 Related

Description

Run scheduled callbacks or spawn cron for all scheduled events.

Usage

<?php wp_cron() ?>

Parameters

None.

Return Values

(null) When doesn't need to run Cron.

ExamplesNotes

Cron is named after a unix program which runs unattended scheduled tasks.

Change Log

Since: 2.1.0

Source File

wp_cron() is located in wp-includes/cron.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_cron"Categories: Functions | New page created

Function Reference/wp delete attachment

Contents1 Description2 Usage3 Example4 Parameters5 Hooks6 Related

Description

This function deletes an attachment

Usage

<?php wp_delete_attachment( $postid ); ?>

Example

To delete an attachment with an ID of '76':

<?php delete_post_meta( 76 ); ?>

Parameters

$postid(integer) (required) The ID of the attachment you would like to delete.

Default: None

Hooks

This function fires the delete_attachment action hook, passing the attachment's ID ($postid).

Page 360: wp-api

Related

wp_get_attachment_url()

delete_attachment

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_delete_attachment"Categories: Functions | New page created | Stubs

Function Reference/wp delete comment

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Removes comment ID and maybe updates post comment count.

The post comment count will be updated if the comment was approved and has a post ID available.

Usage

<?php wp_delete_comment( $comment_id ) ?>

Parameters

$comment_id(integer) (required) Comment ID

Default: None

Return Values

(boolean) False if delete comment query failure, true on success.

ExamplesNotes

Uses: $wpdbUses: do_action() Calls 'delete_comment' hook on comment IDUses: do_action() Calls 'wp_set_comment_status' hook on comment ID with 'delete' set for the second parameterUses: wp_transition_comment_status() Passes new and old comment status along with $comment objectUses: get_comment()Uses: wp_update_comment_count() to decrease count on success.Uses: clean_comment_cache() to remove comment form cache on success.

Change Log

Since: 2.0.0

Source File

wp_delete_comment() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_delete_comment"Categories: Functions | New page created

Function Reference/wp delete post

Page 361: wp-api

Contents1 Description2 Usage3 Examples

3.1 Default Usage4 Parameters

Description

Deleting a post by post ID.

Usage

<?php wp_delete_post($post_id); ?>

Examples

Deleting WP default post "Hello World" which ID is '1'.

<?php wp_delete_post(1); ?>

Default Usage

Parameters

post_id

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_delete_post"Category: Functions

Function Reference/wp delete userDescription

The wp_delete_user function allows you to delete a user from the WordPress database by parsing 2 (two) parameters through to the functionitself.

Usage

<?php wp_delete_user($id, $reassign = 'novalue') ?>

Function_Reference

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_delete_user"

Function Reference/wp die

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Kill WordPress execution and display HTML message with error message.

A call to this function complements the die() PHP function. The difference is that HTML will be displayed to the user. It is recommended to usethis function only when the execution should not continue any further. It is not recommended to call this function very often and try to handle asmany errors as possible siliently.

Usage

<?php wp_die( $message, $title, $args ) ?>

Parameters

Page 362: wp-api

$message(string) (required) Error message.

Default: None

$title(string) (optional) Error title.

Default: ''

$args(string|array) (optional) Optional arguements to control behaviour.

Default: array

Return Values

(void) This function does not return a value.

ExamplesNotes

Uses global: (object) $wp_locale Handles the date and time locales.

Change Log

Since: 2.0.4

Source File

wp_die() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_die"Categories: Functions | New page created

Function Reference/wp enqueue script

Contents1 Description2 Usage3 Example

3.1 Usage4 Parameters5 Resources

Description

A safe way of adding javascripts to a WordPress generated page.

Usage

<?php wp_enqueue_script( 'handle', 'src', 'deps', 'ver'); ?>

ExampleUsage

Load the scriptaculous script:

<?php wp_enqueue_script('scriptaculous'); ?>

Add and load a new script that depends on scriptaculous (this will also cause it to load scriptaculous into the page as well):

<?php wp_enqueue_script('newscript','/wp-content/plugins/someplugin/js/newscript.js',array('scriptaculous'),'1.0' ); ?>

Note: This function will not work if it is called from a wp_head action, as the <script> tags are output before wp_head runs. Instead, callwp_enqueue_script from an init action function.

Parameters

Page 363: wp-api

handle (string) Name of the script. Lowercase string.

src(string) (Optional) Path to the script from the root directory of WordPress. Example: "/wp-includes/js/scriptaculous/scriptaculous.js". Thisparameter is only required when WordPress does not already know about this script. Defaults to false.

deps(array) (Optional) Array of handles of any script that this script depends on; scripts that must be loaded before this script. false if thereare no dependencies. This parameter is only required when WordPress does not already know about this script. Defaults to false.

ver (string) (Optional) String specifying the script version number, if it has one. Defaults to false. This parameter is used to ensure that thecorrect version is sent to the client regardless of caching, and so should be included if a version number is available and makes sensefor the script.

Default scripts included with WordPress:

Script Name HandleScriptaculous Root scriptaculous-rootScriptaculous Builder scriptaculous-builderScriptaculous Drag & Drop scriptaculous-dragdropScriptaculous Effects scriptaculous-effectsScriptaculous Slider scriptaculous-sliderScriptaculous Sound scriptaculous-soundScriptaculous Controls scriptaculous-controlsScriptaculous scriptaculousImage Cropper cropperSWFUpload swfuploadSWFUpload Degarade swfupload-degradeSWFUpload Queue swfupload-queueSWFUpload Handlers swfupload-handlersjQuery jqueryjQuery Form jquery-formjQuery Color jquery-colorjQuery UI Core jquery-ui-corejQuery UI Tabs jquery-ui-tabsjQuery UI Sortable jquery-ui-sortablejQuery Interface interfacejQuery Schedule schedulejQuery Suggest suggestThickBox thickboxSimple AJAX Code-Kit sackQuickTags quicktagsColorPicker colorpickerTiny MCE tiny_mcePrototype Framework prototypeAutosave autosaveWordPress AJAX Response wp-ajax-responseList Manipulation wp-listsWP Common commonWP Editor editorWP Editor Functions editor-functionsAJAX Cat ajaxcatAdmin Categories admin-categoriesAdmin Tags admin-tagsAdmin custom fields admin-custom-fieldsPAssword Strength Meter password-strength-meterAdmin Comments admin-commentsAdmin Users admin-usersAdmin Forms admin-formsXFN xfnUpload uploadPostBox postboxSlug slug

Page 364: wp-api

Post postPage pageLink linkComment commentAdmin Gallery admin-galleryMedia Upload media-uploadAdmin widgets admin-widgetsWord Count word-countWP Gears wp-gearsTheme Preview theme-preview

Resources

Best practice for adding JavaScript code to WordPress pluginsLoading Javascript Libraries in Wordpress Plugins with wp_enqueue_script()How To: Load Javascript With Your WordPress PluginHow to load JavaScript in WordPress pluginswp_enqueue_script question on wp-hackersUsing JavaScript and CSS with your WordPress PluginUsing Javascript libraries with your Wordpress plugin or theme

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_enqueue_script"Categories: New page created | Functions | Copyedit

Function Reference/wp enqueue style

Contents1 Description2 Usage3 Example4 Parameters

Description

A safe way of adding cascading style sheets to a WordPress generated page.

Usage

<?php wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = false ); ?>

Example

<?php

/* * This example will work with WordPress 2.7 */

/* * register with hook 'wp_print_styles' */add_action('wp_print_styles', 'add_my_stylesheet');

/* * Enqueue style-file, if it exists. */function add_my_stylesheet(){ $myStyleFile = WP_PLUGIN_URL.'/myPlugin/style.css'; if (file_exists($myStyleFile)){ wp_register_style('myStyleSheets', $myStyleFile);

wp_enqueue_style( 'myStyleSheets');

Page 365: wp-api

}}?>

Note: This function will not work if it is called from a wp_head action, as the <style> tags are output before wp_head runs. Instead, callwp_enqueue_style from an init or the wp_print_styles action function.

Parameters

handle (string) Name of the stylesheet.

src(string) Path to the script from the root directory of WordPress. Example: "/css/mystyle.css".

deps(array) (Optional) Array of handles of any stylesheet that this stylesheet depends on; stylesheets that must be loaded before thisstylesheet. false if there are no dependencies. Defaults to false.

ver (string) (Optional) String specifying the stylesheet version number, if it has one. Defaults to false. This parameter is used to ensure thatthe correct version is sent to the client regardless of caching, and so should be included if a version number is available and makessense for the stylesheet.

media (string) (Optional) String specifying the media for which this stylesheet has been defined. Examples: "all", "screen", "handheld", "print".See this list for the full range of valid CSS-media-types.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_enqueue_style"

Function Reference/wp explain nonce

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve nonce action 'Are you sure' message.

The action is split by verb and noun. The action format is as follows: verb-action_extra. The verb is before the first dash and has the format ofletters and no spaces and numbers. The noun is after the dash and before the underscore, if an underscore exists. The noun is also onlyletters.

The filter will be called for any action, which is not defined by WordPress. You may use the filter for your plugin to explain nonce actions to theuser, when they get the "Are you sure?" message. The filter is in the format of 'explain_nonce_$verb-$noun' with the $verb replaced by thefound verb and the $noun replaced by the found noun. The two parameters that are given to the hook are the localized 'Are you sure you wantto do this?' message with the extra text (the text after the underscore).

Usage

<?php wp_explain_nonce( $action ) ?>

Parameters

$action(string) (required) Nonce action.

Default: None

Return Values

(string) Are you sure message.

Examples

Page 366: wp-api

NotesChange Log

Since: 2.0.4

Source File

wp_explain_nonce() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_explain_nonce"Categories: Functions | New page created

Function Reference/wp filter comment

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Filters and sanitizes comment data.

Sets the comment data 'filtered' field to true when finished. This can be checked as to whether the comment should be filtered and to keep fromfiltering the same comment more than once.

Usage

<?php wp_filter_comment( $commentdata ) ?>

Parameters

$commentdata(array) (required) Contains information on the comment.

Default: None

Return Values

(array) Parsed comment information.

ExamplesNotes

Uses: apply_filters() Calls 'pre_user_id' hook on comment author's user IDUses: apply_filters() Calls 'pre_comment_user_agent' hook on comment author's user agentUses: apply_filters() Calls 'pre_comment_author_name' hook on comment author's nameUses: apply_filters() Calls 'pre_comment_content' hook on the comment's contentUses: apply_filters() Calls 'pre_comment_user_ip' hook on comment author's IPUses: apply_filters() Calls 'pre_comment_author_url' hook on comment author's URLUses: apply_filters() Calls 'pre_comment_author_email' hook on comment author's email address

Change Log

Since: 2.0.0

Source File

wp_filter_comment() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_filter_comment"Categories: Functions | New page created

Page 367: wp-api

Function Reference/wp filter kses

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Sanitize content with allowed HTML Kses rules.

Usage

<?php wp_filter_kses( $data ) ?>

Parameters

$data(string) (required) Content to filter

Default: None

Return Values

(string) Filtered content

ExamplesNotes

Uses global: (unknown) $allowedtags

Change Log

Since: 1.0.0

Source File

wp_filter_kses() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_filter_kses"Categories: Functions | New page created

Function Reference/wp filter nohtml kses

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Strips all of the HTML in the content.

Usage

<?php wp_filter_nohtml_kses( $data ) ?>

Parameters

Page 368: wp-api

$data(string) (required) Content to strip all HTML from

Default: None

Return Values

(string) Filtered content without any HTML

ExamplesNotesChange Log

Since: 2.1.0

Source File

wp_filter_nohtml_kses() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_filter_nohtml_kses"Categories: Functions | New page created

Function Reference/wp filter post kses

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Sanitize content for allowed HTML tags for post content.

Post content refers to the page contents of the 'post' type and not $_POST data from forms.

Usage

<?php wp_filter_post_kses( $data ) ?>

Parameters

$data(string) (required) Post content to filter

Default: None

Return Values

(string) Filtered post content with allowed HTML tags and attributes intact.

ExamplesNotes

Uses global: (unknown) $allowedposttags

Change Log

Since: 2.0.0

Source File

wp_filter_post_kses() is located in wp-includes/kses.php.

Page 369: wp-api

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_filter_post_kses"Categories: Functions | New page created

Function Reference/wp get attachment image

Contents1 Description2 Synopsis3 Usage4 Parameters5 Related

Description

Returns an HTML Image tag representing an attachment file, if there is any. Else returns an empty string.

Synopsis

(string) $image = function wp_get_attachment_image($attachment_id, $size='thumbnail', $icon = false);

Usage

<?php echo wp_get_attachment_image( 1 ); ?>

If the attachment is an image it will try to return the thumbnail or the medium sized version, else if it's a non-image file it will return the mimeicon.

Parameters

$attachment_id(integer) ID of the desired attachment. Required.

$size(string|array) Size of the image shown for an image attachment: either a string keyword (thumbnail, medium, or full) or a 2-item arrayrepresenting 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; default thumbnail

$icon(bool) Use a media icon to represent the attachment. Optional; default false.

Related

Use Function_Reference/wp_get_attachment_image_src

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_get_attachment_image"Categories: Functions | New page created

Function Reference/wp get attachment image src

Contents1 Description2 Synopsis3 Usage4 Return Values5 Parameters

Description

Returns an Image representing an attachment file, if there is any. Else returns false.

Synopsis

(array) $image = function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false);

Usage

<?php $image = wp_get_attachment_image_src( 1 ); ?>

If the attachment is an image it will try to return the thumbnail, else if it's a non-image file it will return the mime icon, else will return false.

Page 370: wp-api

Return Values

An array containing:

$image[0] => url$image[1] => width$image[2] => height

Parameters

$attachment_id(integer) ID of the desired attachment. Required.

$size(string|array) Size of the image shown for an image attachment: either a string keyword (thumbnail, medium, or full) or a 2-item arrayrepresenting 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; default thumbnail

$icon(bool) Use a media icon to represent the attachment. Optional; default false.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src"Categories: Functions | New page created

Function Reference/wp get attachment metadata

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve attachment meta field for attachment ID.

Usage

<?php wp_get_attachment_metadata( $post_id, $unfiltered ) ?>

Parameters

$post_id(integer) (required) Attachment ID

Default: None

$unfiltered(boolean) (optional) If true, filters are not run.

Default: false

Return Values

(string|boolean) Attachment meta field. False on failure.

ExamplesNotesChange Log

Since: 2.1.0

Source File

wp_get_attachment_metadata() is located in wp-includes/post.php.

Related

Page 371: wp-api

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata"Categories: Functions | New page created

Function Reference/wp get attachment thumb file

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve thumbnail for an attachment.

Usage

<?php wp_get_attachment_thumb_file( $post_id ) ?>

Parameters

$post_id(integer) (optional) Attachment ID.

Default: 0

Return Values

(mixed) False on failure. Thumbnail file path on success.

ExamplesNotesChange Log

Since: 2.1.0

Source File

wp_get_attachment_thumb_file() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_attachment_thumb_file"Categories: Functions | New page created

Function Reference/wp get attachment thumb url

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve URL for an attachment thumbnail.

Usage

<?php wp_get_attachment_thumb_url( $post_id ) ?>

Page 372: wp-api

Parameters

$post_id(integer) (optional) Attachment ID

Default: 0

Return Values

(string|boolean) False on failure. Thumbnail URL on success.

ExamplesNotesChange Log

Since: 2.1.0

Source File

wp_get_attachment_thumb_url() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_attachment_thumb_url"Categories: Functions | New page created

Function Reference/wp get attachment url

Contents1 Description2 Example usage & output3 Parameters4 Related

Description

Returns a full URI for an attachment file or false on failure.

Example usage & output

<?php echo wp_get_attachment_url(12); ?> outputs something like http://wp.example.net/wp-content/uploads/filename

Parameters

id(integer) (required) The ID of the desired attachment

Default: None

Related

You can change the output of this function through the wp_get_attachment_url filter.

If you want a URI for the attachment page, not the attachment file itself, you can use get_attachment_link.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_get_attachment_url"Categories: Functions | New page created | Attachments

Function Reference/wp get comment status

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

The status of a comment by ID.

Usage

<?php wp_get_comment_status( $comment_id ) ?>

Parameters

Page 373: wp-api

$comment_id(integer) (required) Comment ID

Default: None

Return Values

(string|boolean) Status might be 'deleted', 'approved', 'unapproved', 'spam' or false on failure.

ExamplesNotes

Uses: get_comment()

Change Log

Since: 1.0.0

Source File

wp_get_comment_status() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_comment_status"Categories: Functions | New page created

Function Reference/wp get cookie login

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Gets the user cookie login.

This function is deprecated and should no longer be extended as it won't be used anywhere in WordPress. Also, plugins shouldn'tuse it either.

Usage

<?php wp_get_cookie_login() ?>

Parameters

None.

Return Values

(boolean) Always returns false

ExamplesNotes

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.This function is deprecated and should no longer be extended as it won't be used anywhere in WordPress. Also, pluginsshouldn't use it either.

Change Log

Since: 2.0.4

Page 374: wp-api

Deprecated: 2.5.0

Source File

wp_get_cookie_login() is located in wp-includes/pluggable.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_cookie_login"Categories: Functions | New page created

Function Reference/wp get current commenter

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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

<?php wp_get_current_commenter() ?>

ParametersReturn Values

(array) Comment author, email, url respectively.

ExamplesNotes

Return array is mapped like this:

Array ( ['comment_author'] => 'Harriet Smith, ['comment_author_email'] => 'hsmith@,example.com', ['comment_author_url'] => 'http://example.com/' )

Change Log

Since: 2.0.4

Source File

wp_get_current_commenter() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_current_commenter"Categories: Functions | New page created

Function Reference/get currentuserinfo

Contents1 Description2 Usage3 Examples

3.1 Default Usage

Page 375: wp-api

3.2 Using Separate Globals4 Parameters

Description

Retrieves the information pertaining to the currently logged in user, and places it in the global variable $userdata. Properties map directly to thewp_users table in the database (see Database Description).

Also places the individual attributes into the following separate global variables:

$user_login$user_level$user_ID$user_email$user_url (User's website, as entered in the user's Profile)$user_pass_md5 (A md5 hash of the user password -- a type of encoding that is very nearly, if not entirely, impossible todecode, but useful for comparing input at a password prompt with the actual user password.)$display_name (User's name, displayed according to the 'How to display name' User option)

Usage

<?php get_currentuserinfo(); ?>

ExamplesDefault Usage

The call to get_currentuserinfo() places the current user's info into $userdata, where it can be retrieved using member variables.

<?php global $current_user; get_currentuserinfo();

echo('Username: ' . $current_user->user_login . "\n"); echo('User email: ' . $current_user->user_email . "\n"); echo('User level: ' . $current_user->user_level . "\n"); echo('User first name: ' . $current_user->user_firstname . "\n"); echo('User last name: ' . $current_user->user_lastname . "\n"); echo('User display name: ' . $current_user->display_name . "\n"); echo('User ID: ' . $current_user->ID . "\n");?>

Username: Zedd

User email: [email protected] level: 10User first name: JohnUser last name: DoeUser display name: John Doe

User ID: 1

Using Separate Globals

Much of the user data is placed in separate global variables, which can be accessed directly.

<?php global $display_name , $user_email; get_currentuserinfo();

echo($display_name . "'s email address is: " . $user_email);?>

Zedd's email address is: [email protected]

: NOTE: $display_name does not appear to work in 2.5+? $user_login works fine.

Page 376: wp-api

<?php global $user_login , $user_email; get_currentuserinfo();

echo($user_login . "'s email address is: " . $user_email);?>

Parameters

This function does not accept any parameters.

To determine if there is a user currently logged in, do this:

<?php global $user_ID; get_currentuserinfo();

if ('' == $user_ID) { //no user logged in }?>

Here is another IF STATEMENT Example. It was used in the sidebar, in reference to the "My Fav" plugin at http://www.kriesi.at/archives/wordpress-plugin-my-favorite-posts

<?php if ( $user_ID ) { ?><!-- enter info that logged in users will see --><!-- in this case im running a bit of php to a plugin -->

<?php mfp_display(); ?>

<?php } else { ?><!-- here is a paragraph that is shown to anyone not logged in -->

<p>By <a href="<?php bloginfo('url'); ?>/wp-register.php">registering</a>, you can save your favorite posts for future reference.</p>

<?php } ?>

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/get_currentuserinfo"Categories: Functions | Copyedit

Function Reference/wp get http headers

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve HTTP Headers from URL.

Usage

<?php wp_get_http_headers( $url, $deprecated ) ?>

Parameters

$url(string) (required)

Default: None

$deprecated(boolean) (optional) Not Used.

Default: false

Page 377: wp-api

Return Values

(boolean|string) False on failure, headers on success.

ExamplesNotesChange Log

Since: 1.5.1

Source File

wp_get_http_headers() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_http_headers"Categories: Functions | New page created

Function Reference/wp get object terms

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieves the terms associated with the given object(s), in the supplied taxonomies.

The following information has to do the $args parameter and for what can be contained in the string or array of that parameter, if it exists.

The first argument is called, 'orderby' and has the default value of 'name'. The other value that is supported is 'count'.

The second argument is called, 'order' and has the default value of 'ASC'. The only other value that will be acceptable is 'DESC'.

The final argument supported is called, 'fields' and has the default value of 'all'. There are multiple other options that can be used instead.Supported values are as follows: 'all', 'ids', 'names', and finally 'all_with_object_id'.

The fields argument also decides what will be returned. If 'all' or 'all_with_object_id' is choosen or the default kept intact, then all matchingterms objects will be returned. If either 'ids' or 'names' is used, then an array of all matching term ids or term names will be returnedrespectively.

Usage

<?php wp_get_object_terms( $object_ids, $taxonomies, $args ) ?>

Parameters

$taxonomies(string|array) (required) The taxonomies to retrieve terms from.

Default: None

$args(array|string) (optional) Change what is returned

Default: array

Return Values

(array|WP_Error) The requested term data or empty array if no terms found. WP_Error if $taxonomy does not exist.

ExamplesNotes

Page 378: wp-api

Uses global: (object) $wpdbMay return WP_Error object.

Change Log

Since: 2.3.0

Source File

wp_get_object_terms() is located in wp-includes/taxonomy.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_object_terms"Categories: Functions | New page created

Function Reference/wp get original referer

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve original referer that was posted, if it exists.

Usage

<?php wp_get_original_referer() ?>

Parameters

None.

Return Values

(string|boolean) False if no original referer or original referer if set.

ExamplesNotes

HTTP referer is an server variable. 'referer' is deliberately miss-spelled.

Change Log

Since: 2.0.4

Source File

wp_get_original_referer() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_original_referer"Categories: Functions | New page created

Function Reference/wp get post categories

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes

Page 379: wp-api

7 Change Log8 Source File9 Related

Description

Retrieve the list of categories for a post.

Compatibility layer for themes and plugins. Also an easy layer of abstraction away from the complexity of the taxonomy layer.

Usage

<?php wp_get_post_categories( $post_id, $args ) ?>

Parameters

$post_id(integer) (optional) The Post ID.

Default: 0

$args(array) (optional) Overwrite the defaults.

Default: array

Return Values

(array)

ExamplesNotes

Uses: wp_get_object_terms() Retrieves the categories.

Change Log

Since: 2.1.0

Source File

wp_get_post_categories() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_post_categories"Categories: Functions | New page created

Function Reference/wp get recent posts

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the $num most recent posts from the database in order of the post date. Defaults to retrieving the 10 most recent posts.

Usage

<?php wp_get_recent_posts( $num ) ?>

Parameters

$num(integer) (optional) Number of posts to get.

Default: 10

Page 380: wp-api

Return Values

(array) List of posts.

ExamplesNotes

Uses: $wpdb to query the posts table.

Change Log

Since: 1.0.0

Source File

wp_get_recent_posts() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_recent_posts"Categories: Functions | New page created

Function Reference/wp get referer

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve referer from '_wp_http_referer', HTTP referer, or current page respectively.

Usage

<?php wp_get_referer() ?>

Parameters

None.

Return Values

(string|boolean) False on failure. Referer URL on success.

ExamplesNotes

HTTP referer is a server variable. 'referer' is deliberately miss-spelled.

Change Log

Since: 2.0.4

Source File

wp_get_referer() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_referer"Categories: Functions | New page created

Function Reference/wp get schedule

Page 381: wp-api

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve Cron schedule for hook with arguments.

Usage

<?php wp_get_schedule( $hook, $args ) ?>

Parameters

$hook(callback) (required) Function or method to call, when cron is run.

Default: None

$args(array) (optional) Arguments to pass to the hook function.

Default: array

Return Values

(string|boolean) False, if no schedule. Schedule on success.

ExamplesNotes

Cron is named after a unix program which runs unattended scheduled tasks.

Change Log

Since: 2.1.0

Source File

wp_get_schedule() is located in wp-includes/cron.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_schedule"Categories: Functions | New page created

Function Reference/wp get schedules

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples

5.1 display6 Notes7 Change Log8 Source File9 Related

Description

Retrieve supported and filtered Cron recurrences.

The supported recurrences are 'hourly' and 'daily'. A plugin may add more by hooking into the 'cron_schedules' filter. The filter accepts an array

Page 382: wp-api

of arrays. The outer array has a key that is the name of the schedule or for example 'weekly'. The value is an array with two keys, one is'interval' and the other is 'display'.

The 'interval' is a number in seconds of when the cron job should run. So for 'hourly', the time is 3600 or 60*60. For weekly, the value would be60*60*24*7 or 604800. The value of 'interval' would then be 604800.

Usage

<?php wp_get_schedules() ?>

Parameters

None.

Return Values

(array)

Examplesdisplay

The 'display' is the description. For the 'weekly' key, the 'display' would be

__('Once Weekly');

For your plugin, you will be passed an array. you can easily add your schedule by doing the following.

<?php // filter parameter variable name is 'array' $array['weekly'] = array( 'interval' => 604800, 'display' => __('Once Weekly') );?>

NotesChange Log

Since: 2.1.0

Source File

wp_get_schedules() is located in wp-includes/cron.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_schedules"Categories: Functions | New page created

Function Reference/wp get single post

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve a single post, based on post ID.

Usage

Page 383: wp-api

<?php wp_get_single_post( $postid, $mode ) ?>

Parameters

$postid(integer) (optional) Post ID.

Default: 0

$mode(string) (optional) How to return result. Expects a Constant: OBJECT, ARRAY_N, or ARRAY_A.

Default: OBJECT

Return Values

(object|array) Post object or array holding post contents and information with two additional fields (or keys): 'post_category' and 'tags_input'.

ExamplesNotes

Uses: get_post()Uses: wp_get_post_categories()Uses: wp_get_post_tags()

Change Log

Since: 1.0.0

Source File

wp_get_single_post() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_get_single_post"Categories: Functions | New page created

Function Reference/wp hash

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Get hash of given string.

Usage

<?php wp_hash( $data, $scheme ) ?>

Parameters

$data(string) (required) Plain text to hash.

Default: None

$scheme(unknown) (optional)

Default: 'auth'

Return Values

Page 384: wp-api

(string) Hash of $data

ExamplesNotes

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.Uses: wp_salt() Get WordPress salt.

Change Log

Since: 2.0.4

Source File

wp_hash() is located in wp-includes/pluggable.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_hash"Categories: Functions | New page created

Function Reference/wp insert attachment

Contents1 Description2 Usage3 Example4 Parameters5 Related

Description

This function inserts an attachment into the media library. The function should be used in conjunction with wp_update_attachment_metadata()and wp_generate_attachment_metadata(). Returns the ID of the entry created in the wp_posts table.

Usage

<?php wp_insert_attachment( $attachment, $filename, $parent_post_id ); ?>

Example

To insert an attachment to a parent with a post ID of 37:

<?php $attach_id = wp_insert_attachment( $attachment, $filename, 37 ); $attach_data = wp_generate_attachment_metadata( $attach_id, $filename ); wp_update_attachment_metadata( $attach_id, $attach_data );?>

Parameters

$attachment(array) (required) Array of data about the attachment that will be written into the wp_posts table of the database. Must contain at aminimum the keys post_title, post_content (the value for this key should be the empty string) and post_status.

Default: None

$filename(string) (optional) Location of the file on the server. Use absolute path and not the URI of the file.

Default: false

$parent_post_id(int) (optional) Attachments are associated with parent posts. This is the ID of the parent's post ID.

Default: 0

Related

wp_get_attachment_url(), wp_delete_attachment(), wp_insert_post()

This article is marked as in need of editing. You can help Codex by editing it.

Page 385: wp-api

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_insert_attachment"Categories: Copyedit | Functions | New page created

Function Reference/wp insert comment

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Inserts a comment to the database.

The available $commentdata key names are 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_parent','comment_approved', and 'user_id'.

Usage

<?php wp_insert_comment( $commentdata ) ?>

Parameters

$commentdata(array) (required) Contains information on the comment.

Default: None

Return Values

(integer) The new comment's ID.

ExamplesNotes

Uses: $wpdbUses: current_time()Uses: get_gmt_from_date()Uses: wp_update_comment_count()Uses:Insers a record in the comments table in the database

Change Log

Since: 2.0.0

Source File

wp_insert_comment() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_insert_comment"Categories: Functions | New page created

Function Reference/wp insert post

Contents1 Description2 Usage3 Example

3.1 Categories4 Parameters5 Return6 Related

Page 386: wp-api

Description

This function inserts posts (and pages) in the database. It sanitizes variables, does some checks, fills in missing variables like date/time, etc. Ittakes an object as its argument and returns the post ID of the created post (or 0 if there is an error).

Usage

<?php wp_insert_post( $post ); ?>

Example

Before calling wp_insert_post() it is necessary to create an object (typically an array) to pass the necessary elements that make up a post. Thewp_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 user can provide more elements than are listed here by simply defining new keys in the database. The keys should match the names ofthe columns in the wp_posts table in the database.

// Create post object $my_post = array(); $my_post['post_title'] = 'My post'; $my_post['post_content'] = 'This is my post.'; $my_post['post_status'] = 'publish'; $my_post['post_author'] = 1; $my_post['post_category'] = array(8,39);

// Insert the post into the database wp_insert_post( $my_post );

The default list referred to above is defined in the function body. It is as follows:

$defaults = array( 'post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID, 'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '');

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 onecategory is assigned to the post.

Parameters

$post(object) (required) An object representing the elements that make up a post. There is a one-to-one relationship between these elementsand the names of columns in the wp_posts table in the database.

Default: None

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 thekeys you can set for a post:

$post = array( 'comment_status' => [ 'closed' | 'open' ] // 'closed' means no comments. 'ID' => [ <post id> ] //Are you updating an existing post? 'menu_order' => [ <order> ] //If new post is a page, sets the order should it appear in the tabs. 'page_template => [ <template file> ] //Sets the template for the page. 'ping_status' => [ ? ] //Ping status? 'pinged' => [ ? ] //? 'post_author' => [ <user ID> ] //The user ID number of the author. 'post_category => [ array(<category id>, <...>) ] //Add some categories. 'post_content' => [ <the text of the post> ] //The full text of the post.

Page 387: wp-api

'post_date' => [ Y-m-d H:i:s ] //The time post was made. 'post_date_gmt' => [ Y-m-d H:i:s ] //The time post was made, in GMT. 'post_excerpt' => [ <an excerpt> ] //For all your post excerpt needs. 'post_parent' => [ <post ID> ] //Sets the parent of the new post. 'post_password' => [ ? ] //password for post? 'post_status' => [ 'draft' | 'publish' | 'pending' ] //Set the status of the new post. 'post_title' => [ <the title> ] //The title of your post. 'post_type' => [ 'post' | 'page' ] //Sometimes you want to post a page. 'tags_input' => [ '<tag>, <tag>, <...>' ] //For tags. 'to_ping' => [ ? ] //?);

Return

The ID of the post if the post is successfully added to the database. Otherwise returns 0.

Related

wp_update_post(), wp_delete_attachment(), wp_get_attachment_url(), wp_insert_attachment()

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_insert_post"Categories: Copyedit | Functions | New page created

Function Reference/wp insert user

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Insert an user into the database.

Can update a current user or insert a new user based on whether the user's ID is present.

Can be used to update the user's info (see below), set the user's role, and set the user's preference on the use of the rich editor.

Usage

<?php wp_insert_user( $userdata ) ?>

Parameters

$userdata(array) (required) An array of user data.

Default: None

Return Values

(integer) The newly created user's ID.

ExamplesNotes

Uses: $wpdb WordPress database layer.Uses: apply_filters() Calls filters for most of the $userdata fields with the prefix 'pre_user'. See description above.Uses: do_action() Calls 'profile_update' hook when updating giving the user's IDUses: do_action() Calls 'user_register' hook when creating a new user giving the user's ID

Page 388: wp-api

The $userdata array can contain the following fieldsFieldName Description Associated

FilterID An integer that will be used for updating an existing user. (none)user_pass A string that contains the plain text password for the user. pre_user_user_passuser_login A string that contains the users username for logging in. pre_user_user_loginuser_nicename A string that contains a nicer looking name for the user. The default is the users username. pre_user_user_nicenameuser_url A string containing the users URL for the users web site. pre_user_user_urluser_email A string containing the users email address. pre_user_user_emaildisplay_name A string that will be shown on the site. Defaults to users 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 defaultadmin user).

pre_user_display_name

nickname The users nickname, defaults to the users username. pre_user_nicknamefirst_name The users first name. pre_user_first_namelast_name The users last name. pre_user_last_namedescription A string containing content about the user. pre_user_descriptionrich_editing A string for whether to enable the rich editor or not. False if not empty. (none)user_registered The date the user registered. Format is Y-m-d H:i:s. (none)role A string used to set the users role. (none)jabber Users Jabber account. (none)aim Users AOL IM account. (none)yim Users Yahoo IM account. (none)

Page 389: wp-api

Change Log

Since: 2.0.0

Source File

wp_insert_user() is located in wp-includes/registration.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_insert_user"Categories: Functions | New page created

Function Reference/wp iso descrambler

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Converts an email subject to ASCII.

Usage

<?php wp_iso_descrambler( $string ) ?>

Parameters

$string(string) (required) Subject line

Default: None

Return Values

(string) Converted string to ASCII

ExamplesNotes

"iso" seems to refer to the iso-8859-1 character set.There is a somewhat related discussion on WordPress trac about Swedish encoding.

Change Log

Since: 1.2.0

Source File

wp_iso_descrambler() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_iso_descrambler"Categories: Functions | New page created

Function Reference/wp kses

Contents1 Description

Page 390: wp-api

2 Usage3 Parameters4 Return5 Further Reading

Description

This function makes sure that only the allowed HTML element names, attribute names and attribute values plus only sane HTML entities willoccur in $string. You have to remove any slashes from PHP's magic quotes before you call this function.

Usage

<?php wp_kses($string, $allowed_html, $allowed_protocols); ?>

Parameters

$string(string) Content to filter through kses

$allowed_html(array) List of allowed HTML elements

$allowed_protocols(array) (optional) Allow links in $string to these protocols.

The default allowed protocols are http, https, ftp, mailto, news, irc, gopher, nntp, feed, and telnet. This covers all common linkprotocols, except for javascript, which should not be allowed for untrusted users.

Return

This function returns a filtered string of HTML.

Further Reading

For a comprehensive list of functions, take a look at the category Functions

Also, see Function_Reference

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_kses"Categories: Functions | New page created

Function Reference/wp kses array lc

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Goes through an array and changes the keys to all lower case.

Usage

<?php wp_kses_array_lc( $inarray ) ?>

Parameters

$inarray(array) (required) Unfiltered array

Default: None

Return Values

(array) Fixed array with all lowercase keys

Examples

Page 391: wp-api

Notes

This function expects a multi-dimensional array for input.

Change Log

Since: 1.0.0

Source File

wp_kses_array_lc() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_array_lc"Categories: Functions | New page created

Function Reference/wp kses attr

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Removes all attributes, if none are allowed for this element.

If some are allowed it calls wp_kses_hair() to split them further, and then it builds up new HTML code from the data that kses_hair() returns. Italso removes '<' and '>' 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

<?php wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) ?>

Parameters

$element(string) (required) HTML element/tag

Default: None

$attr(string) (required) HTML attributes from HTML element to closing HTML element tag

Default: None

$allowed_html(array) (required) Allowed HTML elements

Default: None

$allowed_protocols(array) (required) Allowed protocols to keep

Default: None

Return Values

(string) Sanitized HTML element

ExamplesNotesChange Log

Since: 1.0.0

Page 392: wp-api

Source File

wp_kses_attr() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_attr"Categories: Functions | New page created

Function Reference/wp kses bad protocol

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Sanitize string from bad protocols.

This function removes all non-allowed protocols from the beginning of $string. It ignores whitespace and the case of the letters, and it doesunderstand HTML entities. It does its work in a while loop, so it won't be fooled by a string like 'javascript:javascript:alert(57)'.

Usage

<?php wp_kses_bad_protocol( $string, $allowed_protocols ) ?>

Parameters

$string(string) (required) Content to filter bad protocols from

Default: None

$allowed_protocols(array) (required) Allowed protocols to keep

Default: None

Return Values

(string) Filtered content

ExamplesNotesChange Log

Since: 1.0.0

Source File

wp_kses_bad_protocol() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_bad_protocol"Categories: Functions | New page created

Function Reference/wp kses bad protocol once

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples

Page 393: wp-api

6 Notes7 Change Log8 Source File9 Related

Description

Sanitizes content from bad protocols and other characters.

This function searches for URL protocols at the beginning of $string, while handling whitespace and HTML entities.

Usage

<?php wp_kses_bad_protocol_once( $string, $allowed_protocols ) ?>

Parameters

$string(string) (required) Content to check for bad protocols

Default: None

$allowed_protocols(string) (required) Allowed protocols

Default: None

Return Values

(string) Sanitized content

ExamplesNotes

Uses global: (unknown) $_kses_allowed_protocols

Change Log

Since: 1.0.0

Source File

wp_kses_bad_protocol_once() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_bad_protocol_once"Categories: Functions | New page created

Function Reference/wp kses bad protocol once2

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Callback for wp_kses_bad_protocol_once() 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

<?php wp_kses_bad_protocol_once2( $matches ) ?>

Parameters

Page 394: wp-api

$matches(mixed) (required) string or preg_replace_callback() matches array to check for bad protocols

Default: None

Return Values

(string) Sanitized content

ExamplesNotes

This is a private function. It should not be called directly. It is listed in the Codex for completeness.Uses global: (unknown) $_kses_allowed_protocols

Change Log

Since: 1.0.0

Source File

wp_kses_bad_protocol_once2() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_bad_protocol_once2"Categories: Functions | New page created

Function Reference/wp kses check attr val

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Performs different checks for attribute values.

The currently implemented checks are 'maxlen', 'minlen', 'maxval', 'minval' and 'valueless' with even more checks to come soon.

Usage

<?php wp_kses_check_attr_val( $value, $vless, $checkname, $checkvalue ) ?>

Parameters

$value(string) (required) Attribute value

Default: None

$vless(string) (required) Whether the value is valueless or not. Use 'y' or 'n'

Default: None

$checkname(string) (required) What $checkvalue is checking for.

Default: None

$checkvalue(mixed) (required) What constraint the value should pass

Default: None

Return Values

(boolean)

Page 395: wp-api

Whether check passes (true) or not (false)

ExamplesNotesChange Log

Since: 1.0.0

Source File

wp_kses_check_attr_val() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_check_attr_val"Categories: Functions | New page created

Function Reference/wp kses decode entities

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Convert all entities to their character counterparts.

This function decodes numeric HTML entities (like &#65; and &#x41;). It doesn't do anything with other entities like &auml;, but we don't needthem in the URL protocol whitelisting system anyway.

Usage

<?php wp_kses_decode_entities( $string ) ?>

Parameters

$string(string) (required) Content to change entities

Default: None

Return Values

(string) Content after decoded entities

ExamplesNotesChange Log

Since: 1.0.0

Source File

wp_kses_decode_entities() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_decode_entities"Categories: Functions | New page created

Function Reference/wp kses hair

Contents

Page 396: wp-api

1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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 weirdinput. It will add quotes around attribute values that don't have any quotes or apostrophes around them, to make it easier to produce HTMLcode that will conform to W3C's HTML specification. It will also remove bad URL protocols from attribute values. It also reduces duplicateattributes by using the attribute defined first (foo='bar' foo='baz' will result in foo='bar').

Usage

<?php wp_kses_hair( $attr, $allowed_protocols ) ?>

Parameters

$attr(string) (required) Attribute list from HTML element to closing HTML element tag

Default: None

$allowed_protocols(array) (required) Allowed protocols to keep

Default: None

Return Values

(array) List of attributes after parsing

ExamplesNotesChange Log

Since: 1.0.0

Source File

wp_kses_hair() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_hair"Categories: Functions | New page created

Function Reference/wp kses hook

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

You add any kses hooks here.

There is currently only one kses WordPress hook and it is called here. All parameters are passed to the hooks and expected to recieve a

Page 397: wp-api

string.

Usage

<?php wp_kses_hook( $string, $allowed_html, $allowed_protocols ) ?>

Parameters

$string(string) (required) Content to filter through kses

Default: None

$allowed_html(array) (required) List of allowed HTML elements

Default: None

$allowed_protocols(array) (required) Allowed protocol in links

Default: None

Return Values

(string) Filtered content through 'pre_kses' hook

ExamplesNotesChange Log

Since: 1.0.0

Source File

wp_kses_hook() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_hook"Categories: Functions | New page created

Function Reference/wp kses html error

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Handles parsing errors in wp_kses_hair().

The general plan is to remove everything to and including some whitespace, but it deals with quotes and apostrophes as well.

Usage

<?php wp_kses_html_error( $string ) ?>

Parameters

$string(string) (required)

Default: None

Return Values

Page 398: wp-api

(string)

ExamplesNotesChange Log

Since: 1.0.0

Source File

wp_kses_html_error() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_html_error"Categories: Functions | New page created

Function Reference/wp kses js entities

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Removes the HTML JavaScript entities found in early versions of Netscape 4.

Usage

<?php wp_kses_js_entities( $string ) ?>

Parameters

$string(string) (required)

Default: None

Return Values

(string)

ExamplesNotesChange Log

Since: 1.0.0

Source File

wp_kses_js_entities() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_js_entities"Categories: Functions | New page created

Function Reference/wp kses no null

Contents1 Description2 Usage3 Parameters4 Return Values

Page 399: wp-api

5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Removes any NULL characters in $string.

Usage

<?php wp_kses_no_null( $string ) ?>

Parameters

$string(string) (required)

Default: None

Return Values

(string)

ExamplesNotesChange Log

Since: 1.0.0

Source File

wp_kses_no_null() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_no_null"Categories: Functions | New page created

Function Reference/wp kses normalize entities

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Converts and fixes HTML entities.

This function normalizes HTML entities. It will convert 'AT&T' to the correct 'AT&T', ':' to ':', '&#XYZZY;' to '&#XYZZY;' and so on.

Usage

<?php wp_kses_normalize_entities( $string ) ?>

Parameters

$string(string) (required) Content to normalize entities

Default: None

Return Values

(string)

Page 400: wp-api

Content with normalized entities

ExamplesNotesChange Log

Since: 1.0.0

Source File

wp_kses_normalize_entities() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_normalize_entities"Categories: Functions | New page created

Function Reference/wp kses normalize entities2

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Callback for wp_kses_normalize_entities() regular expression.

This function helps wp_kses_normalize_entities() to only accept 16 bit values and nothing more for &#number; entities.

Usage

<?php wp_kses_normalize_entities2( $matches ) ?>

Parameters

$matches(array) (required) preg_replace_callback() matches array

Default: None

Return Values

(string) Correctly encoded entity

ExamplesNotes

This is a private function. It should not be called directly. It is listed in the Codex for completeness.

Change Log

Since: 1.0.0

Source File

wp_kses_normalize_entities2() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_normalize_entities2"Categories: Functions | New page created

Function Reference/wp kses split

Page 401: wp-api

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Searches for HTML tags, no matter how malformed.

It also matches stray ">" characters.

Usage

<?php wp_kses_split( $string, $allowed_html, $allowed_protocols ) ?>

Parameters

$string(string) (required) Content to filter

Default: None

$allowed_html(array) (required) Allowed HTML elements

Default: None

$allowed_protocols(array) (required) Allowed protocols to keep

Default: None

Return Values

(string) Content with fixed HTML tags

ExamplesNotes

Uses: wp_kses_split2() as a callback to do much of the work.

Change Log

Since: 1.0.0

Source File

wp_kses_split() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_split"Categories: Functions | New page created

Function Reference/wp kses split2

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Page 402: wp-api

Description

Callback for wp_kses_split() for fixing malformed HTML tags.

This function does a lot of work. It rejects some very malformed things like <:::>. It returns an empty string, if the element isn't allowed (look ma,no strip_tags()!). 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 iscompleted, will be returned.

Usage

<?php wp_kses_split2( $string, $allowed_html, $allowed_protocols ) ?>

Parameters

$string(string) (required) Content to filter

Default: None

$allowed_html(array) (required) Allowed HTML elements

Default: None

$allowed_protocols(array) (required) Allowed protocols to keep

Default: None

Return Values

(string) Fixed HTML element

ExamplesNotes

This is a private function. It should not be called directly. It is listed in the Codex for completeness.Uses: wp_kses_attr()

Change Log

Since: 1.0.0

Source File

wp_kses_split2() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_split2"Categories: Functions | New page created

Function Reference/wp kses strip slashes

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Strips slashes from in front of quotes.

This function changes the character sequence \" to just ". It leaves all other slashes alone. It's really weird, but the quoting frompreg_replace(//e) seems to require this.

Page 403: wp-api

Usage

<?php wp_kses_stripslashes( $string ) ?>

Parameters

$string(string) (required) String to strip slashes

Default: None

Return Values

(string) Fixed strings with quoted slashes

ExamplesNotesChange Log

Since: 1.0.0

Source File

wp_kses_stripslashes() is located in wp-includes/kses.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_strip_slashes"Categories: Functions | New page created

Function Reference/wp kses version

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

This function returns the kses version number.

Usage

<?php wp_kses_version() ?>

Parameters

None.

Return Values

(string) KSES Version Number

ExamplesNotesChange Log

Since: 1.0.0

Source File

wp_kses_version() is located in wp-includes/kses.php.

Page 404: wp-api

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_kses_version"Categories: Functions | New page created

Function Reference/wp mailDescription

Sends an email.

Parameters

$to(string) (required) The intended recipient(s) of the message.

Default: None

$subject(string) (required) The subject of the message.

Default: None

$message(string) (required) Message content.

Default: None

$headers(string) (optional) Mail headers to send with the message (advanced)

Default: Empty

Usage

<?php wp_mail($to, $subject, $message, $headers = ); ?>

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_mail"Categories: Stubs | Functions

Function Reference/wp make link relative

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Convert full URL paths to absolute 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 rootbase.

Usage

<?php wp_make_link_relative( $link ) ?>

Parameters

$link(string) (required) Full URL path.

Default: None

Return Values

(string)

Page 405: wp-api

Absolute path.

ExamplesNotesChange Log

Since: 2.1.0

Source File

wp_make_link_relative() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_make_link_relative"Categories: Functions | New page created

Function Reference/wp mime type icon

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the icon for a MIME type.

Usage

<?php wp_mime_type_icon( $mime ) ?>

Parameters

$mime(string) (optional) MIME type

Default: 0

Return Values

(string|boolean) Returns a value from The filtered value after all hooked functions are applied to it.

ExamplesNotes

Uses: apply_filters calls 'wp_mime_type_icon' on $icon, $mime and $post_id

Change Log

Since: 2.1.0

Source File

wp_mime_type_icon() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_mime_type_icon"Categories: Functions | New page created

Function Reference/wp mkdir p

Contents

Page 406: wp-api

1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Recursive directory creation based on full path.

Will attempt to set permissions on folders.

Usage

<?php wp_mkdir_p( $target ) ?>

Parameters

$target(string) (required) Full path to attempt to create.

Default: None

Return Values

(boolean) Whether the path was created or not. True if path already exists.

ExamplesNotesChange Log

Since: 2.0.1

Source File

wp_mkdir_p() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_mkdir_p"Categories: Functions | New page created

Function Reference/wp new comment

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

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 'comment_post' action withcomment ID and whether comment is approved by WordPress. Also has 'preprocess_comment' filter for processing the comment data beforethe function handles it.

Usage

<?php wp_new_comment( $commentdata ) ?>

Page 407: wp-api

Parameters

$commentdata(array) (required) Contains information on the comment.

Default: None

Return Values

(integer) The ID of the comment after adding.

ExamplesNotes

Uses: apply_filters() Calls 'preprocess_comment' hook on $commentdata parameter array before processingUses: do_action() Calls 'comment_post' hook on $comment_ID returned from adding the comment and if the comment was approved.Uses: wp_filter_comment() Used to filter comment before adding comment.Uses: wp_allow_comment() checks to see if comment is approved.Uses: wp_insert_comment() Does the actual comment insertion to the database.Uses: wp_notify_moderator()Uses: wp_notify_postauthor()Uses: wp_get_comment_status()

Change Log

Since: 1.5.0

Source File

wp_new_comment() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_new_comment"Categories: Functions | New page created

Function Reference/wp new user notification

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Notify the blog admin of a new user, normally via email.

Usage

<?php wp_new_user_notification( $user_id, $plaintext_pass ) ?>

Parameters

$user_id(integer) (required) User ID

Default: None

$plaintext_pass(string) (optional) The user's plaintext password

Default: ''

Return Values

(void)

Page 408: wp-api

This function does not return a value.

ExamplesNotes

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Change Log

Since: 2.0

Source File

wp_new_user_notification() is located in wp-includes/pluggable.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_new_user_notification"Categories: Functions | New page created

Function Reference/wp next scheduled

Contents1 Description2 Usage3 Return Value4 Parameters

Description

Returns the next timestamp for a cron event.

Usage

$timestamp = wp_next_scheduled( hook, args (optional));

Return Value

timestampThe time the scheduled event will next occur (unix timestamp)

Parameters

$hook(string) (required) Name of the action hook for event.

Default: None

$args(array) (optional) Arguments to pass to the hook function(s).

Default: None

See Also:

wp_schedule_eventwp_schedule_single_eventwp_clear_scheduled_hookwp_unschedule_event

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_next_scheduled"Categories: Functions | New page created | WP-Cron Functions

Function Reference/wp nonce ays

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log

Page 409: wp-api

8 Source File9 Related

Description

Display 'Are You Sure?' message to confirm the action being taken.

If the action has the nonce explain message, then it will be displayed along with the 'Are you sure?' message.

Usage

<?php wp_nonce_ays( $action ) ?>

Parameters

$action(string) (required) The nonce action.

Default: None

Return Values

(void) This function does not return a value.

ExamplesNotesChange Log

Since: 2.0.4

Source File

wp_nonce_ays() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_nonce_ays"Categories: Functions | New page created

Function Reference/wp nonce field

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve or display nonce hidden field for forms.

The nonce field is used to validate that the contents of the form came from the location on the current site and not somewhere else. The noncedoes not offer absolute protection, but should protect against most cases. It is very important to use nonce field in forms.

If you set $echo to true and set $referer to true, then you will need to retrieve the wp_referer_field(). If you have the $referer set to true and areechoing the nonce field, it will also echo the referer field.

The $action and $name are optional, but if you want to have better security, it is strongly suggested to set those two parameters. It is easier tojust call the function without any parameters, because validation of the nonce doesn't require any parameters, but since crackers know whatthe default is it won't be difficult for them to find a way around your nonce and cause damage.

The input name will be whatever $name value you gave. The input value will be the nonce creation value.

Usage

<?php wp_nonce_field( $action, $name, $referer, $echo ) ?>

Page 410: wp-api

Parameters

$action(string) (optional) Action name.

Default: -1

$name(string) (optional) Nonce name.

Default: "_wpnonce"

$referer(boolean) (optional) default true. Whether to set the referer field for validation.

Default: true

$echo(boolean) (optional) default true. Whether to display or return hidden form field.

Default: true

Return Values

(string) Nonce field.

ExamplesNotesChange Log

Since: 2.0.4

Source File

wp_nonce_field() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_nonce_field"Categories: Functions | New page created

Function Reference/wp nonce url

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve URL with nonce added to URL query.

Usage

<?php wp_nonce_url( $actionurl, $action ) ?>

Parameters

$actionurl(string) (required) URL to add nonce action

Default: None

$action(string) (optional) Nonce action name

Default: -1

Return Values

Page 411: wp-api

(string) URL with nonce action added.

ExamplesNotesChange Log

Since: 2.0.4

Source File

wp_nonce_url() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_nonce_url"Categories: Functions | New page created

Function Reference/wp notify moderator

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Notifies the moderator of the blog about a new comment that is awaiting approval.

Usage

<?php wp_notify_moderator( $comment_id ) ?>

Parameters

$comment_id(integer) (required) Comment ID

Default: None

Return Values

(boolean) Always returns true

ExamplesNotes

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.Uses global: (object) $wpdb

Change Log

Since: 1.0

Source File

wp_notify_moderator() is located in wp-includes/pluggable.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_notify_moderator"Categories: Functions | New page created

Function Reference/wp notify postauthor

Page 412: wp-api

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Sanitizes a URL for use in a redirect.

Usage

<?php wp_notify_postauthor( $comment_id, $comment_type ) ?>

Parameters

$comment_id(integer) (required) Comment ID

Default: None

$comment_type(string) (optional) The comment type either 'comment' (default), 'trackback', or 'pingback'

Default: ''

Return Values

(boolean) False if user email does not exist. True on completion.

ExamplesNotes

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.Uses: apply_filters() Calls 'allowed_redirect_hosts' on an array containing WordPress host string and $location host string.

Change Log

Since: 1.0.0

Source File

wp_notify_postauthor() is located in wp-includes/pluggable.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_notify_postauthor"Categories: Functions | New page created

Function Reference/wp original referer field

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve or display original referer hidden field for forms.

Page 413: wp-api

The input name is '_wp_original_http_referer' and will be either the same value of wp_referer_field(), if that was posted already or it will be thecurrent page, if it doesn't exist.

Usage

<?php wp_original_referer_field( $echo, $jump_back_to ) ?>

Parameters

$echo(boolean) (optional) Whether to echo the original http referer.

Default: true

$jump_back_to(string) (optional) default is 'current'. Can be 'previous' or page you want to jump back to.

Default: 'current'

Return Values

(string) Original referer field.

ExamplesNotesChange Log

Since: 2.0.4

Source File

wp_original_referer_field() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_original_referer_field"Categories: Functions | New page created

Function Reference/wp publish post

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Publish a post by transitioning the post status.

Usage

<?php wp_publish_post( $post_id ) ?>

Parameters

$post_id(integer) (required) Post ID.

Default: None

Return Values

(null)

ExamplesNotes

Page 414: wp-api

Uses: $wpdbUses: do_action() to call the following on $post_id and $post (post data):

edit_post(),save_post() andwp_insert_post().

Change Log

Since: 2.1.0

Source File

wp_publish_post() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_publish_post"Categories: Functions | New page created

Function Reference/wp redirect

Contents1 Description2 Parameters3 Usage4 Example

Description

Redirects the user to a specified absolute URI.

Parameters

$location(string) (required) The absolute URI which the user will be redirected to.

Default: None

$status(integer) (optional) The status code to use

Default: 302

Usage

<?php wp_redirect($location, $status); ?>

Example

<?php wp_redirect(get_option('siteurl') . '/wp-login.php'); ?>

Redirects can also be external, and/or use a "Moved Permanently" code :

<?php wp_redirect('http://www.example.com', 301); ?>

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_redirect"Categories: Functions | New page created

Function Reference/wp referer field

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve or display referer hidden field for forms.

Page 415: wp-api

The referer link is the current Request URI from the server super global. The input name is '_wp_http_referer', in case you wanted to checkmanually.

Usage

<?php wp_referer_field( $echo ) ?>

Parameters

$echo(boolean) (optional) Whether to echo or return the referer field.

Default: true

Return Values

(string) Referer field.

ExamplesNotesChange Log

Since: 2.0.4

Source File

wp_referer_field() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_referer_field"Categories: Functions | New page created

Function Reference/wp rel nofollow

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Adds rel="nofollow" string to all HTML entities A elements in content.

Usage

<?php wp_rel_nofollow( $text ) ?>

Parameters

$text(string) (required) Content that may contain HTML A elements.

Default: None

Return Values

(string) Converted content.

ExamplesNotes

Uses global: (object) $wpdb to escape text.

Change Log

Page 416: wp-api

Since: 1.5.0

Source File

wp_rel_nofollow() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_rel_nofollow"Categories: Functions | New page created

Function Reference/wp remote fopenDescription

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

<?php $contents = wp_remote_fopen($uri); ?>

Parameters

$uri(string) (required) The URI of the remote page to be retrieved.

Default: None

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_remote_fopen"Category: Functions

Function Reference/wp reschedule event

Contents1 Description2 Usage3 Parameters4 Also see

Description

This function is used internally by WordPress to reschedule a recurring event. You'll likely never need to use this function manually, it isdocumented here for completeness.

Usage

<?php wp_reschedule_event( timestamp, recurrence, hook, args (optional));

Parameters

timestampThe time the scheduled event will occur (unix timestamp)

recurranceHow often the event recurs, either 'hourly' or 'daily'

hookName of action hook to fire (string)

argsArguments to pass into the hook function(s) (array)

Also see

For a comprehensive list of functions, take a look at the category Functions

Function_Reference

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_reschedule_event"Categories: Functions | New page created | WP-Cron Functions

Function Reference/wp richedit pre

Page 417: wp-api

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Formats text for the rich text editor.

The filter 'richedit_pre' is applied here. If $text is empty the filter will be applied to an empty string.

Usage

<?php wp_richedit_pre( $text ) ?>

Parameters

$text(string) (required) The text to be formatted.

Default: None

Return Values

(string) The formatted text after filter is applied.

ExamplesNotesChange Log

Since: 2.0.0

Source File

wp_richedit_pre() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_richedit_pre"Categories: Functions | New page created

Function Reference/wp rss

Contents1 Description2 Usage3 Example4 Parameters5 Output6 Related

Description

Retrieves an RSS feed and parses it, then displays it as an unordered list of links. Uses the MagpieRSS and RSSCache functions for parsingand automatic caching and the Snoopy HTTP client for the actual retrieval.

Usage

<?phpinclude_once(ABSPATH . WPINC . '/rss.php');wp_rss($uri, $num);?>

Example

Page 418: wp-api

To get and display a list of 5 links from an existing RSS feed:

<?php include_once(ABSPATH . WPINC . '/rss.php');wp_rss('http://example.com/rss/feed/goes/here', 5);?>

Parameters

$uri(URI) (required) The URI of the RSS feed you want to retrieve. The resulting parsed feed is returned, with the more interesting anduseful bits in the items array.

Default: None

$num(integer) (required) The number of items to display.

Default: None

Output

The output will look like the following:

<ul><li><a href='LINK FROM FEED' title='DESCRIPTION FROM FEED'>TITLE FROM FEED</a></li>(repeat for number of links specified)</ul>

Related

fetch_rss

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_rss"Category: Functions

Function Reference/wp salt

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Get salt to add to hashes to help prevent attacks.

The secret key is located in two places: the database in case the secret key isn't defined in the second place, which is in the wp-config.php file.If you are going to set the secret key, then you must do so in the wp-config.php file.

The secret key in the database is randomly generated and will be appended to the secret key that is in wp-config.php file in some instances. Itis important to have the secret key defined or changed in wp-config.php.

If you have installed WordPress 2.5 or later, then you will have the SECRET_KEY defined in the wp-config.php already. You will want to changethe value in it because hackers will know what it is. If you have upgraded to WordPress 2.5 or later version from a version before WordPress2.5, then you should add the constant to your wp-config.php file.

Salting passwords helps against tools which has stored hashed values of common dictionary strings. The added values makes it harder tocrack if given salt string is not weak.

Usage

<?php wp_salt( $scheme ) ?>

Page 419: wp-api

Parameters

$scheme(unknown) (optional)

Default: 'auth'

Return Values

(string) Salt value from either 'SECRET_KEY' or 'secret' option

ExamplesNotes

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.See Also: Create a Secret Key for wp-config.phpUses global: (unknown) $wp_default_secret_key

Change Log

Since: 2.5

Source File

wp_salt() is located in wp-includes/pluggable.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_salt"Categories: Functions | New page created

Function Reference/wp schedule event

Contents1 Description2 Usage3 Parameters4 Examples

4.1 Schedule an hourly event5 Further Reading

Description

Schedules a hook which will be executed by the WordPress actions core on a specific interval, specified by you. The action will trigger whensomeone visits your WordPress site, if the scheduled time has passed. See the Plugin API for a list of hooks.

Usage

<?php wp_schedule_event(time(), 'hourly', 'my_schedule_hook'); ?>

Parameters

$timestamp(integer) (required) The first time that you want the event to occur. This must be in a UNIX timestamp format.

Default: None

$recurrance(string) (required) How often the event should reoccur. Valid values:

hourlydailyDefault: None

$hook(string) (required) The name of an action hook to execute.

Default: None

$args(array) (optional) Arguments to pass to the hook function(s).

Default: None

Examples

Page 420: wp-api

Schedule an hourly event

To schedule an hourly event in a plugin, call wp_schedule_event on activation (otherwise you will end up with a lot of scheduled events!):

register_activation_hook(__FILE__, 'my_activation');add_action('my_hourly_event', 'do_this_hourly');

function my_activation() {wp_schedule_event(time(), 'hourly', 'my_hourly_event');

}

function do_this_hourly() {// do something every hour

}

Don't forget to clean the scheduler on deactivation:

register_deactivation_hook(__FILE__, 'my_deactivation');

function my_deactivation() {wp_clear_scheduled_hook('my_hourly_event');

}

Further Reading

For a comprehensive list of functions, take a look at the category Functions

Also, see Function_Reference

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_schedule_event"Categories: Functions | New page created | WP-Cron Functions

Function Reference/wp schedule single event

Contents1 Description2 Usage3 Examples

3.1 Schedule an event one hour from now4 Parameters5 Further Reading

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 whensomeone visits your WordPress site, if the schedule time has passed.

Usage

<?php wp_schedule_single_event(time(), 'my_schedule_hook'); ?>

ExamplesSchedule an event one hour from now

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.

Parameters

Page 421: wp-api

$timestamp(integer) (required) The time you want the event to occur. This must be in a UNIX timestamp format.

Default: None

$hook(string) (required) The name of an action hook to execute.

Default: None

$args(array) (optional) Arguments to pass to the hook function(s)

Default: None

Further Reading

For a comprehensive list of functions, take a look at the category Functions

Also, see Function_Reference

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_schedule_single_event"Categories: Functions | WP-Cron Functions

Function Reference/wp set comment status

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Sets the status of a comment.

The 'wp_set_comment_status' action is called after the comment is handled and will only be called, if the comment status is either 'hold','approve', or 'spam'. If the comment status is not in the list, then false is returned and if the status is 'delete', then the comment is deletedwithout calling the action.

Usage

<?php wp_set_comment_status( $comment_id, $comment_status ) ?>

Parameters

$comment_id(integer) (required) Comment ID.

Default: None

$comment_status(string) (required) New comment status, either 'hold', 'approve', 'spam', or 'delete'.

Default: None

Return Values

(boolean) False on failure or deletion and true on success.

ExamplesNotes

Uses: wp_transition_comment_status() Passes new and old comment status along with $comment objectUses: wp_notify_postauthor()Uses: get_option()Uses: wp_delete_comment()Uses: clean_comment_cache()Uses: get_comment()Uses: wp_transition_comment_status()

Page 422: wp-api

Uses: wp_update_comment_count()Uses global: (object) $wpdb

Change Log

Since: 1.0.0

Source File

wp_set_comment_status() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_set_comment_status"Categories: Functions | New page created

Function Reference/wp set current user

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Changes the current user by ID or name.

Set $id 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. wp_set_current_user() opens the ability to editand perform actions on users who aren't signed in.

Usage

<?php wp_set_current_user( $id, $name ) ?>

Parameters

$id(integer) (required) User ID

Default: None

$name(string) (optional) User's username

Default: ''

Return Values

(WP_User) Current user User object.

ExamplesNotes

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.Uses: User objectUses: setup_userdata()Uses: do_action() Calls 'set_current_user' hook after setting the current user.

Change Log

Since: 2.0.4

Page 423: wp-api

Source File

wp_set_current_user() is located in wp-includes/pluggable.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_set_current_user"Categories: Functions | New page created

Function Reference/wp set post categories

This article is marked as in need of editing. You can help Codex by editing it.

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Set categories for a post.

If the post categories parameter is not set, then the default category is going used.

Usage

<?php wp_set_post_categories( $post_ID, $post_categories ) ?>

Parameters

$post_ID(integer) (optional) Post ID.

Default: 0

$post_categories(array) (optional) List of categories.

Default: array

Return Values

(boolean|mixed)

ExamplesNotesChange Log

Since: 2.1.0

Source File

wp_set_post_categories() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_set_post_categories"Categories: Copyedit | Functions | New page created

Function Reference/wp setcookie

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples

Page 424: wp-api

6 Notes7 Change Log8 Source File9 Related

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Sets a cookie for a user who just logged in.

This function is deprecated. Use wp_set_auth_cookie() instead.

Usage

<?php wp_setcookie( $username, $password, $already_md5, $home, $siteurl, $remember ) ?>

Parameters

$username(string) (required) The user's username

Default: None

$password(string) (optional) The user's password

Default: ''

$already_md5(boolean) (optional) Whether the password has already been through MD5

Default: false

$home(string) (optional) Will be used instead of COOKIEPATH if set

Default: ''

$siteurl(string) (optional) Will be used instead of SITECOOKIEPATH if set

Default: ''

$remember(boolean) (optional) Remember that the user is logged in

Default: false

Return Values

void This function doesn't return anything.

ExamplesNotes

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.This function is deprecated. Use wp_set_auth_cookie() instead.

Change Log

Since: 1.5Deprecated: 2.5.0

Source File

wp_setcookie() is located in wp-includes/pluggable.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_setcookie"Categories: Functions | New page created

Function Reference/wp signon

Contents

Page 425: wp-api

1 Description2 Usage3 Examples4 Parameters5 Return6 Related

Description

Authenticates a user with option to remember. New function instead of wp_login. Since Wordpress 2.5.

Usage

wp_signon( $credentials = , $secure_cookie = )

ExamplesParameters

@param array $credentials Optional. User info in order to sign on.

@param bool $secure_cookie Optional. Whether to use secure cookie.

@return object Either WP_Error on failure, or WP_User on success.

If you don't provide $credentials, wp_signon uses the $_POST variable.

Return

object Either WP_Error on failure, or WP_User on success

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_signon"Category: Functions

Function Reference/wp specialchars

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Converts a number of special characters into their HTML entities.

Differs from htmlspecialchars as existing HTML entities will not be encoded. Specifically changes: & to &#038;, < to &lt; and > to &gt;.

$quotes can be set to 'single' to encode ' to &#039;, 'double' to encode " to &quot;, or '1' to do both. Default is 0 where no quotes are encoded.

Usage

<?php wp_specialchars( $text, $quotes ) ?>

Parameters

$text(string) (required) The text which is to be encoded.

Default: None

$quotes(mixed) (optional) Converts single quotes if set to 'single', double if set to 'double' or both if otherwise set.

Default: 0

Return Values

Page 426: wp-api

(string) The encoded text with HTML entities.

ExamplesNotes

htmlspecialchars (noted in the description) is a PHP built-in function.

Change Log

Since: 1.2.2

Source File

wp_specialchars() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_specialchars"Categories: Functions | New page created

Function Reference/wp throttle comment flood

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Determine whether comment should be blocked because of comment flood.

Usage

<?php wp_throttle_comment_flood( $block, $time_lastcomment, $time_newcomment ) ?>

Parameters

$block(boolean) (required) True if plugin is blocking comments.

Default: None

$time_lastcomment(integer) (required) Timestamp for last comment.

Default: None

$time_newcomment(integer) (required) Timestamp for new comment.

Default: None

Return Values

(boolean) Returns true if $block is true or if $block is false and $time_newcomment - $time_lastcomment < 15. Returns false otherwise.

ExamplesNotesChange Log

Since: 2.1.0

Source File

wp_throttle_comment_flood() is located in wp-includes/comment.php.

Page 427: wp-api

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_throttle_comment_flood"Categories: Functions | New page created

Function Reference/wp trim excerpt

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Generates an excerpt from the content, if needed.

The excerpt word amount will be 55 words and if the amount is greater than that, then the string ' [...]' will be appended to the excerpt. If thestring is less than 55 words, then the content will be returned as is.

Usage

<?php wp_trim_excerpt( $text ) ?>

Parameters

$text(string) (required) The exerpt. If set to empty an excerpt is generated. If you supply text it will be returned untouched. It will not beshortened.

Default: None

Return Values

(string) The excerpt.

ExamplesNotes

Uses: get_the_contentUses: strip_shortcodes() on $text.Uses: apply_filters() for 'the_content' on $text.Uses: apply_filters() for 'excerpt_length' on 55

Change Log

Since: 1.5.0

Source File

wp_trim_excerpt() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_trim_excerpt"Categories: Functions | New page created

Function Reference/wp unschedule eventDescription

Un-schedules a previously-scheduled cron job.

Usage

<?php wp_unschedule_event(next_scheduled_time, 'my_schedule_hook', original_args ); ?>

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

Page 428: wp-api

supposed to have, in order to unschedule it. All future occurrences are un-scheduled by calling this function.

See:

wp_schedule_eventwp_schedule_single_eventwp_clear_scheduled_hookwp_next_scheduled

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_unschedule_event"Categories: Stubs | Functions | New page created | WP-Cron Functions

Function Reference/wp update attachment metadata

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Update metadata for an attachment.

Usage

<?php wp_update_attachment_metadata( $post_id, $data ) ?>

Parameters

$post_id(integer) (required) Attachment ID.

Default: None

$data(array) (required) Attachment data.

Default: None

Return Values

(integer) Returns value from update_post_meta()

ExamplesNotes

Uses: apply_filters() to add wp_update_attachment_metadata() on $data and post ID.

Change Log

Since: 2.1.0

Source File

wp_update_attachment_metadata() is located in wp-includes/post.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_update_attachment_metadata"Categories: Functions | New page created

Function Reference/wp update comment

Page 429: wp-api

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Updates an existing comment in the database.

Filters the comment and makes sure certain fields are valid before updating.

Usage

<?php wp_update_comment( $commentarr ) ?>

Parameters

$commentarr(array) (required) Contains information on the comment.

Default: None

Return Values

(integer) Comment was updated if value is 1, or was not updated if value is 0.

ExamplesNotes

Uses: wp_transition_comment_status() Passes new and old comment status along with $comment objectUses: get_comment()Uses: wp_filter_comment()Uses: get_gmt_from_date()Uses: clean_comment_cache()Uses: wp_update_comment_count()Uses: do_action() on 'edit_comment' on $comment_ID.Uses global: (object) $wpdb

Change Log

Since: 2.0.0

Source File

wp_update_comment() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_update_comment"Categories: Functions | New page created

Function Reference/wp update comment count

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Page 430: wp-api

Description

Updates the comment count for post(s).

When $do_deferred is false (is by default) and the comments have been set to be deferred, $post_id will be added to a queue, which will beupdated 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 $do_deferred is set to true, then all previous deferredpost IDs will be updated along with the current $post_id.

Usage

<?php wp_update_comment_count( $post_id, $do_deferred ) ?>

Parameters

$post_id(integer) (required) Post ID

Default: None

$do_deferred(boolean) (optional) Whether to process previously deferred post comment counts

Default: false

Return Values

(boolean) True on success, false on failure

ExamplesNotes

See wp_update_comment_count_now() for what could cause a false return valueUses: wp_update_comment_count_now()Uses: wp_defer_comment_counting()

Change Log

Since: 2.1.0

Source File

wp_update_comment_count() is located in wp-includes/comment.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_update_comment_count"Categories: Functions | New page created

Function Reference/wp update post

Contents1 Description2 Usage3 Example

3.1 Categories4 Parameters5 Return6 Related

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.

Usage

<?php wp_update_post( $post ); ?>

Example

Before calling wp_update_post() it is necessary to create an array to pass the necessary elements. Unlike wp_insert_post(), it is onlynecessary 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

Page 431: wp-api

database.

// Update post 37 $my_post = array(); $my_post['ID'] = 37; $my_post['post_content'] = 'This is the updated content.';

// Update the post into the database wp_update_post( $my_post );

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 onecategory is assigned to the post.

Parameters

$post(array) (optional) An object representing the elements that make up a post. There is a one-to-one relationship between these elementsand the names of columns in the wp_posts table in the database. Filling out the ID field is not strictly necessary but without it there islittle point to using the function.

Default: An empty array

Return

The ID of the post if the post is successfully added to the database. Otherwise returns 0.

Related

wp_insert_post()

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_update_post"Categories: Copyedit | Functions | New page created

Function Reference/wp update user

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Update (or create) a user in the database.

It is possible to update a user's password by specifying the 'user_pass' value in the $userdata parameter array.

If $userdata does not contain an 'ID' key, then a new user will be created and the new user's ID will be returned.

If current user's password is being updated, then the cookies will be cleared.

Usage

<?php wp_update_user( $userdata ) ?>

Parameters

$userdata(array) (required) An array of user data.

Default: None

Return Values

(integer)

Page 432: wp-api

The updated user's ID.

ExamplesNotes

Uses: get_userdata()Uses: wp_hash_password()Uses: wp_insert_user() Used to update existing user or add new one if user doesn't exist alreadyUses: wp_get_current_user()Uses: wp_clear_auth_cookie()Uses: wp_set_auth_cookie()

Change Log

Since: 2.0.0

Source File

wp_update_user() is located in wp-includes/registration.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_update_user"Categories: Functions | New page created

Function Reference/wp upload bits

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Create a file in the upload folder with given content.

If there is an error, then the key 'error' will exist with the error message. If success, then the key 'file' will have the unique file path, the 'url' keywill have the link to the new file. and the 'error' key will be set to false.

This function will not move an uploaded file to the upload folder. It will create a new file with the content in $bits parameter. If you move theupload file, read the content of the uploaded file, and then you can give the filename and content to this function, which will add it to the uploadfolder.

The permissions will be set on the new file automatically by this function.

Usage

<?php wp_upload_bits( $name, $deprecated, $bits, $time ) ?>

Parameters

$name(string) (required)

Default: None

$deprecated(null) (required) Not used. Set to null.

Default: None

$bits(mixed) (required) File content

Default: None

$time(string) (optional) Time formatted in 'yyyy/mm'.

Default: null

Page 433: wp-api

Return Values

(array)

ExamplesNotesChange Log

Since: 2.0.0

Source File

wp_upload_bits() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/wp_upload_bits"Categories: Functions | New page created

Function Reference/wp upload dirUsage

<?php$wud = wp_upload_dir();$old = wp_upload_dir( '2007-11-26 04:26:39' );

echo 'uploads_use_yearmonth_folders: '.get_option( 'uploads_use_yearmonth_folders' )."\n";echo 'upload_path: ' .get_option( 'upload_path' )."\n";echo 'upload_url_path: ' .get_option( 'upload_url_path' )."\n";print_r($old);print_r($wud);

?>

Return

The fields returned are: [path], [url], [subdir], [basedir], [baseurl], [error]

On success, the returned array will have many indices: 'path' - base directory and sub directory or full path to upload directory. 'url' - base urland sub directory or absolute URL to upload directory. 'subdir' - sub directory if uploads use year/month folders option is on. 'basedir' - pathwithout subdir. 'baseurl' - URL path without subdir. 'error' - set to false.

fields [basedir] and [baseurl] return since WordPress v.2.6

Example Output

uploads_use_yearmonth_folders: 1upload_path: /home/example.com/wordpress/wp-content/uploadsupload_url_path: http://www.example.com/wordpress/wp-content/uploads

Array( [path] => /home/example.com/wordpress/wp-content/uploads/2007/11 [url] => http://www.example.com/wordpress/wp-content/uploads/2007/11 [subdir] => /2007/11 [basedir] => /home/example.com/wordpress/wp-content/uploads [baseurl] => http://www.example.com/wordpress/wp-content/uploads [error] => )

Array( [path] => /home/example.com/wordpress/wp-content/uploads/2008/11 [url] => http://www.example.com/wordpress/wp-content/uploads/2008/11 [subdir] => /2008/11 [basedir] => /home/example.com/wordpress/wp-content/uploads [baseurl] => http://www.example.com/wordpress/wp-content/uploads [error] => )

Page 434: wp-api

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_upload_dir"Categories: Functions | New page created

Function Reference/wp verify nonce

Contents1 Description2 Parameters3 Returns4 Example5 See also

Description

Verify that correct nonce was used with time limit.

Parameters

$nonce(string) (required) Nonce that was used in the form to verify.

Default: None

$action(string) (int) Should give context to what is taking place and be the same when nonce was created.

Default: -1

Returns

@return bool Whether the nonce check passed or failed.

Example

<?php $nonce= wp_create_nonce ('my-nonce'); ?><a href='myplugin.php?_wpnonce=<?php echo $nonce ?>'> ...

<?php $nonce=$_REQUEST['_wpnonce'];if (! wp_verify_nonce($nonce, 'my-nonce') ) die('Security check'); ?>

See also

Wordpress Nonce Implementationwp_create_noncecheck_admin_referer

This page is marked as incomplete. You can help Codex by expanding it.

Retrieved from "http://codex.wordpress.org/Function_Reference/wp_verify_nonce"Categories: Stubs | Functions

Function Reference/wpautop

Contents1 Description2 Usage3 Parameters4 References

Description

Changes double line-breaks in the text into HTML paragraphs (<p>...</p>).

Wordpress uses it to filter the content and the excerpt.

Usage

Page 435: wp-api

<?php wpautop( $pee, $br = 1 ); ?>

Parameters

pee (string) The text to be formatted.

br (boolean) Preserve line breaks. When set to true, any line breaks remaining after paragraph conversion are converted to HTML <br />.Line breaks within script and style sections are not affected. Default true.

References

http://photomatt.net/scripts/autop/

This article is marked as in need of editing. You can help Codex by editing it.

Retrieved from "http://codex.wordpress.org/Function_Reference/wpautop"Categories: Functions | New page created | Copyedit

Function Reference/wpdb Class

Contents1 Interfacing With the Database

1.1 Notes On Use2 Run Any Query on the Database

2.1 Examples3 SELECT a Variable

3.1 Examples4 SELECT a Row

4.1 Examples5 SELECT a Column

5.1 Examples6 SELECT Generic Results

6.1 Examples7 Protect Queries Against SQL Injection Attacks

7.1 Examples8 Show and Hide SQL Errors9 Getting Column Information10 Clearing the Cache11 Class Variables12 Tables

Interfacing With the Database

WordPress provides a class of functions for all database manipulations. The class is called wpdb and is based on the ezSQL class written andmaintained by Justin Vincent. Though the WordPress class is slightly different than the ezSQL class, their use is essentially the same. Pleasesee the ezSQL documentation for more information.

Notes On Use

Within PHP code blocks in a template the $wpdb class should work as expected, but in the case of a plugin or external script it may benecessary to scope it to global before calling it in your code. This is briefly explained in the Writing a Plugin documentation.

If writing a plugin that will use a table that is not created in a vanilla WordPress installation, the $wpdb class can be used to read data from anytable in the database in much the same way it can read data from a WordPress-Installed table. The query should be structured like "SELECTid, name FROM mytable", don't worry about specifying which database to look for the table in, the $wpdb object will automatically use thedatabase WordPress is installed in. Any of the functions below will work with a query that is set up like this.

Run Any Query on the Database

The query function allows you to execute any query on the WordPress database. It is best to use a more specific function, however, forSELECT queries.

<?php $wpdb->query('query'); ?>

query (string) The query you wish to run.

If there are any query results, the function will return an integer corresponding to the number of rows affected and the query results will cachedfor use by other wpdb functions. If there are no results, the function will return (int) 0. If there is a MySQL error, the function will return FALSE.

Page 436: wp-api

(Note: since both 0 and FALSE can be returned, make sure you use the correct comparison operator: equality == vs. identicality ===).

Note: It is advisable to use the wpdb->escape($user_entered_data_string) method to protect the database against SQL injectionattacks by malformed or malicious data, especially when using the INSERT or UPDATE SQL commands on user-entered data in the database.See the section entitled Protect Queries Against SQL Injection Attacks below.

Additionally, if you wish to access the database from your code file which is not placed inside one of the standard plugin locations, you willneed to require_once() the wp-load.php file as this file will will now require any other files you will need for connecting to the database. Ifyou are going to be using the database connection inside of a function, do not forget to declare $wpdb as global. It is always advisable to putyour functionality inside a plugin. However, if you need it in some cases, this workaround is available. For example, this is the code in a filehas_great_code.php in the root/installation directory :

require_once('wp-load.php');

function some_function() { global $wpdb; /* your function code would go here */}

Examples

Add Post 13 to Category 2:

$wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id)VALUES (13, 2)");

Delete the 'gargle' meta key and value from Post 13.

$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '13'AND meta_key = 'gargle'");

Performed in WordPress by delete_post_meta().

Set the parent of Page 15 to Page 7.

$wpdb->query("UPDATE $wpdb->posts SET post_parent = 7WHERE ID = 15 AND post_status = 'static'");

SELECT a Variable

The get_var function returns a single variable from the database. Though only one variable is returned, the entire result of the query iscached for later use. Returns NULL if no result is found.

<?php $wpdb->get_var('query',column_offset,row_offset); ?>

query (string) The query you wish to run. Setting this parameter to null will return the specified variable from the cached results of theprevious query.

column_offset (integer) The desired column (0 being the first). Defaults to 0.

row_offset (integer) The desired row (0 being the first). Defaults to 0.

Examples

Retrieve the name of Category 4.

$name = $wpdb->get_var("SELECT name FROM $wpdb->terms WHERE term_ID=4");echo $name;

Retrieve and display the number of users.

<?php$user_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users;");?><p><?php echo 'user count is ' . $user_count; ?></p>

SELECT a Row

Page 437: wp-api

To retrieve an entire row from a query, use get_row. The function can return the row as an object, an associative array, or as a numberedarray. If more than one row is returned by the query, only the specified row is returned by the function, but all rows are cached for later use.

<?php $wpdb->get_row('query', output_type, row_offset); ?>

query (string) The query you wish to run. Setting this parameter to null will return the specified row from the cached results of the previousquery.

output_type One of three pre-defined constants. Defaults to OBJECT.

OBJECT - result will be output as an object.ARRAY_A - result will be output as an associative array.ARRAY_N - result will be output as a numbered array.

row_offset (integer) The desired row (0 being the first). Defaults to 0.

Examples

Get all the information about Link 10.

$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10");

The properties of the $mylink object are the column names of the result from the SQL query (in this all of the columns from the$wpdb->links table).

echo $mylink->link_id; // prints "10"

In contrast, using

$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10", ARRAY_A);

would result in an associative array:

echo $mylink['link_id']; // prints "10"

and

$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10", ARRAY_N);

would result in a numbered array:

echo $mylink[1]; // prints "10"

SELECT a Column

To SELECT a column, use get_col. This function outputs a dimensional array. If more than one column is returned by the query, only thespecified column will be returned by the function, but the entire result is cached for later use.

<?php $wpdb->get_col('query',column_offset); ?>

query (string) the query you wish to execute. Setting this parameter to null will return the specified column from the cached results of theprevious query.

column_offset (integer) The desired column (0 being the first). Defaults to 0.

Examples

Get all the Categories to which Post 103 belongs.

$postcats = $wpdb->get_col("SELECT category_idFROM $wpdb->post2catWHERE post_id = 103ORDER BY category_id");

Performed in WordPress by wp_get_post_cats().

SELECT Generic Results

Generic, mulitple row results can be pulled from the database with get_results. The function returns the entire query result as an array.

Page 438: wp-api

Each element of this array corresponds to one row of the query result and, like get_row can be an object, an associative array, or a numberedarray.

<?php $wpdb->get_results('query', output_type); ?>

query (string) The query you wish to run. Setting this parameter to null will return the data from the cached results of the previous query.

output_type One of three pre-defined constants. Defaults to OBJECT. See SELECT a Row and its examples for more information.

OBJECT - result will be output as an object.ARRAY_A - result will be output as an associative array.ARRAY_N - result will be output as a numbered array.

Examples

Get the IDs and Titles of all the Drafts by User 5 and echo the Titles.

$fivesdrafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->postsWHERE post_status = 'draft' AND post_author = 5");

foreach ($fivesdrafts as $fivesdraft) {echo $fivesdraft->post_title;

}

Using the OBJECT output_type, get the 5 most recent posts in Categories 3,20, and 21 and display the permalink title to each post. (exampleworks at WordPress Version 2.2.1)

<?php$querystr =" SELECT $wpdb->posts.* FROM $wpdb->posts LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'post' AND $wpdb->post2cat.category_id IN (3,20,21) ORDER BY $wpdb->posts.post_date DESC LIMIT 5";$pageposts = $wpdb->get_results($querystr, OBJECT);?><?php if ($pageposts): ?> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?></a></h2> <?php endforeach; ?> <?php else : ?> <h2> Not Found</h2><?php endif; ?>

Protect Queries Against SQL Injection Attacks

If you're creating an SQL query, make sure you protect against SQL injection attacks. This can be conveniently done with the preparemethod.

<?php $sql = $wpdb->prepare( 'query'[, value_parameter, value_parameter ... ] ); ?>

Note that you may need to use PHP's stripslashes() when loading data back into WordPress that was inserted with a prepared query.

Examples

Add Meta key => value pair "Harriet's Adages" => "WordPress' database interface is like Sunday Morning: Easy." to Post 10.

$metakey = "Harriet's Adages";$metavalue = "WordPress' database interface is like Sunday Morning: Easy.";

$wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->postmeta( post_id, meta_key, meta_value )VALUES ( %d, %s, %s )",

10, $metakey, $metavalue ) );

Page 439: wp-api

Performed in WordPress by add_meta().

Notice that you do not have to worry about quoting strings. Instead of passing the variables directly into the SQL query, place a %s marker forstrings and a %d marker for integers. You can pass as many values as you like, each as a new parameter in the prepare() method.

Show and Hide SQL Errors

You can turn error echoing on and off with the show_errors and hide_errors, respectively.

<?php $wpdb->show_errors(); ?><?php $wpdb->hide_errors(); ?>

You can also print the error (if any) generated by the most recent query with print_error.

<?php $wpdb->print_error(); ?>

Getting Column Information

You can retrieve information about the columns of the most recent query result with get_col_info. This can be useful when a function hasreturned an OBJECT whose properties you don't know. The function will output the desired information from the specified column, or an arraywith information on all columns from the query result if no column is specified.

<?php $wpdb->get_col_info('type', offset); ?>

type (string) What information you wish to retrieve. May take on any of the following values (list taken from the ezSQL docs). Defaults toname.

name - column name. Default.table - name of the table the column belongs tomax_length - maximum length of the columnnot_null - 1 if the column cannot be NULLprimary_key - 1 if the column is a primary keyunique_key - 1 if the column is a unique keymultiple_key - 1 if the column is a non-unique keynumeric - 1 if the column is numericblob - 1 if the column is a BLOBtype - the type of the columnunsigned - 1 if the column is unsignedzerofill - 1 if the column is zero-filled

offset (integer) Specify the column from which to retrieve information (with 0 being the first column). Defaults to -1.

-1 - Retrieve information from all columns. Output as array. Default.Non-negative integer - Retrieve information from specified column (0 being the first).

Clearing the Cache

You can clear the SQL result cache with flush.

<?php $wpdb->flush(); ?>

This clears $wpdb->last_result, $wpdb->last_query, and $wpdb->col_info.

Class Variables

$show_errors Whether or not Error echoing is turned on. Defaults to TRUE.

$num_queries The number of queries that have been executed.

$last_query The most recent query to have been executed.

$queries You may save all of the queries run on the database and their stop times be setting the SAVEQUERIES constant to TRUE (thisconstant defaults to FALSE). If SAVEQUERIES is TRUE, your queries will be stored in this variable as an array.

$last_results The most recent query results.

$col_info The column information for the most recent query results. See Getting Column Information.

$insert_id ID generated for an AUTO_INCREMENT column by the most recent INSERT query.

Page 440: wp-api

Tables

The WordPress database tables are easily referenced in the wpdb class.

$posts The table of Posts.

$users The table of Users.

$comments The Comments table.

$links The table of Links.

$options The Options table.

$postmeta The Meta Content (a.k.a. Custom Fields) table.

$usermeta The usermeta table contains additional user information, such as nicknames, descriptions and permissions.

$terms The terms table contains the 'description' of Categories, Link Categories, Tags.

$term_taxonomy The term_taxonomy table describes the various taxonomies (classes of terms). Categories, Link Categories, and Tags are taxonomies.

$term_relationships The term relationships table contains link between the term and the object that uses that term, meaning this file point to each Categoryused for each Post.

Retrieved from "http://codex.wordpress.org/Function_Reference/wpdb_Class"Categories: Advanced Topics | Design and Layout | Functions | Template Tags | WordPress Development

Function Reference/wptexturize

This page is marked as incomplete. You can help Codex by expanding it.

Description

This returns given text with some transformations:

Usage

<?php wptexturize(); ?>

(List is incomplete, but gives you an idea.)

-- en-dash--- em-dash... ellipsis

There is a small "cockney" list of transformations, as well. The following common phrases will have typographic quotes added to them:

'tain't'twere'twas'tis'twill'til'bout'nuff'round'cause

ParametersRetrieved from "http://codex.wordpress.org/Function_Reference/wptexturize"Categories: Stubs | Functions | New page created

Function Reference/xmlrpc getpostcategory

Contents

Page 441: wp-api

1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve the post category or categories from XMLRPC XML.

If the category element is not found, then the default post category will be used. The return type then would be what $post_default_category. Ifthe category is found, then it will always be an array.

Usage

<?php xmlrpc_getpostcategory( $content ) ?>

Parameters

$content(string) (required) XMLRPC XML Request content

Default: None

Return Values

(string|array) List of categories or category name.

ExamplesNotes

Uses global: (unknown) $post_default_category

Change Log

Since: 0.71

Source File

xmlrpc_getpostcategory() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/xmlrpc_getpostcategory"Categories: Functions | New page created

Function Reference/xmlrpc getposttitle

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Retrieve post title from XMLRPC XML.

If the title element is not part of the XML, then the default post title from the $post_default_title will be used instead.

Usage

<?php xmlrpc_getposttitle( $content ) ?>

Page 442: wp-api

Parameters

$content(string) (required) XMLRPC XML Request content

Default: None

Return Values

(string) Post title

ExamplesNotes

Uses global: (string) $post_default_title

Change Log

Since: 0.71

Source File

xmlrpc_getposttitle() is located in wp-includes/functions.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/xmlrpc_getposttitle"Categories: Functions | New page created

Function Reference/xmlrpc removepostdata

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

XMLRPC XML content without title and category elements.

Usage

<?php xmlrpc_removepostdata( $content ) ?>

Parameters

$content(string) (required) XMLRPC XML Request content

Default: None

Return Values

(string) XMLRPC XML Request content without title and category elements.

ExamplesNotesChange Log

Since: 0.71

Source File

xmlrpc_removepostdata() is located in wp-includes/functions.php.

Page 443: wp-api

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/xmlrpc_removepostdata"Categories: Functions | New page created

Function Reference/zeroise

Contents1 Description2 Usage3 Parameters4 Return Values5 Examples6 Notes7 Change Log8 Source File9 Related

Description

Add leading zeros when necessary.

If you set the threshold to '4' and the number is '10', then you will get back '0010'. If you set the threshold to '4' and the number is '5000', thenyou will get back '5000'.

Uses sprintf to append the amount of zeros based on the $threshold parameter and the size of the number. If the number is large enough, thenno zeros will be appended.

Usage

<?php zeroise( $number, $threshold ) ?>

Parameters

$number(mixed) (required) Number to append zeros to if not greater than threshold.

Default: None

$threshold(integer) (required) Digit places number needs to be to not have zeros added.

Default: None

Return Values

(string) Adds leading zeros to number if needed.

ExamplesNotesChange Log

Since: 0.71

Source File

zeroise() is located in wp-includes/formatting.php.

RelatedRetrieved from "http://codex.wordpress.org/Function_Reference/zeroise"Categories: Functions | New page created