Base on @Tunji answer.
You can add some conditions to the function to detect home-page, feeds…
function display_extra_title( $title, $id = null ) {
$date = the_date('', '', '', false);
if(is_home()){
$title = get_bloginfo( 'name' );
return $date . $title;
}
else{
return $date . $title;
}
}
add_filter( 'the_title', 'display_extra_title', 10, 2 );
In order to properly return the_date
and not echoing it, you must set the last parameter to false. See more details here
If you don’t want to display the date in the menu widget… You can surround $date
in a span and add css to not display it when it’s the menu, sidebar…
$title="<span class="title_date">".$date.'</span> '.$title;
In the css (adjust and add all what you need:
.sidebar .title_date{ display:none;}
Related Posts:
- Edit a function to take different actions based on user role
- get_the_author_meta( ‘ID’ ) just return 1
- How to put 2 php codes in functions.php without site crashing
- Update $wpdb query with AJAX
- Exclude category from function – PHP
- how to add custom select field to wordpress edit page
- Advance custom fields variable with if statement & Function
- How to change order inside foreach using wp_enqueue_script?
- In a foreach loop, how can I add a meta value if it doesn’t exist?
- Change header on one page in WordPress
- Restrict wordpress access to logged users only
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- Custom meta box is not displaying value showing tag as empty
- How to override theme’s public static function inside of a trait?
- How to escape echo for input tag?
- Discount in the specific product title using keyword ( Woocoommerce )
- Menu not updating for logged in users after redirect
- Delete empty title_tags, find a h1 heading and echo it
- Including user data in “new user notification email”
- I got big white screen when i attach main style sheet of Html in functions.php
- Using Javascript On Page – Header and Footer Now Missing
- Notice: Undefined variable
- Extra editor on top of default in Custom Post Type
- How do I fix Undefined variable using $_POST in function?
- Create a temporal post
- cURL needing to loop through all “next_page”
- Enqueue sripts and styles only if function is called
- Woocommerce – if selected attribute term equals
- split 1 cart item into instock and back ordered
- How to bind each “the_content” elements to a custom variables
- post_exists stops working in a scheduled event
- Permalink changes after several minutes after saving post
- how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
- Hide a specific category title from displaying on site
- Send POST request to Flask app from functions.php file
- Adding product permalink on admin order page throwing error
- Before & After Content – After Content directly below Before Content when using require_once
- How do I get the value of a current user’s custom field?
- 500 Error, Get custom field and returning it
- Adding extra data to shortcode attributes and pass it to JS with wp_localize_script
- how to use 2 index.php file One for mobile and one for desktop
- Display current user metadata on WordPress page
- How to add typehints to function in functions.php when argument is an object?
- Add Product Permalink in woocommerce admin order page
- Cannot fetch posts with certain ‘product_cat’. WP_Query is empty
- Reload page with a different shortcode when a user selects from a dropdown
- Modify post image in full size
- How to center all text body in single.php at once?
- How to link all featured images to custom url in single.php for only non-logged-in users?
- Refresh page after login with litespeed cache
- Access WP files on “server 1”, from “server 2” – using wp-load on an external website
- Pagination 404 error(I have refreshed the permalinks and tried several previous options)
- How Can I Display the Last Modified Date for User Profiles on WordPress?
- Return newly created category by code
- Unzip_file causing Media file upload error
- How to override WooCommerce Order Item Meta with data from Cart?
- JQuery modal not loading video on popup, only displaying it after multiple reopenings
- WordPress Ajax filter: Create two loops for different output styles?
- Taxonomy Child Term, Counter is staying on 0
- Add element after navigation element title don’t works like I expect
- Site title not showing. Please help me
- Get user by meta data key and velue
- Trying to publish a little bit of Javascript on the homepage AND at the bottom
- Access to “My Site” is missing from the admin bar
- Logo custom width not implementing
- Check if post visited first time
- How to redirect (301) trashed post to it’s parent taxonomy TERM ARCHIVE instead of 404 page
- Woocommerce textarea format ignored
- Where do I implement this display of User Meta Data, and how to put it in a table?
- How to auto-generate random numbers in username?
- Handling form actions in WordPress
- Remove generated category and tag class names from woocommerce product & blog listings markup
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- Allow Comments by Default for Multiple Post Types
- Cleaner ‘for each’ loop for registering scripts in functions.php
- How best to check if a user is from China and hide content?
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- How do I make comment-reply-button with that takes to comment reply form on click
- Menu to the right of screen on desktop using Bootstrap 4
- Detect what link user clicks and Redirect to a specific page for logged in users only
- WP_Query To Display Product Of Brand On Taxonomy Page
- Woocommerce Add custom “Add to cart button” in single page with tags
- Offset with ajax load more posts duplicates
- Add parent menu item in sub-menu in custom nav_walker
- custom post type column countdown
- ajaxurl usage for a custom function
- Hook into all password resets in WordPress and get password before hashing?
- How can I get my pagination loop to display the correct number of total pages?
- Get Billing Email from WooCommece Checkout and Pass to Fullstory JS
- Get posts by id using shortcode
- Is it possible to replace ‘attachment’ with another word?
- How to call a function from functions.php with ajax?
- How to delete specific element when it is not homepage?
- Add another role to a user when they click a button?
- Custom Bulk Actions handler not firing
- Using wordpress functions in class and change my code to OOP PHP
- Store custom field’s multiple values in one user meta key
- Get field in readable word
- Set user status to absent on WordPress
- Shortcode’s output to use as other shortcode’s parameter