-1

I am new to wordpress and have been trying figure out things on my own.

I’m trying to get the title of the current page I’m in (front-page.page).

I’m using the_title(); but I don’t get any results.

Also I'm using wordpress version 5.5.3.

Any idea what I need to use?

Master.Deep
  • 792
  • 5
  • 20
D. Kris
  • 1
  • 3

1 Answers1

0

Use get_the_title() insted of the_title()

if you are unable to get title, then try passing the page id as argument like

get_the_title(1) Where 1 is id of current page. you can get the page id from wp-admin -> pages -> your current page -> in the address bar it will display something like "yoursite.com/wp-admin/post.php?post=1" where 1 is your page id.

Darsh khakhkhar
  • 666
  • 5
  • 15
  • I have used `get_the_title()` and `get_the_title(page ID)` as well as you said.but it doesn't going well.anyway thank you – D. Kris Dec 09 '20 at 03:50
  • `$page = get_page_by_title( 'Home' ); echo get_the_title($page->ID) ;` First I used as you said.Then I found the way like this and I do not know I'm right or wrong.But it does work. – D. Kris Dec 10 '20 at 03:56
  • May be you were providing the wrong id. bcz what are you doing is getting id from page and then fetching the title using that id. – Darsh khakhkhar Dec 10 '20 at 04:27