Creating an Archives Page
02-15-2008, 01:30 PM
|
Creating an Archives Page
|
Web 2.0? What is the Web?
Posts: 1,752
Name: <member type="brilliant" alt="foolish">James Lewitzke</member>
Location: / public_html / Universe / Local_Group / Milky_Way / Solar_System / Earth / North_America / USA / Wisconsin
|
I want to display my posts to have something like this:
Quote:
- Year 1
- Year 2
- Month 1
- Post 1
- Post 2
- Post 3
- Post 4
|
All the links would be clickable, so months would give me all the posts for that month, years would give posts from each month, etc.
I already have the actual page set up, All I need to do now is edit the code, here is what my current archives.php code is:
Code:
<?php
get_header();
$alwayssidebars = get_option('royale_always_show_sidebars');
if ($alwayssidebars) {
if (get_option('royale_sidebar1_left')) include (TEMPLATEPATH . '/sidebar.php');
if (get_option('royale_3columns') && get_option('royale_sidebar2_left')) {
include (TEMPLATEPATH . '/sidebar2.php');
}
}
?>
<td id="content" class="<?php echo ($alwayssidebars ? 'narrow' : 'wide'); ?>column">
<?php if (have_posts()) : ?>
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
<?php /* If this is a category archive */ if (is_category()) { ?>
<h2 class="pagetitle"><?php printf(__('Archive for the %s Category','royale'),single_cat_title('',false)); ?></h2>
<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
<h2 class="pagetitle"><?php printf(__('Archive for %s','royale'),get_the_time(__('F jS, Y','royale'))); ?></h2>
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
<h2 class="pagetitle"><?php printf(__('Archive for %s','royale'),get_the_time(__('F, Y','royale'))); ?></h2>
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<h2 class="pagetitle"><?php printf(__('Archive for %s','royale'),get_the_time('Y')); ?></h2>
<?php /* If this is a search */ } elseif (is_search()) { ?>
<h2 class="pagetitle"><?php _e('Search Results','royale'); ?></h2>
<?php /* If this is an author archive */ } elseif (is_author()) { ?>
<h2 class="pagetitle"><?php _e('Author Archive','royale'); ?></h2>
<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
<h2 class="pagetitle"><?php _e('Blog Archives','royale'); ?></h2>
<?php } ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« '. __('Previous Entries','royale')) ?></div>
<div class="alignright"><?php previous_posts_link(__('Next Entries','royale'). ' »') ?></div>
</div>
<?php while (have_posts()) : the_post(); ?>
<div class="post">
<div class="postinfo">
<div class="cal">
<span class="cald<?php echo (get_option('royale_dates') ? ' cald2' : '') ?>"><?php the_time((get_option('royale_dates') ? 'M' : 'd')) ?></span>
<span class="calm"><?php the_time((get_option('royale_dates') ? 'd' : 'm')) ?></span>
<span class="caly"><?php the_time('Y') ?></span>
</div>
<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s','royale'),the_title('','',false)); ?>"><?php the_title(); ?></a></h3>
<small><?php printf(__('Posted by: %s in %s','royale'),'<a href="'. get_author_posts_url(get_the_author_ID()) .'" title="'. sprintf(__("Posts by %s"), attribute_escape(get_the_author())).' ">'. get_the_author() .'</a>',get_the_category_list(', ')) ?><?php edit_post_link(__('Edit','royale'), ' - '. mkicon('page_edit',__('Edit this post','royale')) .' ', ''); ?> </small>
</div>
<div class="entry">
<?php the_content() ?>
</div>
<p class="postmetadata"><?php echo mkicon('comments','Comments'); ?> <?php comments_popup_link(__('No Comments','royale'). ' »', __('1 Comment','royale'). ' »', __('% Comments','royale'). ' »'); ?></p>
</div>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« '. __('Previous Entries','royale')) ?></div>
<div class="alignright"><?php previous_posts_link(__('Next Entries','royale'). ' »') ?></div>
</div>
<?php else : ?>
<h2 class="center"><?php _e('Not Found','royale'); ?></h2>
<p class="center"><?php _e('Sorry, but you are looking for something that isn\'t here','royale'); ?>.</p>
<?php endif; ?>
</td>
<?php
if ($alwayssidebars) {
if (!get_option('royale_sidebar1_left')) include (TEMPLATEPATH . '/sidebar.php');
if (get_option('royale_3columns') && !get_option('royale_sidebar2_left')) {
include (TEMPLATEPATH . '/sidebar2.php');
}
}
get_footer();
?>
I'm not really sure what to change here. I could make out some of it, like the "get sidebar's portion, I wouldn't change that, just not sure about the other parts.
When I create the page with the above code, it gives me a search function (don't want that), a list of months (which would be edited with the new format), and it gives me an archives by subject (don't want that either).
|
|
|
|
02-17-2008, 02:07 PM
|
Re: Creating an Archives Page
|
Posts: 248
Name: Stephen
Location: Chicago, IL
|
www.learnphpfree.com/
|
|
|
|
02-17-2008, 02:46 PM
|
Re: Creating an Archives Page
|
Web 2.0? What is the Web?
Posts: 1,752
Name: <member type="brilliant" alt="foolish">James Lewitzke</member>
Location: / public_html / Universe / Local_Group / Milky_Way / Solar_System / Earth / North_America / USA / Wisconsin
|
Is something like this really too complicated for knowledgeable PHP users to help out with?
You could hypothetically post that link in every thread over in the PHP forum  .
Last edited by jamestl2 : 02-17-2008 at 02:51 PM.
|
|
|
|
02-17-2008, 11:32 PM
|
Re: Creating an Archives Page
|
Posts: 248
Name: Stephen
Location: Chicago, IL
|
Quote:
Originally Posted by jamestl2
Is something like this really too complicated for knowledgeable PHP users to help out with?
You could hypothetically post that link in every thread over in the PHP forum  .
|
Well, considering this wasn't in the coding thread that was the best answer you were gonna get. Considering posting it in the correct sub-forum and you might get the correct answer.
Might also help if you provided an output page of the code your displaying.
Last edited by ssandecki : 02-17-2008 at 11:33 PM.
|
|
|
|
02-17-2008, 11:38 PM
|
Re: Creating an Archives Page
|
Web 2.0? What is the Web?
Posts: 1,752
Name: <member type="brilliant" alt="foolish">James Lewitzke</member>
Location: / public_html / Universe / Local_Group / Milky_Way / Solar_System / Earth / North_America / USA / Wisconsin
|
Well this IS the blogging forum, and my issue is related to my blog, powered by wordpress.
I was also thinking that there might have been a better alternative to hard coding, such as a plugin I may have missed, or even someone else who has done this exact same thing for their blog.
Also, I haven't technically "Published" that page yet. The code that is displayed above is from when I give a new page the archive template.
|
|
|
|
02-18-2008, 02:38 PM
|
Re: Creating an Archives Page
|
Posts: 3,016
Name: Forrest Croce
Location: Seattle, WA
|
Quote:
Originally Posted by jamestl2
Is something like this really too complicated for knowledgeable PHP users to help out with?
|
I don't have too much php experience, and a lot of the wp hacking I've done has been less aggressive. Someone else will have to chime in with how to make the dates hierarchal.
As for why the search is showing up, you have a code block near the top starting with:
PHP Code:
if ($alwayssidebars)
It's calling out to other template files. Near the bottom, you have some 404 code.
|
|
|
|
02-18-2008, 02:47 PM
|
Re: Creating an Archives Page
|
Web 2.0? What is the Web?
Posts: 1,752
Name: <member type="brilliant" alt="foolish">James Lewitzke</member>
Location: / public_html / Universe / Local_Group / Milky_Way / Solar_System / Earth / North_America / USA / Wisconsin
|
I'm guessing to get rid of the search box, I'll have to delete all this code, right?
PHP Code:
if ($alwayssidebars) { if (get_option('royale_sidebar1_left')) include (TEMPLATEPATH . '/sidebar.php'); if (get_option('royale_3columns') && get_option('royale_sidebar2_left')) { include (TEMPLATEPATH . '/sidebar2.php'); } }
Last edited by jamestl2 : 02-18-2008 at 02:48 PM.
|
|
|
|
02-20-2008, 10:24 PM
|
Re: Creating an Archives Page
|
Posts: 3,016
Name: Forrest Croce
Location: Seattle, WA
|
Well ... do you want to include other things around it?
If I were you, I'd save the file, or copy it to the clipboard, gut that section, then see what happens. Your theme looks a bit more complicated than mine, so I'm not 100 % sure. But I kind of get the feeling you'll loose more than just your search form if you remove all of that. Maybe that's what you want, though; it's talking about pulling in files with sidebar in the name, so I'm guessing that's also the archives - useless on an archives page - categories and tags.
Probably the easiest way, if that doesn't work, would be with css and display: none. That's cheating, but ... probably better than duplicating everything for just one page.
|
|
|
|
02-20-2008, 10:32 PM
|
Re: Creating an Archives Page
|
Web 2.0? What is the Web?
Posts: 1,752
Name: <member type="brilliant" alt="foolish">James Lewitzke</member>
Location: / public_html / Universe / Local_Group / Milky_Way / Solar_System / Earth / North_America / USA / Wisconsin
|
You've probably got more php experience than I do  , so I wouldn't know what I'd be removing. I was just guessing on what to take out or not, since you posted the
if ($alwayssidebars) code.
Actually the structure I listed in the OP, I'd want in page form (as in all my sidebars, header, footer, etc. would still be there), it would just be another link in the header (along with disclaimer, home, etc.).
|
|
|
|
02-21-2008, 04:16 PM
|
Re: Creating an Archives Page
|
Web 2.0? What is the Web?
Posts: 1,752
Name: <member type="brilliant" alt="foolish">James Lewitzke</member>
Location: / public_html / Universe / Local_Group / Milky_Way / Solar_System / Earth / North_America / USA / Wisconsin
|
Alright, I was able to solve it using this plugin (I knew it was out there somewhere):
http://www.geekwithlaptop.com/projects/clean-archives/
Last edited by jamestl2 : 02-21-2008 at 06:48 PM.
|
|
|
|
|
« Reply to Creating an Archives Page
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|