Changing the output of date from a custom field
-
I am working on an events page for a website I am designing with WordPress as the CMS. The date displays YYYY/MM/DD. I would like to output date like this Wednesday, March 7, 2012, not 2012/03/07.
I need to get the date in the YYYY/MM/DD format in order for the function to know how to sort and effectively stop displaying the post once the day comes. I enter this date in a custom field when creating the post. I have set up a custom post type to handle events.
I’m a noob when it comes to WordPress and PHP but here is the code I am using to output the events.
<?php if (have_posts()) : ?> <?php /* edit begin */ ?> <?php query_posts( array ( 'post_type' => 'event', 'posts_per_page' => -3, 'meta_key' => 'Date', 'meta_value' => date("Y/m/d"), 'meta_compare' => '>=', 'orderby' => 'meta_value', 'order' => 'ASC', 'paged' => get_query_var('paged') ) ); $more = 0; ?> <?php /* edit end */ ?> <?php while (have_posts()) : the_post(); ?> <div class="blogpost"> <h1 class="title" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1> <p class="post-meta"><span style="color: #168f9d">Date: </span><?php if ( function_exists('get_custom_field_value') ){ get_custom_field_value('Date', true); } ?> <?php edit_post_link('Edit this post <br />', '| ', ''); ?></p>
Like I said, I’m new to all of this so I’m feeling a little overwhelmed. Is there a way to change the date format in the call to display it? I have searched many forums and blogs to find an answer but with NO luck. I could leave the display as YYYY/MM/DD but it doesn’t look as user friendly.
- The topic ‘Changing the output of date from a custom field’ is closed to new replies.