Get the Title for the Posts List Page in WordPress

WordPressPosted on

1 min read

In WordPress, we can set up static pages for the front and home pages. The first one (front) is the page which we get on the root domain (https://pineco.de) the second (home) is our blog listing page (like https://pineco.de/articles/).

We can set these two pages under the “Reading Settings” (Settings -> Reading menu item). First, we must create two separate pages for each.

One usual scenario is to get the title of one of the pages (like the title of your blog listing to show in your template dynamically). We can get the title value with the following snippets:

// Get the title of the home page
echo get_the_title(get_option('page_for_posts'));
// Get the title of the front page
echo get_the_title(get_option('page_on_front'));

Using the get_the_title() function we can get any title based on an ID. To get the ID we can query the page_for_posts or page_on_front meta value with the get_option() function.

Need a web developer? Maybe we can help, get in touch!

Looking for web dev job?
You can check them on Jooble.

To see and write comments, you must allow the related (Disqus) cookies. For more information, please visit our privacy policy page.

Similar Posts

More content in WordPress category