0

So I am trying to create a wordpress plugin that stores all the dates of posts written in a certain month. So if there were posts published on the 10th, 12th and 18th of this month, I want to store those dates '10', '12' and '18' in the array $stack[]. Im new to php and so I can't figure out why this isn't storing the dates in the array:

// The Query
$themonth = date( 'n', current_time( 'timestamp' ) );
query_posts('cat=4&month=' . $themonth );
// The Loop
$stack = array();
while ( have_posts() ) : the_post(); 
$stack[] = the_time('j');
endwhile;

Any ideas?

1 Answer 1

1

Change your while into this:

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

2 Comments

This seems to store the content of the post inside the array. I don't need to store the content, just the day of the month that the post was created.
So, ignore the content and just use the day in the key of the array!

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.