In the Wordpress admin settings>reading you can configure the 'frontpage displays as' as being a static page for the front page. Now I would like to retrieve the ID of the selected static page which is set to display as front page. I've tried Googling but to not much avail, thus I was wondering if there is a native function to retrieve this ID. (I don't feel like programming a workaround if there is a native direct function for this).
The ID of the page used as static page is stored in the wp_options
WP table, as option_name
=page_on_front
and option_value
=ID of the page.
So if you want to retrieve this value, just use get_option('page_on_front')
.
I was looking for the solution where you select a page as placeholder for the blog archive.
You can do the same, but then query for 'page_for_posts' instead of 'page_on_front'. So:
$pageID = get_option('page_for_posts');
does the trick for that situation.
Here is an idea:
Get the page by Title first
$Page = get_page_by_title( 'test' );
Then, get the ID like this
echo $Page->ID . "<br /><br />";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With