BBBBF- Sell and Share Everything
  • Home
  • Streaming Premium Account
  • Tools Premium Account
  • Shop
  • Welfare
    • Account
    • Cracked Programs
    • Recourse
    • Amazon Affiliate
  • Digital Marketing
    • Search Engine Marketing
    • Social Media Marketing
    • Content Marketing
    • Email Marketing
Login

Displaying the Last Post Date in WordPress

8:46 am, July 15, 2024 Website Tutorial 0 0 7 0

To display the date of the last post in WordPress, you can use the get_lastpostdate() function, which retrieves the date and time of the last post in the WordPress database. Here’s how you can display it in your theme files (e.g., footer.php, sidebar.php, index.php, etc.):

<?php
$last_post_date = get_lastpostdate('gmt'); // Get the last post date in GMT timezone
if ($last_post_date) {
echo 'Last post date: ' . date('F j, Y', strtotime($last_post_date));
}
?>

Explanation:

  1. get_lastpostdate(‘gmt’): This function retrieves the date and time of the last post in the WordPress database. The ‘gmt’ parameter ensures the date returned is in GMT (UTC) timezone.
  2. date(‘F j, Y’, strtotime($last_post_date)): This formats the retrieved date ($last_post_date) into a human-readable format like “January 1, 2023”. Adjust the format ('F j, Y') to suit your preference.
  3. if ($last_post_date): This condition checks if a valid date is returned before displaying it. This helps in cases where there might not be any posts yet.
  4. echo: Outputs the formatted last post date.

Place this code where you want the last post date to appear in your theme files. Remember to wrap it in PHP tags (<?php ?>) if you’re adding it directly to a PHP file. Adjust the date format ('F j, Y') as needed to match your site’s style.

Displaying the Last Post Date
admin
Favorites Likes(0)
Previous
WordPress displays article page views
Next
How to display the latest article in wordpress

Related Articles

Website Tutorial

WordPress display the latest comment

WordPress display the latest comment <?php global $wpdb; $sql = “SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,30) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = ’1′ AND comment_type...
11 months ago 0 0 6
Website Tutorial

Register a navigation menu in WordPress

To register a navigation menu in WordPress, you’ll need to add code to your theme’s `functions.php` file. Here’s a step-by-step guide to help you through the process: 1. Open Your Theme’s `functions.php` File You can access this file through the...
11 months ago 0 0 3
Website Tutorial

How to correctly set robots.txt on WordPress website

How to correctly set robots.txt on WordPress website File header rules: The beginning of robots.txt file starts with User-agent:, which is used to specify search engine spiders. If you want to target Google search spiders, you can enter User-agent: Googlebot...
12 months ago 0 0 6
Website Tutorial

Remove category base from WordPress URL

Remove category base from WordPress URL Add the following code in functions.php add_action( ‘load-themes.php’, ‘no_category_base_refresh_rules’); add_action(‘created_category’, ‘no_category_base_refresh_rules’); add_action(‘edited_category’, ‘no_category_base_refresh_rules’); add_action(‘delete_category’, ‘no_category_base_refresh_rules’); function no_category_base_refresh_rules() { global $wp_rewrite; $wp_rewrite -> flush_rules(); } // register_deactivation_hook(__FILE__, ‘no_category_base_deactivate’); // function no_category_base_deactivate() { // remove_filter(‘category_rewrite_rules’, ‘no_category_base_rewrite_rules’);...
11 months ago 0 0 3

Comments (0)

Note: Please be respectful and civil in your comments Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Envato Elements premium free download
  • EA Sports FC 25 Ultimate Team 12000 FC Points
  • EA Sports FC 25 Ultimate Team 5900 FC Points
  • Perplexity Pro 1 Year free
  • EA Sports FC 25 Ultimate Team 2800 FC Points

Recent Comments

  1. admin on 2025 Free Netflix Premium Account Cookies
  2. MomoBz on 2025 Free Netflix Premium Account Cookies
  3. Temp Mail on EA Sports FC 25 Ultimate Team 12000 FC Points
  4. admin on 2025 Free Crunchyroll Premium Accounts
  5. INIXINTY on 2025 Free Crunchyroll Premium Accounts
BBBBF- Sell and Share Everything

Quick Navigation

About this site

Contact Us

Copyright © 2025 BBBBF - All rights reserved.Top Up Games| Buy Items
BBBBF- Sell and Share Everything