Title: Show date
Last modified: September 19, 2023

---

# Show date

 *  Resolved [janwill](https://wordpress.org/support/users/janwill/)
 * (@janwill)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/show-date-8/)
 * Hi, sorry for my english. I will do my best.
 * I use a custom loop in the functions.php (for a custom shortcode) to show the
   last posts from a certain category. With your plugin, I will change the category
   from a post on certain date – thats working fine.
 * BUT
   How can I show this special date in my loop in the functions.php?I will show
   the expire date, which I settting with your plugin….
 * like
 *     ```wp-block-code
       <?php
           $args = array(
           'post_type'      => 'post',
           'category_name'  => 'dogs',
           'posts_per_page' => 2,
       );
           $query = new WP_Query( $args );
       ?>
   
       <?php if ( $query->have_posts() ) : while ( $query-> have_posts() ) : $query-> the_post(); ?>
   
       <p class="date">
   
       <?php SHOW_EXPIRE_DATE ?></p> 
   
       <?php
           endwhile;
        wp_reset_postdata();
       endif;  
       ?>
       ```
   
 * Do you can help me?
   janwill

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Thread Starter [janwill](https://wordpress.org/support/users/janwill/)
 * (@janwill)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/show-date-8/#post-17063967)
 * hmmmm I have found this snippet but this will show not a right date:
 *     ```wp-block-code
       	 <?php echo get_post_meta( get_the_ID(), '_expiration-date', true);  ?>
       ```
   
 * For a test I have set the expire date of 21.09.2023 but in the table there are:
 *     ```wp-block-code
       1695331200
       ```
   
 *  Thread Starter [janwill](https://wordpress.org/support/users/janwill/)
 * (@janwill)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/show-date-8/#post-17063988)
 * Ahhhhhh
 *     ```wp-block-code
       <?php echo do_shortcode('[postexpirator type=date]'); ?>
       ```
   
 * 🙂 Thx for help 🙂
 *  Plugin Support [Riza Maulana Ardiyanto](https://wordpress.org/support/users/rizaardiyanto/)
 * (@rizaardiyanto)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/show-date-8/#post-17064728)
 * Hi [@janwill](https://wordpress.org/support/users/janwill/)
 * I’m glad your found the solution already.
 * For other users that facing the same issue, this is relevant documentation: [https://publishpress.com/knowledge-base/shortcodes-to-show-expiration-date/](https://publishpress.com/knowledge-base/shortcodes-to-show-expiration-date/)
 * Thanks,
 *  Thread Starter [janwill](https://wordpress.org/support/users/janwill/)
 * (@janwill)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/show-date-8/#post-17064903)
 * thxy 🙂
 * But I have another question:
 * I´m planning to change the category by a date from your plugin – that`s fine 
   and ist working. Now, after change the category, I`m planning to show the posts,
   after a certain time, on another page with another WP_Query-Loop and order (‘
   meta_key’ => XXX) this posts with the expired date before.
 * But I can´t find the expired date in the table AFTER the plugin is change the
   category…
 * DO you know what I mean and do you can help me?
 * janwill
 *  Plugin Author [andergmartins](https://wordpress.org/support/users/andergmartins/)
 * (@andergmartins)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/show-date-8/#post-17066967)
 * [@janwill](https://wordpress.org/support/users/janwill/) we don’t store the expiration
   date in the metadata after a post has expired, but you can use an action that
   is triggered when that happens, before the data is deleted. You could then grab
   the date and store in a different metadata.
   You can try something like this:
 *     ```wp-block-code
       add_action('publishpressfuture_post_expired', function ($postId) {
           $actionDate = (int)get_post_meta($postId, '_expiration-date', true);
   
           update_post_meta($postId, '_last_expiration_date', $actionDate);
       });
       ```
   
 *  Thread Starter [janwill](https://wordpress.org/support/users/janwill/)
 * (@janwill)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/show-date-8/#post-17089898)
 * Hi, many thx for help. This snippet worked well but I have another quistion for
   this:
 * How can I show the new custom field “_last_expiration_date” in the frontend like
   the field “_expiration_date”? For “_expiration_date” I use
 * [postexpirator type=date]
 * But how can I use this shortcode for the new custom fiel to show the date?
 * br
 * janwill
 *  Thread Starter [janwill](https://wordpress.org/support/users/janwill/)
 * (@janwill)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/show-date-8/#post-17090385)
 * Hi there,
 * I could find a solution but I need one change in your code. How can I change 
   your code
 *     ```wp-block-code
       add_action('publishpressfuture_post_expired', function ($postId) {
           $actionDate = (int)get_post_meta($postId, '_expiration-date', true);
   
           update_post_meta($postId, '_last_expiration_date', $actionDate);
       });
       ```
   
 * so the value of your custom field `_expiration-date` is copy to `_last_expiration_date`
   AND in another custom field `_last_expiration_date_NEW` but here with the right
   date output: **d.m.Y H:i**?
 * I need this for a custom query for the Plugin Search and Filter PRO, so I can
   filter the posts in the pasts… Do you can help me?
 * By the Way is it possible to change your custom field, so that the date is not
   save in UNIX but in normal date format, or is this to complex?
 * janwill
 *  Plugin Author [andergmartins](https://wordpress.org/support/users/andergmartins/)
 * (@andergmartins)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/show-date-8/#post-17094036)
 * Hi [@janwill](https://wordpress.org/support/users/janwill/) 
   Cool, sure thing.
   You can try the following code. I left both formats, UNIX time, and your custom
   format. You can remove or customize according to your need.
 *     ```wp-block-code
       add_action('publishpressfuture_post_expired', function ($postId) {
           $actionDate = (int)get_post_meta($postId, '_expiration-date', true);
   
           update_post_meta($postId, '_last_expiration_date', $actionDate);
           update_post_meta($postId, '_last_expiration_date_NEW', gmdate("d.m.Y H:i", $actionDate));
       });
       ```
   

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Show date’ is closed to new replies.

 * ![](https://ps.w.org/post-expirator/assets/icon-256x256.png?rev=3569472)
 * [Schedule Post Changes With PublishPress Future: Unpublish, Delete, Change Status, Trash, Change Categories](https://wordpress.org/plugins/post-expirator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-expirator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-expirator/)
 * [Active Topics](https://wordpress.org/support/plugin/post-expirator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-expirator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-expirator/reviews/)

 * 8 replies
 * 3 participants
 * Last reply from: [andergmartins](https://wordpress.org/support/users/andergmartins/)
 * Last activity: [2 years, 8 months ago](https://wordpress.org/support/topic/show-date-8/#post-17094036)
 * Status: resolved