Tag Archives: wp_get_archives()

wp_get_archives(‘type=alpha’)

Thanks to a great find. I was able to make some sweet adjustments to my site. With some modification to what JTK said on his website I used some really cool drop down boxes to achieve what I wanted on my site. I will give you the code for both.

First I wanted to make all my posts accessible on any post page. Then after I found that I could do that I found out how to make it not so obtrusive. Because if you have a lot of posts and not a lot of space on your page you don’t necessarily want the first option that JTK had.

So I found a different way and possibly a better one. If you look on my single post page you can see the top, right below adsense (two drop boxes), one with posts most recent and the other with posts alphabetized.

Anyway without further ado, THE CODE:

1
2
3
4
5
6
7
8
9
<select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> 
  <option value=""><?php echo attribute_escape(__('Pick a new post to go to! (Most recent to oldest)')); ?></option> 
  <?php wp_get_archives('type=postbypost&format=option&show_post_count=1'); ?> </select><br />
<select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
  <option value="">
   <?php echo attribute_escape(__('Pick a new post to go to! (Alphabetically A-Z)')); ?>
   </option>
  <?php wp_get_archives('type=alpha&format=option&show_post_count=1'); ?>
</select>
GD Star Rating
loading...
GD Star Rating
loading...