WordPress.org

Ready to get started?Download WordPress

Forums

WP upside down (5 posts)

  1. boldt
    Member
    Posted 5 years ago #

    I want to use WP as an event calendar where the categories are different departments and the posts are the events.

    The publish-date will be the start date of the event and I have installed the plugin:"No Future Posts", so all my posts are shown.

    Now I want to turn the pile of posts upside down.
    today the list of posts on a page is shown with the youngest on top and the oldest in the bottom, but because I want to look in to the future, the oldest should be on the top.

    Moreover, the opening list should start with the first event closest to the actual time.

    Is this possible with some looping or shall I create a plugin?

    Any Ideas???

    kind regards

    Mikael Boldt

  2. krembo99
    Member
    Posted 5 years ago #

  3. boldt
    Member
    Posted 5 years ago #

    Thanks, the first step was quite easy:

    in my theme index.php

    <div id="content">
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="post">
    <h2>" title="<?php the_title(); ?>"><?php the_title(); ?></h2>
    ...

    I added the line query_posts

    <div id="content">
    <?php query_posts('order=ASC'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="post">
    <h2>" title="<?php the_title(); ?>"><?php the_title(); ?></h2>
    ...

    The next problem is to start the list with the first event closest to the actual time.

  4. krembo99
    Member
    Posted 5 years ago #

    <?php $current_month = date('m'); ?>
    <?php $current_year = date('Y'); ?>
    
    <?php query_posts("cat=22&year=$current_year&monthnum=$current_month&order=ASC"); ?>
    <!-- put your loop here -->

    try this (just change categories to what you want)

  5. boldt
    Member
    Posted 5 years ago #

    ohh
    it is soo simple

    I love WP

Topic Closed

This topic has been closed to new replies.

About this Topic