Hallo zusammen,
mit dem Plugin CM RSS Post Importer Pro importiere ich den Feed des täglichen Polizeiberichtes.
Es gibt dort auch ein Titelfeld, in dem man die Überschrift festlegen kann. Nur sieht das natürlich nicht so schön aus, wenn in der URL dann irgendwann steht 'polizeibericht-134'.
Mit folgendem Code kann ich an den Titel das Datum anhängen, von dem der Feed stammt:
Code
function my_add_date_to_title($title, $id) {
// Check if we're in the loop or not
// This should exclude menu items
if ( !is_admin() && in_the_loop() && has_category('polizeibericht', $id)) {
// First get the default date format
// Alternatively, you can specify your
// own date format instead
$date_format = get_option('date_format');
// Now get the date
$date = get_the_date($date_format, $id); // Should return a string
// Now put our string together and return it
// You can of course tweak the markup here if you want
$title .= ' ' . $date ;
}
// Now return the string
return $title;
}
// 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
add_filter('the_title','my_add_date_to_title',10,2);
Alles anzeigen
Nun steht das Datum aber eben auch nur im Titel, z. B. 'Polizeibericht vom 14.02.2018' (wenn ich im Titelfeld des Plugins 'Polizeibericht vom ' eingebe.
Jemand eine Idee, wie man das Datum auch in die URL bekommt?