post_type_archive_title()
Outputs or returns the title for the archive page of a custom post type.
This Template Tag is intended for use on pages that are output by the template files: archive.php and archive-{posttype}.php.
Used By: wp_get_document_title()
Hooks from the function
Returns
String|null.
Usage
<?php post_type_archive_title( $prefix, $display ); ?>
- $prefix(string)
- Text that will appear before the title.
Default: '' - $display(boolean)
- true — will output to the screen, false — will simply return for processing.
Default: true
Examples
#1 How the function works
Suppose we have a movie registered post type (see register_post_type()) which label parameter is "Movies" and has_archive parameter is true (i.e. the type has an archive page). Now, if we call this function on the archive page http://example.com/movie, we should see the following header:
<?php post_type_archive_title( 'Posts of type: '); ?>
Outputs: "Posts of type: Movies"
Changelog
| Since 3.1.0 | Introduced. |