Hallo zusammen!
Ich bin auf der Suche nach einer Möglichkeit, das aktuelle Datum in die Überschrift eines Posts auf folgendes Snippet gestoßen:
PHP
* Adds date to end of title [COLOR=#1D2129][FONT=Helvetica]* @uses Hooked to 'the_title' filter
* @args $title(string) - Incoming title
* @args $id(int) - The post ID[/FONT][/COLOR]
[FONT=inherit]function my_add_date_to_title($title, $id) {[/FONT]
[FONT=inherit]// Check if we're in the loop or not
// This should exclude menu items
if ( !is_admin() && in_the_loop() ) {[/FONT]
[FONT=inherit]// First get the default date format
// Alternatively, you can specify your
// own date format instead
$date_format = get_option('date_format');[/FONT]
[FONT=inherit]// Now get the date
$date = get_the_date($date_format, $id); // Should return a string[/FONT]
[FONT=inherit]// Now put our string together and return it
// You can of course tweak the markup here if you want
$title .= ' (' . $date . ')';
}[/FONT]
[FONT=inherit]// Now return the string
return $title;
}[/FONT]
[FONT=inherit]// Hook our function to the 'the_title' filter
// Note the last arg: we specify '2' because we want the filter
// to pass us both the title AND the ID to our function
[/FONT]
add_filter('the_title','my_add_date_to_title',10,2);*/
Alles anzeigen
Wie könnte man das so abändern, das es nur in Artikeln erscheint, in denen man es auch haben möchte? Also in dem man quasi also ein Platzhalter verwendet.
Ich will es in meinem Regionalmagazin verwenden, um den Polizeibericht, den ich per Feed abrufe, mit dem aktuellen Datum zu versehen.