Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Do you also need to have the posts separated by year (as in the example)?

    Can you post the code you use now to show the archive links.

    Thread Starter silvine

    (@silvine)

    Code below. That would be good but I’m only online a few months.

    <?php
    
    get_header(); ?>
    
    	<section id="primary" class="site-content">
    		<div id="content" role="main">
    
    <div id="container">
    	<div id="content" role="main">
    
    		<?php the_post(); ?>
    		<h1 class="entry-title"><?php the_title(); ?></h1>
    
    			 <?php wp_get_archives('type=alpha'); ?>
    		<ul>
    			<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
      			<option value=""><?php echo esc_attr( __( 'Select Month' ) ); ?></option>
      			<?php wp_get_archives( array( 'type' => 'monthly', 'format' => 'option', 'show_post_count' => 1 ) ); ?>
    		</select>
    		</ul>
    
    	</div><!-- #content -->
    </div><!-- #container -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    Moderator keesiemeijer

    (@keesiemeijer)

    Try it with this:

    <?php
    get_header(); ?>
    
    	<section id="primary" class="site-content">
    		<div id="content" role="main">
    
    <div id="container">
    	<div id="content" role="main">
    
    		<?php the_post(); ?>
    		<h1 class="entry-title"><?php the_title(); ?></h1>
    
    <?php
    $temp_year = $temp_month = '';
    $archive = new WP_Query( 'posts_per_page = -1' );
    ?>
    
    <?php if ( $archive->have_posts() ) : while ( $archive->have_posts() ) : $archive->the_post(); ?>
    <?php
    $Year= get_the_date( 'Y' );
    $Month = get_the_date( 'F' );
    $Day = get_the_date( 'j' );
    ?>
      <?php if ( $Year != $temp_year ) : ?>
      <h2><?php echo $Year ?></h2>
      <?php endif; ?>
      <?php if ( $Month != $temp_month || $Year != $temp_year ) : ?>
      <h3><?php echo $Month; ?></h3>
      <?php endif; ?>
        <li><span><?php echo $Day; ?></span><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
      <?php
    $temp_year = $Year;
    $temp_month = $Month;
    ?>
    <?php endwhile; endif; ?>
    
    		<ul>
    			<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
      			<option value=""><?php echo esc_attr( __( 'Select Month' ) ); ?></option>
      			<?php wp_get_archives( array( 'type' => 'monthly', 'format' => 'option', 'show_post_count' => 1 ) ); ?>
    		</select>
    		</ul>
    
    	</div><!-- #content -->
    </div><!-- #container -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Changed version of this:
    http://wordpress.org/support/topic/latest-post-plus-archive-on-home-page-how?replies=12

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Need Help Setting up a Dated Archive’ is closed to new replies.