I need to allow my users to set the default page of the blog. So when someone visits, “www.example.com/blog/” the page they see is either the blog posts list or a specific page.

It looks like I can tell which page is already set using:

get_option( 'page_on_front' ): returns the ID of the static page assigned to the front page. 

source

Can I change that by using:

set_option( 'page_on_front', 10 );

How would I remove a specific front page that has already been set?
Do I set it to null?

UPDATE:

I found this call to check if showing blog posts:

get_option( 'show_on_front' ) == 'posts';

source

BTW This is on a network site (WordPress MU).

1 Answer
1

If you manually enter the admin URL wp-admin/options.php you’ll see a list of all options and their values.

show_on_front is page when a page is selected to show on front. page_on_front and page_for_posts are 0 when no pages are chosen.

You can use update_option to change these values, there is no set_option function.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *