I am very new in WP, I want to change the title display on the portal to show also the post date in brackets using a filter ? how can I do it ? when I try this (solution of @Dre) ; I get also date with the top menu:
function my_add_date_to_title($title, $id) {
$date_format = get_option('date_format');
$date = get_the_date($date_format, $id); // Should return a string
return $title . ' (' . $date . ')';
}
add_filter('the_title','my_add_date_to_title',10,2);
You'd probably be better off editing your page templates to simply output the date; it's quicker and makes it much more obvious and easier to find later on. Apply content via filters can make it harder to tracker down where content is coming from.
Having said that, if you're determined to do it via filters, here's what you'd need to add to your
functions.php
file:Not tested, but should work.