You should use WordPress conditionals to determine which page you’re on, build the title based on that, then print the title.
<?php
$sep = ' | ';
$name = get_bloginfo( 'name' );
if( is_home() || is_front_page() )
$title = $name . $sep . get_bloginfo( 'description' );
if( is_single() || is_page() )
$title = wp_title( $sep, false, 'right' ) . $name;
if( is_category() )
$title = single_cat_title( '', false ) . $sep . $name;
if( is_day() )
$title="Post for the day " . get_the_date( 'j F, Y' ). $sep . $name;
if( is_month() )
$title="Post for the month " . get_the_date( 'F, Y' ). $sep . $name;
if( is_year() )
$title="Post for the year " . get_the_date( 'Y' ). $sep . $name;
?>
<title><?php echo $title;?></title>
Related Posts:
- wordpress is_front_page() issue
- Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
- Sanitizing integer input for update_post_meta
- Meta compare with date (stored as string) not working
- How to update/insert custom field(post meta) data with wordpress REST API?
- Front-end update_post_meta snippet displays white screen?
- How to get meta value in wp_attachment_metadata
- Clean up output added via wp_head()
- How to check if current static page is frontpage from admin plugin
- get_post_custom()
- Get post from meta_key and meta_value
- get_post_meta returns bool(false)
- How do I make my single-work page show on my front-page.php?
- is_home() in HTML head
- How to get custom post type to display post meta on archive pages?
- Mass importing json data into custom fields (postmeta)
- WP_POSTMETA changes site crash
- meta_post_meta return value 1
- How to use post_id with a Class?
- get_post_meta remains empty while looping all menu items and using the ID
- Set default Custom Post Meta Value
- INSERT ON DUPLICATE KEY UPDATE failes in postmeta table
- Set Checkbox as checked by default
- replacing the_autor or make callback
- Some post meta fields stop saving after a few successful saves
- update_post_meta saves nothing in database when run in publish_post
- Save an array of values in the post meta box
- Compare meta_query with a Regular Expression and do a less-than operation on it
- get_post_meta() empty in preview WHEN custom post is published [closed]
- Add Embed.ly API objects to post_meta on update
- Editing does not change post_name
- Compare string with post id in wpdb and do stuff when match is found
- $wpdb class updating meta_value using Ajax [closed]
- Is it possible to retrieve a post and its metadata at the same time?
- Display post details by post ID
- Post meta as array looks like string instead of array
- How to selected which tags to print, instead of printing the whole tag list?
- query posts and split meta information into separate div’s
- How to test the outcome of a wpdb query?
- add unique string as custom-field to every post
- How do I insert a new meta key / value pair, but only if another meta key is present?
- “Cannot use import statement outside a module” JS error while adding a custom meta block?
- Gutenberg featured image checkbox – checkbox not correctly set on editing page reload
- How to properly use oneOf and anyOf in Rest Schema?
- Get the author meta adds now
- Is there a way to disable post meta caching for development?
- Accidentally deleted the ‘home’ page as my front page, can someone help?
- show ad after # paragraphs
- If ACF meta_key has meta_value
- How we can get “get_post_meta” of specific user who added it
- Repeated nav bar queries failing to be cached
- Randomizing Post Links Outside of Loop – No Author or Date
- help to decipher wp metadata
- Display current ranking of post as a number in post title
- Insert Custom Field Value
- delete duplicates wp_postmeta
- SQL query – get a featured image’s alt / alternative text
- I can not display meta value in extras.php and template-tags.php
- update_post_meta() updating nested array in Multidimensional array with empty sub-array
- How do I list taxonomies that have upcoming events in WP? Is there a way to do this without having to query posts first?
- Sorting my posts on homepage my specific value in post_meta table
- Strict comparisons problem when using boolean post meta
- Why is the actual number of thumbnail images not matching what is store in an attachments metadata?
- How to show taxonomy on front page
- update_post_meta() is not saving the value
- Only show meta on one post type on search results page
- Check if any meta on the post has value then display content
- Combine meta query and give a specific meta query a higher priority
- Can we have duplicate key pair values in post meta data?
- Meta data being pulled from wp-login.php
- Get table parameter and save in meta value
- How can i show post views using specified post ID?
- How to add/update post meta to use in query?
- Get post content before rendering
- gettext localization is not working
- Move Entry Meta Above Title in Archives (Genesis + Brunch Pro)
- Update Post metafield of specific categories
- Multiple postmeta values to the same post_id/meta_key combination?
- get_post_meta not work in php foreach
- Why are my custom metaboxes not updating the post meta?
- Problem serializing single quote and double quote into post meta
- Storing post_meta fields in array
- Performace on 1 million plus meta fields vs 1 field with 1 million multi array
- Fetching array of postmeta with $wpdb and in_array conditional
- Piklist File Upload
- php wp_insert data on front using a form
- Updating post_meta when updating a setting with the Settings API
- How to show specific meta keys of all posts in admin panel?
- Use page.php for front page
- how to echo/display the custom field value in specific custom field name?
- update_post_meta() not working in bulk option
- 3 x 3 grid of posts on the home page
- How to update the ‘modified_time’ of a post ONLY when content is changed?
- Multiple If else statements on Search Result Page
- How to make certain content of the post noindex and no follow. not entire post?
- get_children filter with postmeta
- What is the advantage of using home.php over index.php for the front page
- How to access the so called “Posts page”
- How to wrap image logo in Homepage with H1 tag
- Save frontend submission form field as custom field