• Hi,

    I want to modify the archives widget.

    By default it’s one dropdown containing all the months.

    I’d like to have one dropdown for each year.

    I’m really not sure how i go about this and which files to modify.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • This can be done easier and without a plugin – just use the Links widget…First create a new Link category, then create the links in form: yoursite.com/year/
    An example at my site is in footer at “SOME SITES I BUILT AND HOST” (of using Links and it’s widget)
    …or just use a text widget and hard code the HTML.

    Update with new link each year.

    Thread Starter onebitrocket

    (@onebitrocket)

    Thanks for your help, but it wasn’t the solution I was looking for.
    I did find a fix though which I’m still working on.

    Eventually I want a function that will recognise if the checkbox in the archive widget has been checked and then replace the standard widget select area width the code below.

    <ul>
    <?php
    /**/
    $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date)
    FROM $wpdb->posts WHERE post_status = 'publish'
    AND post_type = 'post' ORDER BY post_date DESC");
    foreach($years as $year) :
    ?>
    
    <li>
    <label><?php echo $year; ?></label>
    
    	 <select  name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
    
            <?php $months = $wpdb->get_col("SELECT DISTINCT MONTH(post_date)
            FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post'
            AND YEAR(post_date) = '".$year."' ORDER BY post_date DESC");
            foreach($months as $month) :
            ?>
    
    	<option value="<?php echo get_month_link($year, $month); ?>">
    
                <?php echo date( 'F', mktime(0, 0, 0, $month) );?>
    
                </option>
    
            <?php endforeach;?>
    	    </select>
    
    </li>
    <?php endforeach; ?>
    
    </ul>

    It may have helped if your end result was stated in the OP. What I suggested does and would work well for most without coding.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘archive dropdown for each year’ is closed to new replies.