Skip to Main Content

Create “Archive-Only” Custom Post Types in WordPress, and make “team” pages simple

One of the more complicated things to handle in wordpress is creating a “team” page that is attractive and easy to maintain.  Many designers use pre-packaged plugins that remove a level of control, or create these pages as flat pages with complicated custom layouts (sometimes with the assistance of Visual Composer or another complicated shortcode library).

The same issue tends to carry over to other ‘aggregate’ pages like “board of directors” or “testimonials”.  However, it’s actually fairly simple to implement these pages as a Custom Post Type, giving content-editors a simple post interface to add and delete team members, and making front-end layout a simple job for a custom template and some css.

ADVERTISEMENT:

Here’s some well-commented code to implement a “Board of Directors” page for a non-profit.  However, with minimal tweaking, this becomes a “Team”, “Testimonials”, or even “Coupons” page. I’ve listed the custom archive page first, followed by the code to generate the custom post type.

2 Comments

  1. Rob's profile image.

    Could you explain in a nutshell at the top of the post, which part makes it ‘archive only’ as the title suggests?

    I have a custom post type where I can’t stop the single views from working without also disabling the archive page.

    Driving me insane at the moment and your’s was the only post I could find that wasn’t about disabling the archive page!

    • gschoppe's profile image.

      Hi Rob, This post could probably use a rewrite, as it was pushed out fast, and doesn’t meet the standards of most of my content. I’ll try to find the time to do so soon

      there are two filters that are added around line 32 of the second section of code, that handle the archive-only component. The first modifies that permalinks of the post type to point back to specific scrolled positions on the archive page, and the second makes sure that the archive isn’t paginated, so the scrolling will work.

      Ideally, you would also want a single page template for the CPT that contains a 301 redirect back to the archive page, just to make sure no one can access the single page by typing the url directly.

      To be honest, now that I have a few more years experience in WordPress, this solution isn’t really my go-to for this situation anymore. Instead, I would recommend creating a private post type to store the data, and rendering it via a shortcode, widget, or custom page template, which can be applied to a normal page.

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>