Never miss a thing!

Sign up to have the latest news and announcements from my site delivered straight to your inbox.
  • This field is for validation purposes and should be left unchanged.

Reader Interactions

Comments

    • What types plugin are you using?

      Just to clarify: Genesis 2.0 doesn’t include tools for creating/managing your CPTs. This feature is related only to archive support, regardless of whether you use a plugin or manually register your CPTs.

      • @Asifsomy I also use wp-types. Hopefully they’ll update it to support genesis-cpt-archives-settings in future. I’d guess that all CPT tools have the same issue, unless they generate code that you can manually edit.

        What I’m doing to work around this is using wp-types to create a custom taxonomy matching the CPT. With this method, your custom posts are already listed at /{taxonomy-name}/ without any further work. As an extra, now you can also access /{taxonomy-name}/{taxonomy-item}/ .

        If you need the listing page to include your custom fields, you’ll need to create a file called taxonomy-{taxonomy-name}.php. You don’t need to remove the Loop or write html; just something like this:

        add_action( ‘genesis_after_post_content’, ‘rhl_add_cpt_fields’ );

        function rhl_add_cpt_fields(){
        echo types_render_field( “my-field-slug”, array(‘output’ => ‘html’));
        }

  1. Thanks for this write up, Carrie! Some of my CPTs need custom archives anyway but nice to know this option is available as well. Haven’t checked it out yet, but your sneak peek is encouraging!

    • You bring up an interesting point – I haven’t played with creating a CPT archive template to see how it impacts the archive settings. I’m betting it would overwrite the headline and intro, but would still be useful for the SEO and layout settings.

      Of course, depending on how heavily you need to custom the archive template, you could always change minor things via conditionals in functions.php.

      • It certainly improves the existing archive template. You’ll find some SP child themes include the archive template (archive-portfolio.php) already so all you need to do is add a few lines of your code to the existing CPT code in your functions.php file.

        Just done this locally and it adds the archive settings page as seen in your screen shot.

        On top of this, Brian Gardner has supplied the code for adding a Portfolio page using a CPT to any theme. This includes the archive and single-portfolio.php code.

    • I was curious, so I tried it. It didn’t impact the SEO settings on the archives, which are more limited to begin with than post SEO options.

      Bottom line, with or without Yoast, the SEO options for the archive settings page remain as: Doc Title, Meta Description, Meta Keywords, and Robots Meta Tags.

  2. hahaha. Awesome and so easy with Genesis 2.0.

    Looking forward to seeing this built into the new Genesis 2.0 child themes

    @Asifsomy, i think Easy Content Types gives Types plugin a run for its money. It also generates the code you can use to make custom templates and archives pages.

  3. Awesome! This is yet another reason why I love the Genesis framework. I have been creating widget areas and conditionals in functions for text on the custom post archives. Looking forward to Genesis 2.0.

  4. This is pretty cool, only one line of code is needed.

    Yeah, since I’m using WordPress SEO plugin by Yoast, I’m quite curious whether the SEO part of the CPT archive settings will override Yoast SEO settings or not.

  5. Hi Carrie
    Thanks a lot. It works great we don’t need anymore to use a template page with a custom loop to do it.
    I wonder if there is a way to use genesis hooks directly in a archive-$posttype.php files. I try but remove title ou meta do not works. But remove loop is ok and the new archive title and description still there in this case.
    Have you an idea.
    Thanks anyway.

    • I haven’t tested this bit of code, but the idea would be to remove the title and write a function to conditionally add it back in everywhere except your CPT archive file, like this:

      remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
      add_action( 'genesis_entry_header', 'cd_archive_title' );
      function cd_archive_title() {

      if ( ! is_post_type_archive('your-cpt-name') ) {
      genesis_do_post_title();
      }

      }

      Don’t try that on a live site, it’ just to give you an idea. 🙂

      • Thanks Carrie. I will give a try.
        Sometimes, I really need to make a custom page for archive with more customization. So like remove loops works, I will try with a custom loop in the archive-$posttype.pho file. I want to avoid weird URL brings by custom page when I need to display CPT archives.
        Of course on a local website 🙂

  6. Hey Carrie, Great post! I wanted to customize my portfolio archive page by removing the commas that seperated the tagged list as well as remove the categories all together. Both is_archive() and is_post_type_archive() seem to have no effect on the page. I ended up using a portfolio-archive.php file and everything works as I intended but am a bit confused on why is_post_type_archive() did not work. I did some testing an could not echo a simple string using the function. Any idea why these functions do not effect the archive page?

    • Hi Juan,
      Do you mean archive-portfolio.php? If you want the an archive page for a Portfolio custom post type, then the template should be named archive-portfolio.php (see the template hierarchy for more info there).

      Assuming you’re already ON the portfolio archive, then a conditional statement to see if you’re on the archive isn’t necessary. Here’s a post on WordPress Conditionals that may shed some light there. 🙂

      Cheers,
      Carrie

      • It was a bit late when I wrote my question so sorry I wasn’t clear. I did mean archive-portfolio.php and this is what I ended up doing and it works fine. I never added the conditional statement to the archive-portfolio.php file, I added the statement to the functions.php file. For some reason is_post_type_archive() does not effect the portfolio archive page. So if I add this:
        `if ( is_post_type_archive() ) { echo ‘Hello World!’; } ` to the functions.php the string does not get echoed. Any thoughts on why?

    • Ah, okay!

      You’ll need to wrap it in a function and execute it in the context of an action hook or filter. Something like this:

      add_action( ‘wp_head’, ‘do_my_thing’ );

      function do_my_thing() {
      // insert conditional code here
      }

      If that still doesn’t work for you, double check that when you created your CPT you set ‘has_archive’ => true, 🙂

  7. I was just able to add support for the Genesis CPT Archive to a plugin which generated an archive but without giving me the ability to add content to it! This saved me from having to create essentially a duplicate archive page. I call that a WIN. Thanks, Carrie!

  8. Brilliant post – This is what I was looking for!!!
    Just wondered, is there a way to activate the WYSIWYG for the intro text as well as support for choosing image sizes? Travis’s plugin had this but doesn’t seem available native the genesis 2.0.

    • Heya! There’s not built-in support for what you’re looking for. Not sure if Travis plans to update his plugin for 2.0 or not since the primary feature is not built-in, but you might be able to fork his code and do what you need.

      • Gary Jones (@GaryJ) did an excellent job of porting my plugin into core. As a result, my plugin is in massive need of an upgrade or retirement (which is most likely) where I am considering a few different ideas. Yes, I like the use of the editor in various places where Genesis doesn’t use for whatever reason as that is more “user-friendly” (if the user is not a developer, ha!).

        • Hi Travis. Thanks for the effort with the plugin so far. Before it became Genesis core it was saviour as there was quite a lot of tricky customisation in the functions.php to achieve even half of what the plugin did. I guess I can work around the fact the editor isn’t in place but declaring come styles for text intro descriptions in css. Shame there is no option to add links in the text though.

      • Just wanted to update on this. Even though the archive settings show only a text box (no editior) it accepts html!! I was able to maintain the styling of the intro text exactly as I had using Travis’s plugin. Now just to find a way to choose a custom image size for the archives…..

    • Hi Scott,
      Not sure what you mean by “rework the entire framework.” The code here applies to the archive page (which is what the link you sent appears to be). If you’re wanting it to look any different than the standard archive page, you’re probably better going the custom template route.

      Carrie

  9. Hi Carrie,
    I’ve followed a few of your posts in the past and find this site a really useful resource, so firstly many thanks.
    Regarding Custom Post Types, I’m really stuck on something here…
    I’ve registered my CPT (music-reviews) and the archive page is working ok.
    For a single page, I can’t get it to show just the one article.
    I have a file in my Child Dir, called single-music-reviews.php but this is showing all the posts for that CPT.
    The Archive URL is here: http://plainandsimple.tv/music-reviews/

    I have setup my CTP in a plugin and created a single-music-reviews.php file.
    I think it may be because Genesis doesn’t have a single.php file?
    Any suggestions, please?
    Thanks in advance,

    Tom

    • Hi Tom,
      Sounds like you’re on the right track. With Genesis, you can still follow the naming structure for templates as outlined in the Template Hierarchy.

      Note this excerpt from that page specifically:

      single-{post_type}.php – If the post type were product, WordPress would look for single-product.php.

      You’re using single-music-reviews.php which should be corrected assuming your CPT is registered as “music-reviews”. The register name is not necessarily the same as a slug. For instance, your CPT may actually be registered as music_reviews, which would just make your template naming a little off.

      Easiest way to get the name of your CPT (assuming the plugin you’re using doesn’t make it blatantly obvious) is to hover over your CPT in your admin dashboard, check your URL preview and see what it shows your post_type= as. 🙂

      Cheers,
      Carrie

  10. Great article. Has helped me a lot! I’m curious though whether it would be possible to add specific page templates to the cpt category. I’d like to present a video, photo or audio file differently in my portfolio! I’m curious how you would solve this 😉

    • Hi Piet,
      Using this method removes the need to use a template. If you wanted to use a template, I’d disable support for the CPT archive and manually include your template.

      Alternatively, if it’s just a styling issues, use this CPT archive setting. You’ll get a unique body class on the page you can use to target elements with CSS.

      Cheers,
      Carrie

      • Hey Carrie, the thing I’m looking for is to make optimal use of the schema.org functionality of genesis. I’m working on a audio/video/photography company website and it would be great if I could add different schema.org code on the individual page within a portfolio archive, which is now just an article or blog post. Right?
        At messages you can select something like a notation/template for an audio/video/picture/quote post. I’m not aware of how this is implemented when using your great tutorial 😉

  11. Hi Carrie, thanks for a wonderful explanation. I was wondering if a plugin, for example, wmpu classifieds already creates a custom post type “classifieds” how can I customize its archive page in Genesis?

  12. Hi Carrie, I’m trying to do something that I *think* should be very simple (especially with Genesis), but I’m having trouble figuring out exactly how to do it. I want to create category/archive pages for a client that shows a grid of book covers (each of which links to the post for that book. So, for example, if one of her series is called “Biscayne Bay” a template called category-biscayne-bay.php would generate a page of covers of books in the Biscayne Bay series and clicking on each cover would take you to the post that contains the cover, back blurb, buy info, etc. I thought the best way to do it was with a grid loop, but I haven’t found a way to do that without pulling in the title and other info in addition to the featured image. My search for “Genesis portfolio grid” led me here, so I’m hoping you can help me. Could the technique you describe on this page do what I need? Thanks in advance for any advice.

    • Hi,
      If you’re using standard posts/categories to organize the series, then your first step would be to have all the posts that represent the books assigned to the “Biscayne Bay” category. From there, without a custom template, the category archive from “Biscayne Bay” should return associated posts. If that works as expected, then go about the business of creating your custom template as you described. You’ll have to customize the loop to only return featured images.

      In short, the custom template method is the opposite of this post which circumvents the need for custom templates. 🙂 Check out this article – it’s dated, but might give you some ideas. You might also look into the Types and Views plugins which make it easy to create custom post types (in other words, break your books out of the standard post/categories for better organization) and associated templates.

      Cheers,
      Carrie

  13. Hi carrie,
    using this method (which worked great by the way, how do you get an excerpt to appear in the CPR archive page. I would like to put some info about a condo buildling in the custom post type excerpt field, and have it show in this archive page under each condos page title. page

    Also, how the heck do I get the dates of these custom post types? I reserached numerous methods on the SP forum and none work.

    your blog is VERY informative. thank you!!!

  14. Great ideas and help here. Thanks Carrie.

    I just started working with a child theme in Genesis. In the Genesis page_blog.php it only pulls in the ‘post’ type, yet I also want it to pull in the ‘podcast’ type which I added in my functions.php file.

    How would I frame that arg to that in brings in both kinds?

    Thanks again for your expertise.

    -Dan

  15. I’m using WPMU Dev’s CustomPress plugin to create and manage my custom post types, taxonomies and fields. Is there a way to add the last line:

    ‘supports’ => array( ‘title’, ‘editor’, ‘genesis-seo’, ‘thumbnail’,’genesis-cpt-archives-settings’ ),

    as code into my functions.php file. I don’t need all the rest above, but still want to support Genesis 2 to be supported!

    Thanks.
    Cathie.

    • Hey Cathie,
      I think this function might be the ticket.

      Absolutely untested code, so be prepared for a white screen of death. 🙂 But here’s the idea:

      add_action('init', 'my_custom_init');
      function my_custom_init() {
      add_post_type_support( 'your-post-type-name', 'genesis-cpt-archives-settings' );
      }

      • Hi Carrie, thanks for the code. No white screen of death but also no archive settings popping up under my custom post type either!

        Do you think this is an important feature to activate or am I chasing something that isn’t really that necessary for custom post type archives in genesis .. especially if I use Yoasts SEO to compliment?

        • You don’t need it for SEO purposes, but it’s a great easy way to add in a headline and intro to archives. For an example, note that I have a headline/intro on this category, but not on this one.

          If you decide it’s important, pop over to the CustomPress forum and ask them how/where is the best place to use the add_post_type_support() function to modify a post type created by the plugin. It may be the code below executes prior to the plugin being loaded (and the “existence” of the post type) to be applied. Bringing it in later may solve the problem, but not sure. Or there may be a better technique altogether. 🙂

  16. Hi Carrie,
    I’ve created my CPT ‘Testimonials’ & have also created a custom archive template called archive-testimonials.php because I have meta data containing the clients name. I have included ‘genesis-cpt-archive-settings’ in my CPT registration because I want to add my own Title & Intro text. It works great except that I also get the title ‘Testimonials Archive – Site Title’ under my custom title. If I don’t use ‘genesis-cpt-archive-settings’ then I get no page title at all. remove action (‘genesis_entry_header’, ‘genesis_do_post_title’) doesn’t remove this title and so the only way I have found to remove the default archive page title but keep my custom title is to use this in my style.css:

    .archive-description{display:none;}
    .archive-description.cpt-archive-description{display:block;}

    Do you know of any other way to remove this default title?
    Many Thanks & I love Genesis Office Hours!

    • Hey Angie,
      Hiding the title via CSS is a good way to do it, although if there’s something more specific that just .archive-description to target for the display:none, that’d be better since you wouldn’t have to specify how to display the other title. If you shoot me a link, I’m happy to look.

      Cheers,
      Carrie

      • Thanks for the reply Carrie, I have also tried:

        remove_action( ‘genesis_before_loop’, ‘genesis_do_taxonomy_title_description’, 15 );

        which I thought was what I was looking for but the Title was still there. I always feel like display:none is a bit of a hack but I can’t find another solution.

        The site is at http://thepds.wpengine.com/testimonials/

        Thanks for your help
        Angie

        • Have you tried installing the Genesis Visual Hook guide plugin? It’ll help you narrow down the right spot to apply your action if you want to go about it that way. 🙂

        • Angie, your code should work for the regular ‘post’ post type, but for a cpt, this works for me.

          remove_action( ‘genesis_before_loop’, ‘genesis_do_cpt_archive_title_description’ );

  17. What about if you want to control the SEO settings for the custom post type index page? the one that is not associated with the taxonomies, but the equivelent of the homepage for “posts”. How can you gain control over that top level page for your custom post type? These are auto generated. I want to 301 some of them on a site.

  18. Hi Carrie – thanks for this tutorial, it’s the best I’ve found on the subject of creating a Template for CPTs, however I’m struggling with getting it to work, and hoping you can help.

    I’m using WP 4.2.2 and Genesis 2.1.2 – I see how you can add the Archive Setting support for Genesis (above), but that isn’t working for me (it only displays the most recent CPT, not a list of all as would be expected), so I’m back to using the template from your earlier tutorial.

    However, what is happening is that some of the info that should be contained *within* the tags is being outputted just ahead of them…..for example, where you are calling a div id=”testimonials” I am using the ‘article’ tag in keeping with my Theme, like so:

    `echo ”;`

    But what gets echo’d to the page is the post classes first (which naturally displays publicly on my page), then the article tag with no classes. The same thing happens with this tag:

    `echo ”. the_title() . ”;`

    what appears is the title twice, because the title=””‘. the_title() . ‘” is being outputted just before the A tag, so the (second instance of the) title is not really linked….

    My code in the template looks perfect – I honestly cannot see what to change, but Genesis is not outputting it as it should, so the page is messed up and none of the posts are linked to.

    This is the complete section that is not working:

    ` while( $loop->have_posts() ): $loop->the_post(); global $post;

    echo ”;
    echo ”. get_the_post_thumbnail( $id, array(150,150) ).”;
    echo ”. the_title() . ”;
    echo ” . the_excerpt() . ”;
    echo ”;

    endwhile;
    `

    Any ideas?

  19. Well sadly the tags are being stripped, even though I surrounded my code with backticks…..maybe the code tag will work so trying again – this is the section I’m having trouble with, both the post_class and the_title are being outputted ahead of the tag.

    while( $loop->have_posts() ): $loop->the_post(); global $post;

    echo '';
    echo ''. get_the_post_thumbnail( $id, array(150,150) ).'';
    echo ''. the_title() . '';
    echo '' . the_excerpt() . '';
    echo '';

    endwhile;

  20. Well that didn’t work either……not sure how to show you the problem…..hopefully my description is adequate……

    • Hey Trisha,

      Be sure to check those function references in the WordPress Codex. Some of them return the info to the page already, so if you say echo the_title() it’s redundant as the_title() is already printing to screen. Instead, you’d want to use get_the_title() which returns the value, but doesn’t print to screen (and therefore you could use with an echo).

      Basically, these would output the same thing:

      the_title();

      echo get_the_title();

      Just depends on your usage which one you call.

      Cheers,
      Carrie

  21. I am wondering what this shall all be about?

    you can add and customize Archives using WP API, also for CPT’s, that’s very easy.

    So what is this “support for genesis archive” all about?

    I see you add it in the “support” argument as it would be Title, Editor whatever.

    What does it do? How is that useful? Can you provide a hook, filter whatever so one could add this to a CPT stored in DB instead of PHP code? (plugin CPT’s as example)

    If CPT’s aren’t registered in PHP, its not as easy to add a “support” argument value as you illustrated above…

    I am a bit confused. Thank you ver much!

    • This post assumes you’re working with the Genesis Framework. If you’re not, the simplest solution would be custom archive templates.

      If you’re working with a plugin that registers a CPT (and don’t have any control over how its registered), then you could use the add_post_type_support() function to add support for Genesis archives.

  22. Hi Carrie. About the adding support with “add_post_type_support” – this used to work for me until I shifted over using “types and views” from the toolset suite. I can’t actually seem to activate support for archive settings at all right now. Do you have experience with types and views and know how this is possible?

    • Hi Robert,
      I’ve used Types & Views but never tried to use add_post_type_support with it. I’m wondering if Types adds it’s own prefix to CPTs names so that might be why add_post_type_support isn’t working for you. I don’t think it does, but truly never poked around that much.

      I’ll ping my friend Jonathan Perez to see if he has insights.

      If you don’t mind, I’ll continue this conversation via your G+ profile -> https://plus.google.com/+RobertKhoome

      Cheers,
      Carrie

  23. Great information! I created the new custom post type, and I got the Archive Settings to show up, but it’s not showing the SEO options. I use Yoast anyways, so should I be concerned? Thanks!

  24. @Robert Khoo @Carrie Dils

    I have just enebled the Genesis CPT archive on a CPT created with ‘Types’ (from WP Toolset). I did this using the following function:

    /* Enables Genesis CPT Arcthive settings on Types CPTs */
    function add_genesis_support_to_types() {
    add_post_type_support( ‘action-plan’, ‘genesis-cpt-archives-settings’ );
    }
    add_action( ‘init’, ‘add_genesis_support_to_types’ );

    This works fine.

    Kind regards

    Mark

  25. I realize this is quite an old post, but I have a quick troubleshooting question. I’ve set up my custom post type to have the archive settings, but when I click to view the archive, it defaults to the homepage. I also tried viewing one of the posts, and it did the same thing.

    If it helps, I’m using Atmosphere Pro.

    Here’s the code for the CPT:

    ‘//* Add a custom post type
    add_action( ‘init’, ‘cd_post_type’ );
    function cd_post_type() {
    // Speaker custom post type
    register_post_type( ‘speaker’,
    array(
    ‘labels’ => array(
    ‘name’ => __( ‘Speakers’ ),
    ‘singular_name’ => __( ‘Speaker’ ),
    ),
    ‘has_archive’ => true,
    ‘public’ => true,
    ‘show_ui’ => true, // defaults to true so don’t have to include
    ‘show_in_menu’ => true, // defaults to true so don’t have to include
    ‘rewrite’ => array( ‘slug’ => ‘speakers’ ),
    ‘supports’ => array( ‘title’, ‘editor’, ‘genesis-seo’, ‘thumbnail’,’genesis-cpt-archives-settings’, ‘custom-fields’ ),
    )
    );
    }’

    Thanks!

    -Alaina

    • Hey Alaina,
      Sounds like a permalinks issue. Visit Settings > Permalinks (no need to save anything) and that will flush your rewrite rules. If that doesn’t do the trick, please post this over in the StudioPress forums and leave a link so I can help you over there.

      Cheers,
      Carrie

  26. Nice write up, thanks. I’m trying to come up with a way to display custom post type categories, with the category descriptions, and a link back to the archive. without the posts.

    any suggestions? thanks

  27. thanks for the prompt response. I’ll need to get out my martian decoder ring to find out what to do with that, but nice to know there is some code out there that likely will put this together.

  28. Thanks for the helpful post, Carrie. It was just what I was looking for.

    I was using Toolset Types plugin but after their last upgrade it’s just too pricey for my purposes so I’ve switched to the Custom Post Type UI (CPT UI) plugin. [Good thing I’m at the beginning of my project.]

    Anyway, since it took me a couple of minutes to figure out how to blend your tutorial with the CPT UI plugin, I thought I’d share my solution in case anyone else is trying to figure it out. Once you know how to fit the pieces together, it’s super simple.

    On the “Add New Post Type” screen almost at the very bottom is a text field for “Custom ‘Supports.'” If you just pop in “genesis-seo,genesis-pct-archives-settings” (without the quotes), everything comes up roses.

  29. Hi Carrie,

    Great article, I didn’t know that was possible. I always considered these pages indexes of the post type as they are like the home/posts page is to posts rather than a taxonomy archive.

    Anyway with some further digging I noticed you can use WP-Types plugin still and hook these filters in using the below code. One of your commenters mentioned this was an issue. Thanks, keep up the splendid work.


    //* Adds Genesis Custom Post Type Archive Settings Support to Custom Post Types when using WP-Types Toolset.

    add_filter('wpcf_type', 'add_genesis_post_type_support_cpt', 10, 2);
    function add_genesis_post_type_support_cpt($data, $post_type)
    {
    $arr = array('rests', 'workouts', 'recipes');
    if(!in_array($post_type, $arr)) return $data;
    $data['supports'][] = 'genesis-cpt-archives-settings';
    return $data;
    }

  30. Carrie, this was excellent news for me. I’m newer to Genesis, and was trying to figure how to get a CPT to have it’s archive page. After doing it “old school” last year with a TwentyTwelve theme setup and using two plug-ins and a bunch of hand-coded templates, it’s astounding to see that a simple function would add the CPT and provide archive support automatically. Great post. No wonder you’re near the top in the search results.

Trackbacks

  1. […] or looking to brush up on their coding finesse.  Carrie recently shared a post covering a new feature in the upcoming Genesis Framework 2.0 […]

Leave a Reply