Switch language

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




the_date [ WordPress Function ]

the_date ( $d = '', $before = '', $after = '', $echo = true )
Parameters:
  • (string) $d Optional. PHP date format defaults to the date_format option if not specified.
  • (string) $before Optional. Output before the date.
  • (string) $after Optional. Output after the date.
  • (bool) $echo Optional, default is display. Whether to echo the date or return it.
Uses:
Returns:
  • (string|null) Null if displaying, string if retrieving.
Defined at:



Display or Retrieve the date the current $post was written (once per date)

Will only output the date if the current post's date is different from the previous one output.

i.e. Only one date listing will show per day worth of posts shown in the loop, even if the function is called several times for each post.

HTML output can be filtered with 'the_date'. Date string output can be filtered with 'get_the_date'.

Source


<?php
function the_date$d ''$before ''$after ''$echo true ) {
    global 
$currentday$previousday;
    
$the_date '';
    if ( 
$currentday != $previousday ) {
        
$the_date .= $before;
        
$the_date .= get_the_date$d );
        
$the_date .= $after;
        
$previousday $currentday;

        
$the_date apply_filters('the_date'$the_date$d$before$after);

        if ( 
$echo )
            echo 
$the_date;
        else
            return 
$the_date;
    }

    return 
null;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



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