D
D
Dymok2018-08-26 11:47:09
WordPress
Dymok, 2018-08-26 11:47:09

How to display the page name if it is set by the main static page?

If I set the page as the main one and access the site root, then wp_title() is empty.
If you access this page as sitename.ru/pagename, then wp_title() will display the correct page name.
How can you display the name of the page even if it is set as the main one? So, to change it from the WP admin panel, and not to crutch in the template.
Thanks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2018-09-03
@HeadOnFire

get_the_title() , you can pass an ID or a WP_Post object to it. And they can be obtained via get_queried_object() / get_queried_object_id().
However, there is some kind of bug somewhere or the left code is doing something weird. The title should be displayed already running.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question