Hi @drreen,
That’s indeed possible ??
It will only work if your theme is outputting the title correctly, or when the title has been fixed through the Title Fix extension.
This is what the code will look like, you can ignore the 2nd and 3rd parameters ($args
and $escape
).
add_filter( 'the_seo_framework_pro_add_title', 'my_pro_title_alterations', 10, 3 );
/**
* Alter title after it has been processed.
*
* @param string $title The current title.
* @param array $args The title args
* @param bool $escape Whether the title is being escaped in this call.
* @return string The full title.
*/
function my_pro_title_alterations( $title = '', $args = array(), $escape = true ) {
//* If it's a post:
if ( is_single() ) {
// You can change 'F' with any of these date codes:
// @link https://php.net/manual/en/function.date.php
$title = get_the_date( 'F' ) . ' - ' . $title;
}
//* If it's a page:
if ( is_page() ) {
// Code here
}
//* If it's an archive:
if ( is_archive() ) {
// Code here
}
//* If the current Post ID is 3
// Don't use get_the_ID as it can cross with archives.
if ( 3 === get_queried_object_ID() ) {
// Per your request, with i18n support:
$title = date_i18n( 'F', true, false ) . ' - ' . $title;
}
return $title;
}
If you have any questions, feel free to ask! Cheers ??
Edit: After re-reading your request, I’ve updated the code snippet.
-
This reply was modified 8 years, 1 month ago by
Sybre Waaijer.
-
This reply was modified 8 years, 1 month ago by
Sybre Waaijer. Reason: Typo in code