get_the_date
must be used inside the Loop. For outside the loop use get_the_time
.
$posts = get_posts(array('numberposts'=>-1)); //Get all published posts
foreach ($posts as $post){
echo get_the_time('Y-m-d', $post->ID); //Echos date in Y-m-d format.
}
Consider replacing 'Y-m-d'
in this example with get_option('date_format')
as this will display the date as per your date format setting in wp-admin.
Related Posts:
- wpdb update add current timestamp not working
- Bulk Updating Post Date in 1 day Increments
- SELECT rows between two datetimes when the range is dynamic [closed]
- Removing old_slug and old_date from WordPress Database
- How to resolve ORA-011033: ORACLE initialization or shutdown in progress
- Oracle SQL query for Date format
- Failed to connect to mysql at 127.0.0.1:3306 with user root access denied for user ‘root’@’localhost'(using password:YES)
- Can I have multiple primary keys in a single table?
- Using wpdb to connect to a separate database
- MariaDB as a backend database
- What is the purpose of the option name hack_file in the options table?
- WordPress database error with latest WP – “WP_termmeta doesn’t exist”
- WordPress Connection Pooling
- WordPress database error: [Query was empty] [closed]
- How to reset the post ID increment
- What is the fastest way to generate a unique id number when registering a user
- How best to inject ads between posts in the loop?
- Cloning and syncing a WordPress website
- How to execute mulitple statement SQL queries using $wpdb->query?
- Store and Encrypt Contact Form 7 Submissions in Database? [closed]
- Does thumbnail regeneration edit the database?
- Clean database from unused tables
- How wordpress accesses its own database
- Using table lock with wp_insert_post?
- Migrating database / content of non-CMS site to WordPress
- Should I remove transients from the wp_options table?
- WordPress doesn’t show all posts in database
- Show last modified date of database
- Are custom tables in the database overwritten when WordPress is updated to new versions?
- What is the proper way to validate and sanitize JSON response from REST API?
- What generates these very slow postmeta queries? [closed]
- How to migrate a website based on a custom database to wordpress?
- How do I get the posts within a certain year/date(with sql query)?
- batch UPDATE autoload value in wp_options table
- Displaying BLOB PDF File
- Data storage for JS app using WP REST API
- How to scan barcode and store data into a database [closed]
- Fetching values from database for select box
- WP CLI Core install – blank database
- Update from 4.5 to 4.6 failing
- Setup 3 Sites To Connect To 1 Database and Share Data
- fastest replacement DB
- Does auto_load to ‘no’ in wp_options improve performance
- Call to undefined function get_user_meta() – trying to access data in MySQL from custom fields
- When to use custom DB tables or add_option?
- Have working sql query… trying to adjust it to use $wpdb
- Best host for running large mem and processor intensive WordPress sites?
- Will there be any concern if I upgrade my current WordPress Database server from Centos 7 Mariadb 5.5 to Centos 8 Mariadb 10.3?
- In which format the data is stored in WordPress Databases?
- Strange characters added to the database
- Is it possible to rebuild the website while not accesseing the original database?
- Error message on blog posts only on my local environment [closed]
- how to read database fields
- $wpdb->query can’t insert data
- Database Update Required – Update from command-line
- Can you refresh ONLY the wordpress adminbar and not the whole page?
- After database migration, theme mods don’t show [closed]
- Remote database connection and local development
- How can I detect right db type?
- Add search bar to Custom Database Table in WordPress Dashboard
- Custom search query by category id
- Design problems when exporting remote database for local development
- Website displays old version of page
- Image link issues after importing a database backup to my local web server
- multiple wordpress installs w/shared user database but separate content databases
- A change in URL slug in database returns 404, how can I do auto-redirect?
- Updating seperate database when post attachment is changed
- add featured image dialog box disappear
- Displaying table data on a page
- muliple wordpress installs (network) on different databases
- WordPress Database – wp_usermeta and the correct number of session_tokens rows
- Continuous SQL query errors from outside source
- How to get a list of articles related to a particular category from my other WordPress website?
- Whats the best practise on how to store json data from a custom settings page?
- Recovery – Restore Database after moving folder location locally
- Migrate Users From laravel to wordpress
- /wp-admin not accessible after migrating to local host (no plugin issue)
- Job and Employee Performance Tracking with Product Safety
- how add more field to wp user and save it to database
- set_transient fails if the value has more than 60.000 characters
- How do I cleanup my database with data that is no longer being used?
- Set SQL_BIG_SELECTS and MAX_JOIN_SIZE on a WP_Query
- How to optimize wp_option table?
- How can I get $wpdb to show MySQL warnings?
- About wp database hooks (error establishing connection)
- How to display $wpdb->insert_id; value on redirected page
- Database for JQuery Autocomplete field
- Create Tables in WordPress
- Catchable fatal error in formatting.php
- Wrong url for the images while using same database for two WordPress installations
- WordPress Failed to Login (DB Error)
- Sending WordPress database information to cross domain the safe way?
- Database Name Change
- Share WordPress Database
- Where To Find bb_profile_data(); In bbPress?
- ERROR: “Table Prefix” must not be empty
- How do you build a database-centric site in WP?
- WordPress: Interact with Database Query Data and Login
- Attach posts based on category and position
- Getting an error when trying to migrate to DV server from Grid with Media Temple [closed]