Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

up vote 4 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

 
discard

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.