Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7966975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:34:36+00:00 2026-06-04T06:34:36+00:00

I have a custom query in WordPress that is pulling a time assigned to

  • 0

I have a custom query in WordPress that is pulling a time assigned to a post item in a custom meta field. The times are entered in the following format:

1:00am, 2:00am, 1:00pm, 2:00pm, 3:00pm, etc

The query displays the posts in order of this time, however, its displaying them out of order, like this:

1:00am, 1:00pm, 2:00am, 2:00pm, 3:00am, 3:00pm, etc.

I need it to display them in the proper order, like this: 1:00am, 2:00am, 3:00am….11:00am, 12:00pm, 1:00pm, 2:00pm, 3:00pm, etc

I thought about simply switching to a 24 hour clock, but some users are not familiar with it.

Here is my query, can someone help me with a solution:

<ul>
<?php
$args=array(
  'taxonomy' => 'day',
  'term' => 'monday',
  'post_type' => 'schedule',
  'meta_key' => 'tr_show_time', 
  'orderby' => 'tr_show_time', 
  'order' => 'asc',  
  'posts_per_page' => 24,
  'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
      <?php $show_name = get_post_meta( get_the_ID(), 'tr_show_name', true ); ?>
      <?php $show_time = get_post_meta( get_the_ID(), 'tr_show_time', true ); ?>
      <li>
        <?php echo $show_time;?> - <?php echo $show_name;?>
      </li>
      <?php endwhile; } wp_reset_query(); ?>
</ul>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:34:38+00:00Added an answer on June 4, 2026 at 6:34 am

    I ended up using jQuery to solve this as, personally, I found it easier to do than in PHP.

    I used this script and the following code:

    http://benalman.com/projects/jquery-replacetext-plugin/

    $("#whats-on-container *").replaceText( /00:00/gi, "12:00am" );
    $("#whats-on-container *").replaceText( /01:00/gi, "1:00am" );
    $("#whats-on-container *").replaceText( /02:00/gi, "2:00am" );
    $("#whats-on-container *").replaceText( /03:00/gi, "3:00am" );
    $("#whats-on-container *").replaceText( /04:00/gi, "4:00am" );
    $("#whats-on-container *").replaceText( /05:00/gi, "5:00am" );
    $("#whats-on-container *").replaceText( /06:00/gi, "6:00am" );
    $("#whats-on-container *").replaceText( /07:00/gi, "7:00am" );
    $("#whats-on-container *").replaceText( /08:00/gi, "8:00am" );
    $("#whats-on-container *").replaceText( /09:00/gi, "9:00am" );
    $("#whats-on-container *").replaceText( /10:00/gi, "10:00am" );
    $("#whats-on-container *").replaceText( /11:00/gi, "11:00am" );
    $("#whats-on-container *").replaceText( /12:00/gi, "12:00pm" );
    $("#whats-on-container *").replaceText( /13:00/gi, "1:00pm" );
    $("#whats-on-container *").replaceText( /14:00/gi, "2:00pm" );
    $("#whats-on-container *").replaceText( /15:00/gi, "3:00pm" );
    $("#whats-on-container *").replaceText( /16:00/gi, "4:00pm" );
    $("#whats-on-container *").replaceText( /17:00/gi, "5:00pm" );
    $("#whats-on-container *").replaceText( /18:00/gi, "6:00pm" );
    $("#whats-on-container *").replaceText( /19:00/gi, "7:00pm" );
    $("#whats-on-container *").replaceText( /20:00/gi, "8:00pm" );
    $("#whats-on-container *").replaceText( /21:00/gi, "9:00pm" );
    $("#whats-on-container *").replaceText( /22:00/gi, "10:00pm" );
    $("#whats-on-container *").replaceText( /23:00/gi, "11:00pm" );
    $("#whats-on-container *").replaceText( /24:00/gi, "12:00am" );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query in WordPress to call custom post meta, everything is
I have a custom SQL query that I run with this line: @avg_score =
I have a custom post type called song and i want to query the
I have a multiple pages in wordpress all with a single custom field called
I have setup a custom Post Type in WordPress and have a question. How
I am having some trouble pulling multiple custom post types from a Custom Wordpress
I have a similar problem with this ( https://wordpress.stackexchange.com/questions/9593/custom-post-type-archive-with-pagination ) and can't really figure
Inside phpMyAdmin, I am working with custom meta fields in WordPress. Say I have
I have 100 property listings as wordpress posts and each post has two custom
I have a small problem on a wordpress custom post type page, whereby the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.