Title: Set front page with php
Last modified: August 22, 2016

---

# Set front page with php

 *  [A. M. M.](https://wordpress.org/support/users/laius/)
 * (@laius)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/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’ ); }
 * ?>

Viewing 1 replies (of 1 total)

 *  Thread Starter [A. M. M.](https://wordpress.org/support/users/laius/)
 * (@laius)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/set-front-page-with-php/#post-5406479)
 * Apparently I have to use
 * elseif ($foo) ($SignupCounter==1) {
 * instead of
 * elseif ($SignupCounter == 1) : {
 * But it is still not working. I tried something simpler too:
 * $LP = get_page_by_title( ‘Fragen’ );
    update_option( ‘page_on_front’, $LP->ID);
   update_option( ‘show_on_front’, ‘page’ );
 * And even this doesn’t work. There must be something wrong with the basics here.
   Can anyone help? Pleeeeaaasseee

Viewing 1 replies (of 1 total)

 The topic ‘Set front page with php’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [A. M. M.](https://wordpress.org/support/users/laius/)
 * Last activity: [11 years, 12 months ago](https://wordpress.org/support/topic/set-front-page-with-php/#post-5406479)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
