I need to overwrite the show_on_front, page_on_front, page_for_posts options values for some reasons. I am setting show_on_front to 'page' and the other both to two different page id. If I change these settings in Administration > Settings > Reading panel to the same values as I do programmatically, the front page loads the front-page.php template. Otherwise the front page loads the page.php template. What am I doing wrong?
add_filter('pre_option_show_on_front', 'static_front_page');
function static_front_page() {
return 'page';
}
add_filter('pre_option_page_on_front', 'page_on_front');
function page_on_front() {
return 123;
}
add_filter('pre_option_page_for_posts', 'page_for_posts');
function page_for_posts() {
return 123;
}
I know this is not best practice, but would love to get this done this way.
Another problem when setting it per filter, is that is_front_page() isn´t working correct after it.