WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to programmatically set the 'page_on_front' option with the id value retrieved from the get_page_by_title command...

$homepage = get_page_by_title( 'Front Page' );
update_option('page_on_front', $homepage);
update_option('show_on_front', 'page');

This isn't working, can anyone help?

share|improve this question
up vote 10 down vote accepted

get_page_by_title() returns an object.

Use $homepage->ID.

You should also check if you really got a usable return value:

$homepage = get_page_by_title( 'Front Page' );

if ( $homepage )
    update_option( 'page_on_front', $homepage->ID );
    update_option( 'show_on_front', 'page' );
share|improve this answer
It had to be something obvious :) Thanks for the heads up – fightstarr20 Apr 16 '13 at 18:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.