Ready to get started?Download WordPress


Link to an archive page that displays all posts (9 posts)

  1. meevil
    Posted 1 year ago #

    I'm having a little trouble with WordPress archives, or more accurately, trying to create a custom one.

    I'm making a custom theme for a client, and they specified that they want three items from each category (in this case, News (the default post type) and reviews (a custom post type)) to be present on the homepage.

    Now that was the easy part (two loops on the homepage, wp_query 3 posts per page), however they want the user to be able to click on a button, in order to view all of the posts of that specific type (rather than by category).

    This is my theme, currently:


    However I have no idea how i'd even approach this.

    I understand I can make a custom page-template and apply it to a page, but realistically I'd like to make something that's packaged within the theme and works "straight out of the box", as it were, so the client doesn't have to make the page himself in order to make it work.

    Thanks in advance for your help!

  2. keesiemeijer
    Posted 1 year ago #

    So these are both custom post types where you want an archive for? Or are they categories for a custom post type?

    If you registered your post type with: 'has_archive' => true, you can use the following templates to show an archive for that post type:


  3. meevil
    Posted 1 year ago #

    The first one (news) is just the standard wordpress post type. The second one is a custom post type, yea.

    How would I go about directly linking to these pages? Thanks for the quick response!

  4. keesiemeijer
    Posted 1 year ago #

    How would I go about directly linking to these pages?

    Do you mean from a nav menu in wp-admin > Appearance > Menus?

    From a nav menu you could link to the reviews post archive by using a "Custom Link" : http://codex.wordpress.org/Function_Reference/wp_nav_menu

    For the normal post type you can use a custom Page template (with a query on the loop to show the standard post type posts) and link to it by adding the Page.

  5. meevil
    Posted 1 year ago #

    I need to be able to link to these "archive" pages from within my home page loop. Is that possible?

  6. keesiemeijer
    Posted 1 year ago #

  7. meevil
    Posted 1 year ago #

    Thankyou! The post type archive function is precisely what I'm after, but it only seems to work for custom post types. Is there a value to get an archive for default posts?

    Something like:


    I'm not entirely sure if this is even possible!

  8. keesiemeijer
    Posted 1 year ago #

    Is there a value to get an archive for default posts?

    if the posts are all in category "news" you could use:

    If you don't want to use a category page you'll need need to make a page of posts for the normal post type and use:

    What theme are you using? (download link please)

  9. meevil
    Posted 1 year ago #

    I'm making my own, based on the _S theme by automattic.

    The posts aren't in a specific category just yet. What I ideally need is a system that will always take users to an archive-esque page that just displays everything they've published as a "default" post, without having to make a new page template to my specification when they initially install the theme.

    Sorry if this isn't possible, as I say the client was adamant about this "feature", and I'm just completely stumped. It's not something I've ever had to think about when developing a theme before.

Topic Closed

This topic has been closed to new replies.

About this Topic