Forums

How to echo current custom post type name (not slug) (2 posts)

  1. drewbarden
    Member
    Posted 1 year ago #

    How do I echo the custom post type name when viewing the archive or single post of that type? To grab the slug is,

    <?php $queried_post_type = get_query_var('post_type'); ?>

    But how in the world do I grab and echo the name?

  2. vtxyzzy
    Member
    Posted 1 year ago #

    From the Codex article on get_post_tyoes, I think you can use this:

    $names = get_post_types(array('name' => get_query_var('post_type')),'names');
    $queried_post_type = $names[0];

Topic Closed

This topic has been closed to new replies.

About this Topic