PressTigers

Using WordPress Archive Widget to Display Customized Archives

In WordPress you can easily display archives, on a monthly or yearly basis, as a single link using the default archive widget. However to get a customized display, you need to rewrite the code. In this article, we will explain how to display lists of archives on a monthly basis under a yearly heading.

You need to add the following PHP code to functions.php file of your active theme. The code snippet below generates a list of monthly achives with separated by yearly headings.

Place the callback function pt_year_wise_monthly_archive() in you template file where you want to display the archive listing widget e.g sidebar.php. The function will output html of archive listing as explained.

You are done!

User Comments

2 thoughts on “Using WordPress Archive Widget to Display Customized Archives

    Alex says:

    For a novice, to where does one add the custom PHP code?

      Hello Alex,

      Please add the above code snippet in your theme’s functions.php file and use the callback pt_year_wise_monthly_archive() where you want to display the customize archive widget.

      Thanks for reaching us out. Let us know if you need any other assistance from us.

      Regards,
      Abdullah | WP Plugin Developer
      Email: support@presstigers.com

Leave a Reply

Your email address will not be published. Required fields are marked *

Get in Touch