How to Remove Links on a Genesis Custom Archive Page Template

Have you ever wanted an archive to display posts, but not wanted those posts to link through to the individual post pages? Well, you’re in luck because in this tutorial I’ll show you how to create a custom Genesis archive page template to display the thumbnail and post title, but without links to the individual post content.

This tutorial requires the Genesis Framework. While you could use a similar approach for a non-Genesis theme, the code samples below only work with Genesis.

Why a Genesis Custom Post Type Archive?

For this project, I wanted to display a list of employees with their name, photo, and some other details. While I could have easily created a static page with this info, I wanted content that a client could easily update without the need to manually add formatting.

To do that, I created a custom post type and a corresponding custom template to display the content.

Screenshot of archive page with no links

You can use the steps below to help you customize an archive template that doesn’t link through to individual posts.

How to Remove the Link from the Thumbnail & Post Title on a Genesis Custom Archive Page Template

Step 1: Create the Custom Post Type

In this case, I named my custom post type “Team” since I wanted to display a list of employees, or team members.

You can manually create a custom post type (CPT) or use a plugin to help. While I typically go the former route (via a custom plugin to for non theme-specific code), I opted to use the WP-Types plugin for simpler maintenance.

While I was at it, I also used WP-Types to create a custom meta box to go with the “Team” post type so that I could store the team member’s job title and bio as a separate pieces of meta-data.

Step 2: Create a Custom Post Type Archive Template

According to the WordPress template hierarchy, the standard for naming a CPT archive is archive-$posttype.php, where $posttype equals the CPT’s slug.

Mine was team, so I named it archive-team.php.

Drop this in your child theme’s root directory.

Step 3: Drop in the code

For starters, I added a bit of code to functions.php that gets rid of the post meta (i.e. author, publish date, tags, etc.) for the “team” post type. (Note that you need to have Genesis 2.2 to use this code)

<?php
add_action( 'init', 'team_remove_entry_meta', 12 );
/**
* Remove entry meta for the 'team' post type
*
* @link https://gist.github.com/cdils/61b8a0720fe828acb467/
*/
function team_remove_entry_meta() {
remove_post_type_support( 'team', 'genesis-entry-meta-before-content' );
remove_post_type_support( 'team', 'genesis-entry-meta-after-content' );
}
view raw functions.php hosted with ❤ by GitHub

Next, I added my custom code to archive-team.php.

<?
/**
* Team Archive template
*/
// Remove default post title (with link)
remove_action( 'genesis_entry_header','genesis_do_post_title' );
add_action( 'genesis_entry_header','cd_archive_title' );
/**
* Display the post title (without link).
*
*/
function cd_archive_title() {
echo '<h2 class="title">' . get_the_title() . '</h2> ';
}
add_action( 'genesis_entry_content', 'cd_archive_featured_image', 8 );
/**
* Display featured image (without a link).
*
* Check to see if the post has a thumbnail and, if so, display the thumbnail.
*
*/
function cd_archive_featured_image() {
if ( ! has_post_thumbnail() ) {
return;
}
$attr = array (
'class' => 'alignleft',
'context' => 'archive',
'alt' => get_the_title(),
);
echo '<span class="featured-image">';
the_post_thumbnail( 'thumbnail', $attr );
echo '</span>';
}
add_action ( 'genesis_entry_content', 'cd_team_member_details', 9 );
/**
* Display team member title and bio.
*
* Uses WP Types & Views to return two custom fields.
* https://wp-types.com/documentation/user-guides/displaying-wordpress-custom-fields/
*
*/
function cd_team_member_details() {
echo '<strong>' . types_render_field( 'team-member-title', array("output"=>"html") ) . '</strong>';
echo '<p>' . types_render_field( 'bio', array("output"=>"html") ) . '</p>';
}
genesis();

You could change the CSS classes or other markup as needed, but this should get you headed in the right direction.

Step 4: Adjust Genesis Theme Settings for Content Archives

Under your Genesis theme settings, make sure you have don’t have the “Include the Featured Image” option checked.

Genesis theme settings for Content archives

If you want to leave this checked (for use on other archive pages, say), then add this to your CPT archive:

remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );

The finished CPT archive

What I end up with is an archive page listing every team member, along with their photo, title, and bio. The post title (the team member’s name) is not linked and neither is the featured image (the team member’s photo).

Tada!

Photo credits for featured image go to Hernán Piñera

25 thoughts on “How to Remove Links on a Genesis Custom Archive Page Template”

  1. Yes, very helpful Carrie. I’m a Lynda subscriber and have stumbled across your excellent courses in Genesis – wonderful stuff! Any more courses planned for release? Something I’m really interested in is CPTs – not really how to set up as there are a variety of great plugins to do – more about how to fine tune them specifically with genesis.

    1. Thanks, Robert!
      I don’t have anything in the words for CPTs, but there are loads of great tutorials (both WordPress and Genesis-specific) available. The best way to learn it (or at least the way I did) is to keep hacking away at code from tutorials and the WordPress codex until it clicks.

      Cheers,
      Carrie

  2. Good advice Carrie. I think we can be too reliant these days of getting a quick fix without putting the effort in to understand how it all works. Will get hacking….

  3. Do you use ACF much, Carrie? When I have something like this that I want to have specially formatted, I usually set up a page template that activates an ACF field group when selected. The ACF field group will utilize a repeater field (containing, say, image, name, title, description) so that they can add as many staff members (or whatever) that they want, and then I will set up the styling with a combination of HTML included in the page template file and CSS. It works well and might cover what you’re doing here with custom post types.

  4. When using CMB instead of Types in code below?

    function cd_team_member_details() {
    echo ‘‘ . types_render_field( ‘team-member-title’, array(“output”=>”html”) ) . ‘‘;
    echo ” . types_render_field( ‘bio’, array(“output”=>”html”) ) . ”;
    }

  5. I have set the featured image as a parallax background on each page and post in the header, but when the post is on an archive news page I want to display a different featured image any idea how i would go about that – thanks

    1. What you’re going for is definitely outside the scope of this post, but it sounds like what you’re looking for is a way to associate a featured image with a particular category and then display that information on a category archive page. As for associating a featured image with a category, there are several plugins in the WP repo that address that (it’s been awhile since I looked at them, so I don’t really have a recommendation). From there, you’d just need to grab the image and display it on your archive page. The way you grab it will depend on the way whatever plugin (or custom code you use) stores the featured image in the database. I would imagine it’s stored as term meta.

  6. Hi Carrie

    Thanks for your post.

    I’m trying to create one custom category page that – unlike my other category pages – just lists the full content of a number of category posts. Unlike my other category pages, I want this page to have a category description, but then just a list of full posts. No post excerpts or summary, no Read More links, no title-link or featured-image-link to the full post. Just a list of short posts in their entirety.

    I’ve got as far as creating a category_slug.php file and uploading it in my root directory. But I simply cannot figure out how to modify the code to make the rest happen. Any pointers?

    I am using Genesis Sample Theme…Here is the category page I am trying to customize: http://www.bookishboys.com/category/funstuff/

    Thanks!

Leave a Comment

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

Carrie Dils uses Accessibility Checker to monitor our website's accessibility.