Archive.php in WordPress | WordPress Theme Development | Lesson 6

In this lesson, we will learn to create a customize archive page (archive.php). For this, we have created a new page named “archive.php” and copy all code from “index.php” and pasted to “archive.php”.

Now in our “archive.php” page, we added some new code snippet.


Explanation: We use the following new functions for customization to our “archive.php” page.

is_category()                           :  Return True if the selected archive is category archive
single_cat_title()                     :  Print the title of selected category
is_tag()                                                : Return true, if the selected archive is tag archive
single_tag_title()                     : Print the single tag title
is_author()                              : Return true if the selected archive is author archive
the_post()                               : Iterate the post index in loop
get_the_author()                    : Print the author name of selected post
rewind_posts()                       : Re-using the same query in same page
is_day()                                   : Return true if the selected archive is day archive
get_the_date()                                    : Print the date
is_month()                              : Return true if the selected archive is month archive

get_the_date(‘F Y’)                 : Print the month and year
is_year()                                  :  Return true if the selected archive is year archive
get_the_date(‘Y’)                    : Print the year

Also we used function

the_excerpt() in place of the_content()

the_excerpt() function shows only a part of content instead of full content.