Skip to main content
added 1777 characters in body
Source Link

The code for the homepage looks like this:

<div id="news_content">
    <div id="header_line_news">
        <h2>Nieuws</h2>
    </div>
    <div id="news_content_inner">
<?php query_posts('post_type=' . $post_types . '&posts_per_page=3&orderby=date'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
    <div class="nieuws_text">
    <?php echo do_shortcode( '[hupso]' );?>
    <div class="date_post">
        <?php the_date(); ?>
    </div>
    <h2><?php the_title(); ?></h2>
    <div class="text_holder">
        <div class="img_center_index">
            <?php the_post_thumbnail();?>
        </div>
        <p><?php the_excerpt(); ?></p>
    </div>
        <hr>
    </div>
        <?php endwhile; endif; wp_reset_postdata(); ?>
        <div id="meer_berichten">
            <input type="button" class="meer_berichten" onClick="parent.location='<?php echo $link."berichten";?>'" value="Meer berichten">
        </div>
    </div>
</div>

The code for the 'all posts' page looks like this:

<div id="content">
    <div id="header_line_news">
        <h2>Alle berichten</h2>
    </div>
    <div id="content_overons">
        <?php 
        $years = $wpdb->get_results( "SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY year DESC" );
        foreach ( $years as $year ) {
            $posts_this_year = $wpdb->get_results( "SELECT ID, post_title FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' AND YEAR(post_date) = '" . $year->year . "'" );
            echo '<h2>' . $year->year . '</h2>';
            echo '<ul>';
                foreach ( $posts_this_year as $post ) {
                // Display the title as a hyperlinked list item
                echo '<li><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a>'.the_time('d F').'</li>';
                }
            echo '</ul>';
        }
        ?>
    </div>

The code for the homepage looks like this:

<div id="news_content">
    <div id="header_line_news">
        <h2>Nieuws</h2>
    </div>
    <div id="news_content_inner">
<?php query_posts('post_type=' . $post_types . '&posts_per_page=3&orderby=date'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
    <div class="nieuws_text">
    <?php echo do_shortcode( '[hupso]' );?>
    <div class="date_post">
        <?php the_date(); ?>
    </div>
    <h2><?php the_title(); ?></h2>
    <div class="text_holder">
        <div class="img_center_index">
            <?php the_post_thumbnail();?>
        </div>
        <p><?php the_excerpt(); ?></p>
    </div>
        <hr>
    </div>
        <?php endwhile; endif; wp_reset_postdata(); ?>
        <div id="meer_berichten">
            <input type="button" class="meer_berichten" onClick="parent.location='<?php echo $link."berichten";?>'" value="Meer berichten">
        </div>
    </div>
</div>

The code for the 'all posts' page looks like this:

<div id="content">
    <div id="header_line_news">
        <h2>Alle berichten</h2>
    </div>
    <div id="content_overons">
        <?php 
        $years = $wpdb->get_results( "SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY year DESC" );
        foreach ( $years as $year ) {
            $posts_this_year = $wpdb->get_results( "SELECT ID, post_title FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' AND YEAR(post_date) = '" . $year->year . "'" );
            echo '<h2>' . $year->year . '</h2>';
            echo '<ul>';
                foreach ( $posts_this_year as $post ) {
                // Display the title as a hyperlinked list item
                echo '<li><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a>'.the_time('d F').'</li>';
                }
            echo '</ul>';
        }
        ?>
    </div>
Source Link

Date is wrong on 'all posts' page

The website i'm working on has a homepage with posts and at the end of the page a button with view more posts.

When I click that button it sends me to 'all posts'.

On this page I have a problem, the date for the post is wrong.

If you visit: http://www.solarboatleeuwarden.nl/test/berichten/ You can see that every date is set to 30 november. This is either for 2013 and for 2014.

What could be the problem? it's not a problem with my database because the dates on the frontpage are right.