post_type_archive_title()
Display or retrieve title for a post type archive.
This is optimized for archive.php and archive-{$post_type}.php template files for displaying the title of the post type.
Used By: wp_get_document_title()
Hooks from the function
Return
String|null
. Title when retrieving, null when displaying or failure.
Usage
post_type_archive_title( $prefix, $display );
- $prefix(string)
- What to display before the title.
Default: '' - $display(true|false)
- Whether to display or retrieve title.
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. |