get post title by id code example
Example 1: wordpress echo the page title
<?php echo get_the_title(post->$ID); ?>
Example 2: wordpress get post category name
<?php
$categories = get_the_category();
if ( ! empty( $categories ) ) {
echo esc_html( $categories[0]->name ); // Show first item of category
}
?>
Example 3: get post title by post id wordpress
get_post( $post_id )->post_title