Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




single_month_title [ WordPress Function ]

single_month_title ( $prefix = '', $display = true )
Parameters:
  • (string) $prefix Optional. What to display before the title.
  • (bool) $display Optional, default is true. Whether to display or retrieve title.
Returns:
  • (string|null) Title when retrieving, null when displaying or failure.
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($m04);
        
$my_month $wp_locale->get_month(substr($m42));
    }

    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

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics