0

I need to return an array of post dates in wordpress. So basically if I have 10 posts in wordpress, I need to create an array that will return the date that each of the tens posts were created. I don't need the list to be ordered nor contain any other content. Pretty simple right?!

Something like this:

$myarray = array();
query_posts();
// The Loop         
while ( have_posts() ) : the_post();
   $my_array = the_time('j');
endwhile;

I have attempted many different methods to accomplish this but they have all more or less failed. Any ideas?

1 Answer 1

1

You are using the_time which does not return anything which is to display output directly.

use get_the_time()

while ( have_posts() ) : the_post();
   $my_array[] = get_the_time('j');
endwhile;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.