0

Thanks for reading firstly.

I am coding a site that requires 3 post titles for the current month and 3 post titles for the next month (upcoming events)!

I am struggling to get this to work. I am using wp_query to do this but I cannot get to work at all!

Any help would be appreciated :)

Thanks!

Just to expand on this as I might not have made myself clear!

I want to be able to show this months 3 events / posts and next months 3 events / posts - How would I do this? Please help as I am going slightly insane..

Cheers!

This is the code for the current month 3 blog title:

                <p class="blue"><?php the_time('F') ?> <span class="small">Events</span></p>

                <?php if(have_posts()) : while(have_posts()) : the_post();?>


                        <div id="date">

                            <span class="date">         
                                <?php the_time('j') ?>
                            </span>
                            <br />

                            <span class="month">
                                <?php the_time('M') ?>
                            </span> 

                        </div>  <!-- end date -->
            <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>

    <hr>


    <?php endwhile; endif; wp_reset_query(); ?>
6
  • A sample of the code you have tried should be very valuable in order to help you. Also, clarify what you are trying to do. "the site needs 3 post titles for the next month" is very unclear.
    – cybmeta
    Apr 22 '14 at 15:47
  • OK, Sorry for not being clear.
    – Tired_Man
    Apr 22 '14 at 15:48
  • I just want to show the latest three posts titles using time stamps.
    – Tired_Man
    Apr 22 '14 at 15:49
  • Can you see my code now? Thanks!
    – Tired_Man
    Apr 22 '14 at 15:54
  • "... posts from next month" - do these posts have future publish dates or do you use some custom field to store this date? Apr 22 '14 at 16:14
1

try this query_post for up to 3 posts for the current month:

$current_year = date('Y');
$current_month = date('m');
$args = array(
    'year'     => $current_year,
    'monthnum' => $current_month,
    'order'    => 'DESC',
    'posts_per_page' => 3
);
query_posts( $args );
3
  • Thanks for this, any chance you could tell me how to get 3 posts for the next month please :) Thanks again!
    – Tired_Man
    Apr 22 '14 at 16:22
  • @Ben Ask a new question on that.
    – kaiser
    Apr 22 '14 at 17:30
  • Thanks for this, I already have and it has been answered here wordpress.stackexchange.com/questions/142086/… Thanks for your help :)
    – Tired_Man
    Apr 22 '14 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.