2

I have a simple file with the loop in it to get all posts called archive-post.php, but I'm not sure how I get to it in the URL?

http://www.examples.com/post/ gives me a 404

How can I see the archive of all my posts (not custom post types)?

  • Try saving your permalinks again – czerspalace Jul 30 '15 at 0:01
  • Any specific reason why you would like to do this – Pieter Goosen Jul 30 '15 at 6:10
  • @PieterGoosen Yes, very simple one really: I have a Static Page as my homepage and I just want to find a link to the normal posts page (ie. what would normally be shown as the homepage). There's probably a really simple solution to this! – Django Reinhardt Jul 30 '15 at 11:48
  • That makes more sense. The updated answer from @TomJNowell will then work for you :-) – Pieter Goosen Jul 30 '15 at 12:18
5

You don't, archive-post.php doesn't exist, it's just archive.php, and on most sites the post archive is the root of the site, aka /. Depending on how you're viewing posts it'll use home.php, front-page.php, index.php, etc. You should refer to the template hierarchy diagram, but remember, the standard post post type is a special case, as are pages

Perhaps adding your own rewrite rules, or specifying post_type=post in the URL as a query variable, or toggling the pre_get_post filter that's adding your custom post types to the main query

If you've set a page as your homepage, there is an option directly next to that option that lets you set the posts page, which will give you what you want. ( as a sidenote, you don't need to set a page as your homepage to give it a custom design, that's what the home.php template is for )

For example, this is my own site:

enter image description here

Where posts is a page called posts at /posts/. Of note, it will not use a page template if I assign one to that page, it uses the archive/index templates instead

  • Thanks, Tom. I have a Page as my site "root", so that's why I'm looking for another way to view all posts. – Django Reinhardt Jul 30 '15 at 11:14
  • Underneath the homepage option in settings is a posts page option, that's what that option is intended for – Tom J Nowell Jul 30 '15 at 12:11
  • Incredibly counter-intuitive, but it worked. Thanks! – Django Reinhardt Jul 30 '15 at 18:47
0

In this case you need to use Page Template. Add these line to the top of the file:

<?php
/**
*Template Name: Post Archive
*/
?>

Then you will create a new page, choose Post Archive for its page template box. That is, when you visit this page, you will get your posts archive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.