On the site I am currently developing I have used custom post types for the different types of content it contains (News, Podcasts, Press Releases etc). How would I go about showing the label (plus a bit of text) for each section above the loop?
For example:
Press Releases
Some text under the heading.
- Press Release 1
- Press Release 2
- Press Release 3
- Press Release 4
- Press Release 5
Any idea how I would go about achieving this?
Thanks!
If the template page in question is the archive index for the custom post type, you can simply create a custom template file, archive-{post-type}.php
, and add in the Title and custom text.
If you don’t want to create a custom template file, you can use this boolean as a conditional in your existing archive.php
template file, for creating custom output:
<?php is_post_type_archive( $post_types ); ?>
To retrieve the Title for a Post Type archive:
<?php post_type_archive_title( $prefix, $display ); ?>
To retrieve the current Post Type (for use in PHP):
<?php get_post_type( $post ) ?>
To retrieve all Post Type information (e.g. to output Title, Description, etc. if configured):
<?php get_post_type_object(); ?>