How to get page title in wordpress

Well i tried <?php echo get_the_title('About Us');?>

But the code doesn't work. I am using wordpress 4.1. This should work, but it doesn't. Have Wordpress Features Updated?

+3


source to share


5 answers


Try this, it might help you

<?php single_post_title(); ?>

      



Thank:)

+3


source


You are specifying incorrect parameters get_title

. See codex

.

Instead, you would have to use ID

to get the title.

So your code will be



 <?php echo get_the_title(13); //where 13 is the ID of the about us page ?>

      

NOTE. The parameters are optional.

+2


source


Try this, maybe it will help you

<?php echo get_the_title(); ?>

      

And if you want to get the title of the page or post by id

 <?php echo get_the_title(post->$ID); ?> 

      

thank

+1


source


You can try this

 <?php echo get_page_by_title( 'About' ); ?>

      

Link

0


source


<?php
  $page = get_page_by_title( 'About Us' );
 echo get_the_title($page->ID)
?>

      

-1


source







All Articles