Post tags

1)the_content()

Description
The "the_content" filter is used to filter the content of the post after it is retrieved from the database and before it is printed to the screen.
A plugin (or theme) can register as a content filter with the code:
<?php add_filter( 'the_content', 'filter_function_name' ) ?>
Where 'filter_function_name' is the function WordPress should call when the content is being retrieved. Note that the filter function must return the content after it is finished processing, or site visitors will see a blank page and other plugins also filtering the content may generate errors.
filter_function_name should be unique function name. It cannot match any other function name already declared.
Examples
Debug Page
This could be used to provide generated content for a page (as an alternative to the Shortcode_API), or for a set of pages sharing some characteristics (e.g. the same author):
// returns the content of $GLOBALS['post']
// if the page is called 'debug'
function my_the_content_filter($content) {
  // assuming you have created a page/post entitled 'debug'
  if ($GLOBALS['post']->post_name == 'debug') {
    return var_export($GLOBALS['post'], TRUE );
  }
  // otherwise returns the database content
  return $content;
}

add_filter( 'the_content', 'my_the_content_filter' );



2)the_ID()

Description
Displays the numeric ID of the current post. This tag must be within The Loop.
Note: This function displays the ID of the post, to return the ID use get_the_ID().
Usage <?php the_ID(); ?>
Parameters
This tag has no parameters.
Examples
Default 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>



3)the_tags()

Description
This template tag displays a link to the tag or tags a post belongs to. If no tags are associated with the current entry, nothing is displayed. This tag should be used within The Loop.
Usage
 <?php the_tags( $before, $sep, $after ); ?>
Parameters
$before
(string) Text to display before the actual tags are displayed. Defaults to Tags:
$sep
(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.
Return Values
None.
Examples
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>
Separated by Commas
Displays a list of the tags with a line break after it.
 <?php the_tags( 'Tags: ', ', ', '<br />' ); ?>



4)the_title()

Description
Displays or returns the title of the current post. This tag may only be used within The Loop, to get the title of a post outside of the loop use get_the_title. If the post is protected or private, this will be noted by the words "Protected: " or "Private: " prepended to the title.
Usage
 <?php the_title( $before, $after, $echo ); ?>
Parameters
$before
(string) (optional) Text to place before the title.
Default: None
$after
(string) (optional) Text to place after the title.
Default: None
$echo
(Boolean) (optional) Display the title (TRUE) or return it for use in PHP (FALSE).
Default: TRUE
Example
<?php the_title( '<h3>', '</h3>' ); ?>

5)get_the_title()

Description
Displays or returns the title of the current post. This tag may only be used within The Loop, to get the title of a post outside of the loop use get_the_title. If the post is protected or private, this will be noted by the words "Protected: " or "Private: " prepended to the title.
Usage
 <?php the_title( $before, $after, $echo ); ?>
Parameters
$before
(string) (optional) Text to place before the title.
Default: None
$after
(string) (optional) Text to place after the title.
Default: None
$echo
(Boolean) (optional) Display the title (TRUE) or return it for use in PHP (FALSE).
Default: TRUE
Example
<?php the_title( '<h3>', '</h3>' ); ?>

6)the_date()

Description
Displays or returns the date of a post, or a set of posts if published on the same day.
Usage
 <?php the_date( $format, $before, $after, $echo ); ?>
Parameters
$format
(string) (optional) The format for the date. Defaults to the date format configured in your WordPress options. See Formatting Date and Time.
Default: F j, Y
$before
(string) (optional) Text to place before the date.
Default: None
$after
(string) (optional) Text to place after the date
Default: None
$echo
(boolean) (optional) Display the date (TRUE), or return the date to be used in PHP (FALSE).
Default: TRUE
Return
(string|null) Null if displaying, string if retrieving.
Examples
Default Usage
Displays the date using defaults.
<?php the_date(); ?>
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 with the PHP echo command.
<?php $my_date = the_date('', '<h2>', '</h2>', FALSE); echo $my_date; ?>


7)get_the_date()

Description
The get_the_date template tag retrieves the date the current $post was written. Unlike the_date() this tag will always return the date. Modify output with 'get_the_date' filter.
Usage
<?php $pfx_date = get_the_date( $format, $post_id ); ?>
Parameters
$format
(string) (optional) PHP date format.
Default: the date_format option ('Date Format' on Settings > General panel)
$post
(integer) (optional) The ID of the post you'd like to fetch. By default the current post is fetched.
Default: null
Return
(string) The formatted date string
Filter
apply_filters( 'get_the_date', $the_date, $format )
Changelog
3.0.0 : New template tag.
Examples
Default Usage
<span class="entry-date"><?php echo get_the_date(); ?></span>


8)the_time()

Description
Displays the time of the current post. To return the time of a post, use get_the_time(). This tag must be used within The Loop.
Usage
 <?php the_time( $d ); ?>
Parameters
$d
(string) (optional) The format the time is to display in. Defaults to the time format configured in your WordPress options. See Formatting Date and Time.
Default: None
Examples
Default Usage
Displays the time using your WordPress defaults.
<p>Time posted: <?php the_time(); ?></p>
Time as AM/PM VS. 24H format
Displays the time using the format parameter string 'g:i a' (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_date('F j, Y'); ?> at <?php the_time('g:i a'); ?></p>



9)next_post_link()

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.
In standard usage (within the default, unaltered loop) next_post_link will generate a link to a post that is newer (more recent) than the current post. This is in contrary to the similarly-named previous_posts_link, which will typically link to a page of posts that is older than the current batch.
This tag must be used in The Loop.
Usage
<?php next_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ); ?>
Parameters
format
(string) (Optional) Format string for the link. This is where to control what comes before and after the link. '%link' in string will be replaced with whatever is declared as 'link' (see next parameter). 'Go to %link' will generate "Go to <a href=..." Put HTML tags here to style the final results.
Default: '%link &raquo;'
link
(string) (Optional) Link text to display.
Default: '%title' (next post's title)
in_same_term
(boolean) (optional) Indicates whether next post must be within the same taxonomy term as the current post. If set to 'true', only posts from the current taxonomy term will be displayed. If the post is in both the parent and subcategory, or more than one term, the next post link will lead to the next post in any of those terms.
true
false
Default: false
excluded_terms
(string/array) (optional) Array or a comma-separated list of numeric terms IDs from which the next post should not be listed. For example array(1, 5) or '1,5'. This argument used to accept a list of IDs separated by 'and', this was deprecated in WordPress 3.3
Default: None
taxonomy
(string) (Optional) Taxonomy, if $in_same_term is true. Added in WordPress 3.8.
Default: 'category'
Examples
Default Usage
Displays link with the post title of the next post (chronological post date order), followed by a right angular quote (»).
Next Post Title »
<?php next_post_link(); ?>

10)previous_post_link()

Description
Used on single post permalink pages, this template tag displays a link to the previous post which exists in chronological order from the current post.
This tag must be used in The Loop.
Arguments
<?php previous_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ); ?>
Parameters
format
(string) (Optional) Format string for the link. This is where to control what comes before and after the link. '%link' in string will be replaced with whatever is declared as 'link' (see next parameter). 'Go to %link' will generate "Go to <a href=..." Put HTML tags here to style the final results.
Default: '&laquo; %link'
link
(string) (Optional) Link text to display.
Default: '%title' (previous post's title)
in_same_term
(boolean) (optional) Indicates whether previous post must be within the same taxonomy term as the current post. If set to 'true', only posts from the current taxonomy term will be displayed. If the post is in both the parent and subcategory, or more than one term, the previous post link will lead to the previous post in any of those terms.
true
false
Default: false
excluded_terms
(string/array) (optional) Array or a comma-separated list of numeric terms IDs from which the next post should not be listed. For example array(1, 5) or '1,5'. This argument used to accept a list of IDs separated by 'and', this was deprecated in WordPress 3.3
Default: None
taxonomy
(string) (Optional) Taxonomy, if $in_same_term is true. Added in WordPress 3.8.
Default: 'category'
Examples
Default Usage
Displays link with left angular quote («) followed by the post title of the previous post (chronological post date order).
« Previous Post Title
 <?php previous_post_link(); ?>
posts_nav_link()
Description
Displays links for next and previous pages. Useful for providing "paged" navigation of index, category and archive pages.
For displaying next and previous pages of posts see next_posts_link() and previous_posts_link().
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, $nextlabel ); ?>
Note: since weblog posts are traditionally listed in reverse chronological order (with most recent posts at the top), there is some ambiguity in the definition of "next page". WordPress defines "next page" as the "next page toward the past". In WordPress 1.5, the default Kubrick theme addresses this ambiguity by labeling the "next page" link as "previous entries". See Example: Kubrick Theme Format.
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
Examples
Default Usage
By default, the posts_nav_link() look like this:
« Previous Page — Next Page »
<?php posts_nav_link(); ?>



11)post_class()

Description
WordPress theme authors who want to have finer css control options for their post styling, have the post_class function available. When the post_class function is added to a tag within the loop, for example <div <?php post_class(); ?> >, it will print out and add various post-related classes to the div tag. It can also be used outside the loop with the optional post_id parameter. This function is typically used in the index.php, single.php, and other template files that feature hierarchical post listings.
If you would prefer to have the post classes returned instead of echoed, you would want to use get_post_class(). Note: get_post_class() does not return a string, but an array that must be processed to produce text similar to what is echoed by post_class().
For css classes intended to help target entire pages, see body_class(), and for classes targeting comment listings, see comment_class().
Usage
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
The post_class may include one or more of the following values for the class attribute, dependent upon the pageview.
.post-[id]
.[post-type]
.type-[post-type]
.status-[post-status]
.format-[post-format] (default to 'standard')
.post-password-required
.post-password-protected
.has-post-thumbnail
.sticky
.hentry (hAtom microformat pages)
.[taxonomy]-[taxonomy-slug] (includes category)
.tag-[tag-name]
Default Values
The post_class CSS classes appear based upon the post pageview Conditional Tags as follows.
Front Page
If posts are found on the front page of the blog, be it static or not, the class selectors are: post post-id hentry
Single Post
Single post template files and pageviews feature the class selectors: post post-id hentry
Sticky Post
Posts designated as "sticky," sticking to the front page of the blog, feature the class selector: sticky
Author
Author template files and pageviews displaying posts feature the class selectors: post post-id
Category
Category template files and pageviews displaying posts feature the class selectors: post post-id category-ID category-name
Tags
Tag template files and pageviews with posts feature the class selectors: tag-name post post-id
Archives
Archive pageviews and pageviews with posts feature CSS classes: post post-id
Search
Search template files and pageviews with posts feature the class selectors: post post-id
Attachment
Attachment template files and pageviews feature the class selectors: attachment post post-id
Format
Posts using Post Formats feature the class selector: format-name
Parameters
How to pass parameters to tags with PHP function-style parameters
class
(string or array) (optional) One or more classes to add to the class attribute, separated by a single space.
Default: null
$post_id
(int) (optional) An optional post ID, used when calling this function from outside The Loop
Default: null
Examples
Implementation
The following example shows how to implement the post_class template tag into a theme.
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
The actual HTML output might resemble something like this for a post in the "dancing" category:
<div id="post-4564" class="post post-4564 category-48 category-dancing logged-in">
In the WordPress Theme stylesheet, add the appropriate styles, such as:
.post {
/* styles for all posts */
}
.post-4564 {
/* styles for only post ID number 4564 */
}
.category-dancing {
/* styles for all posts within the category of dancing */
}

No comments:

Post a Comment

=>SEO

1.  Syllabus 2.  Unit Wise Question/Material 3. Paper 4. Previous Paper