Display title of custom post type dynamically

I’ve registered my custom post type in functions.php like so:

function whatwedo_custom_post_type()
{
register_post_type(‘whatwedo’,
array(
‘labels’ => array(
‘name’ => __(‘What We Do’),
‘singular_name’ => __(‘What We Do’),

),
‘public’ => true,
‘has_archive’ => true,
‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’),
‘capability_type’ => ‘post’,
‘capabilities’ => array(
‘create_posts’ => ‘do_not_allow’,
),
‘map_meta_cap’ => true,

)
);
}
add_action(‘init’, ‘whatwedo_custom_post_type’);

Currently, I have the post title hardcoded within my frontpage.php template like so:

<h1 class=”ft-center”>WHAT WE DO</h1>

I need to display the post title dynamically instead, meaning – whenever I change the custom post title in admin, I want to display the changed title on front-end. Currently, when I try to display the custom post title (out of the loop) with

<?php echo get_the_title( ); ?>

it displays the page title, instead of post title. What should I do to display the custom post title instead?

Read more here:: Display title of custom post type dynamically

Leave a Reply

Your email address will not be published. Required fields are marked *