Archive.php file to function display page blog archives. Usability archive is placed posts to the group. Archive blog posts can be archived per month, the archive posts per category or archive tags.
The principle of making the same file archive.php index.php file is a file called header.php, sidebar.php and footer.php. The difference found on the content presented. The following codes are used to create the file archive.php.
<?php get_header(); ?>
<div id="content">
<?php if (have_posts()) : ?>
<?php $post = $posts[0];?>
<?php if (is_category()) { ?>
<h2><?php printf(__('Archive for the ‘%s’ Category'), single_cat_title('', false)); ?></h2>
<?php } elseif( is_tag() ) { ?>
<h2><?php printf(__('Posts Tagged ‘%s’'), single_tag_title('', false) ); ?></h2>
<?php } elseif (is_day()) { ?>
<h2><?php printf(_c('Archive for %s|Daily archive page'), get_the_time(__('F jS, Y'))); ?></h2>
<?php } elseif (is_month()) { ?>
<h2><?php printf(_c('Archive for %s|Monthly archive page'), get_the_time(__('F, Y'))); ?></h2>
<?php } elseif (is_year()) { ?>
<h2><?php printf(_c('Archive for %s|Yearly archive page'), get_the_time(__('Y'))); ?></h2>
<?php } elseif (is_author()) { ?>
<h2><?php _e('Author Archive'); ?></h2>
<?php } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
<h2><?php _e('Blog Archives'); ?></h2>
<?php } ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link(__('« Older Entries')); ?></div>
<div class="alignright"><?php previous_posts_link(__('Newer Entries »')); ?></div>
</div>
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class(); ?>>
<h2><a href="">></a></h2>
<small><?php the_time(__('l, F jS, Y')) ?></small>
<div class="entry">
<?php the_excerpt() ?>
</div>
<p><?php the_tags(__('Tags:'), ', ', '
'); ?> <?php printf(__('Posted in %s'), get_the_category_list(', ')); ?> | <?php edit_post_link(__('Edit'), '', ' | '); ?> <?php comments_popup_link(__('No Comments »'), __('1 Comment »'), __('% Comments »'), '', __('Comments Closed') ); ?></p>
</div>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link(__('« Older Entries')); ?></div>
<div class="alignright"><?php previous_posts_link(__('Newer Entries »')); ?></div>
</div>
<?php else :
if ( is_category() ) {
printf("<h2 class='center'>".__("Sorry, but there aren't any posts in the %s category yet.").'</h2>', single_cat_title('',false));
} else if ( is_date() ) {
echo('<h2>'.__("Sorry, but there aren't any posts with this date.").'</h2>');
} else if ( is_author() ) {
$userdata = get_userdatabylogin(get_query_var('author_name'));
printf("<h2 class='center'>".__("Sorry, but there aren't any posts by %s yet.")."</h2>", $userdata->display_name);
} else {
echo("<h2 class='center'>".__('No posts found.').</h2>');
}
get_search_form();
endif;
?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Description:
-
< code>? php get_header ();? code>> code> is useful to call the file header.php. li>< code>div id = "content" code>> code> untilcode < code>/ div code>> code> before the code< code>? php get_sidebar ();? code>> code> is a blog content. The contents of this blog's content is the archive later. li>< code>? php get_sidebar ();? code>> code> is useful to call the sidebar.php file. li>< code>? php get_footer ();? code>> code> is useful to call the footer.php file. li>
ol>
