single_month_title()
Display or retrieve page title for post archive based on date.
Useful for when the template only needs to display the month and year, if either are available. The prefix does not automatically place a space between the prefix, so if there should be a space, the parameter value will need to have it at the end.
No Hooks.
Return
String|false|null
. False if there's no valid title for the month. Title when retrieving.
Usage
single_month_title( $prefix, $display );
- $prefix(string)
- What to display before the title.
Default: '' - $display(true|false)
- Whether to display or retrieve title.
Default: true
Examples
#1 A basic example.
Let's print a header for the page:
<?php single_month_title( ) ?>
The output format will be:
prefix + MONTH + prefix + YEAR
If we specify the prefix *
, we get:
*February*2004
#2 You can use html tags in the prefix:
<p><?php single_month_title('<br />') ?></p>
Output is following 2 lines.
December 2004
Notes
- Global. WP_Locale. $wp_locale WordPress date and time locale object.
Changelog
Since 0.71 | Introduced. |