Set front page with php
-
Hi, everyone. I am trying to set a different page as front page, depending on the value of a counter-variable. I created a child theme and placed the following code in it. Unfortunately it’s not working and I am not particularly firm with php. Any help in getting it to work is greatly appreciated.
<?php
// Exit if accessed directly
if ( !defined(‘ABSPATH’)) exit;/* Add custom functions below */
if (is_new_day() ):
$SignupCounter = 0;if (is_page( ‘confirmed-signup’ ) ):
$SignupCounter++;if ($SignupCounter == 0) : {
$LP = get_page_by_path( ‘/home-0’ );
update_option( ‘page_on_front’, $LP->ID );
update_option( ‘show_on_front’, ‘page’ );
}elseif ($SignupCounter == 1) : {
$LP = get_page_by_path( ‘/home-1’ );
update_option( ‘page_on_front’, $LP->ID );
update_option( ‘show_on_front’, ‘page’ );
}elseif ($SignupCounter == 2) : {
$LP = get_page_by_path( ‘/home-2’ );
update_option( ‘page_on_front’, $LP->ID );
update_option( ‘show_on_front’, ‘page’ );
}elseif ($SignupCounter == 3) : {
$LP = get_page_by_path( ‘/home-3’ );
update_option( ‘page_on_front’, $LP->ID );
update_option( ‘show_on_front’, ‘page’ );
}elseif ($SignupCounter == 4) : {
$LP = get_page_by_path( ‘/home-4’ );
update_option( ‘page_on_front’, $LP->ID );
update_option( ‘show_on_front’, ‘page’ );
}elseif ($SignupCounter >= 5) : {
$LP = get_page_by_path( ‘/home-5’ );
update_option( ‘page_on_front’, $LP->ID );
update_option( ‘show_on_front’, ‘page’ );
}?>
- The topic ‘Set front page with php’ is closed to new replies.