single_month_title [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
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. Optimized for just this purpose, so if it is all that is needed, should be better than {@link wp_title()}.
It does not support placing the separator after the title, but by leaving the prefix parameter empty, you can set the title separator manually. 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.
Source
<?php
function single_month_title($prefix = '', $display = true ) {
global $wp_locale;
$m = get_query_var('m');
$year = get_query_var('year');
$monthnum = get_query_var('monthnum');
if ( !empty($monthnum) && !empty($year) ) {
$my_year = $year;
$my_month = $wp_locale->get_month($monthnum);
} elseif ( !empty($m) ) {
$my_year = substr($m, 0, 4);
$my_month = $wp_locale->get_month(substr($m, 4, 2));
}
if ( empty($my_month) )
return false;
$result = $prefix . $my_month . $prefix . $my_year;
if ( !$display )
return $result;
echo $result;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/single month title « WordPress Codex
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 passed by ...
codex.wordpress.org - WordPress › Support » single_month_title() is without whitespace
When I use single_month_title() I get "January2004" without space between the month and year. I searched the files but could only find the smarty version of this ...
wordpress.org - WordPress › Support » permalinks break single_month_title
Now as a result, single_month_title returns nothing (it was working fine before). Any know why or have an alternative tag I can use to put the month & year at the ...
wordpress.org - WordPress › Support » No single_month_title in #more text
For each page (wether category or month) I have a title on top of the page by using either single_month_title() or single_cat_title. But when clicking on the ' more.
wordpress.org
Gebruikersdiscussies [ wordpress.org ]
- athique on "Displaying titles for Archive Pages and Categories"
- moshu on "Displaying titles for Archive Pages and Categories"
- athique on "Displaying titles for Archive Pages and Categories"
- moshu on "Displaying titles for Archive Pages and Categories"
- athique on "Displaying titles for Archive Pages and Categories"
- athique on "Displaying titles for Archive Pages and Categories"
- moshu on "Displaying titles for Archive Pages and Categories"
- athique on "Displaying titles for Archive Pages and Categories"