Contents
What does it mean to have an archive page in WordPress?
It is optional because if you don’t have it, then the index.php will handle the output of archive type posts. Now as a refresher, an archive page in WordPress is referring to a collection of posts grouped by category, author, date, tag, etc.
How to display all your WordPress posts in one page?
This shortcode will simply display a list of all your post titles in a chronological order. It is set to display maximum 1000 posts per page. If you have more than a thousand posts, then you can change that.
What do I put in archive.php file?
Go ahead and create a new archive.php file in your theme folder. At this point, you can leave it blank. Just to show that the archive.php has now taken over for index.php, we can visit our archive links and notice that those pages are no longer outputting any information. What code do I put in archive.php?
We would have 48 monthly archive links in the sidebar. You also have the ability to add category archives, author listing, etc on your sidebar. But why clutter the sidebar with so many links when you can create a single page to list them all. This is when a custom archives page come in play.
How to get category ID of active page in PHP?
I use the get_queried_object function to get the current category on a category.php template page. Jordan Eldredge is right, get_the_category is not suitable here.
How to get category link URL in WordPress?
Retrieves category link URL. (int|object) (Required) Category ID or object. (string) Link on success, empty string if category does not exist. This function returns the correct url for a given Category ID. In a Plugin or Theme, it can be used as early as the setup_theme Action. Any earlier usage, including plugins_loaded, generates a Fatal Error.
Why is it important to have an Archives page on your blog?
This increases engagement, which is critical to maintaining a positive community around your blog. Beyond audience engagement, an archives page boosts the amount of time that people spend on your site, which is always a plus for you.