WordPress.org

Ready to get started?Download WordPress

Forums

Theme Switching via GET (2 posts)

  1. robahas
    Member
    Posted 3 years ago #

    Hi, I'm setting up a site where the theme must be tied to the entrance URL. I've got that figured out. My problem is how to have the php run before the template loads. The way it works now, I have to load the default template first and then on the refresh it will display the newly configured one. How can I choose the template before loading?

    Here is the code I'm working with, which I placed in the header of my default template:

    <?php
    
    if (isset($_GET['site'])) {
    
    $theme=$_GET['site'];
    update_option( 'template', theme2);
    update_option( 'stylesheet', theme2 );
    update_option( 'current_theme', theme2 );
    
    } else {
    
    update_option( 'template', default );
    update_option( 'stylesheet', default );
    update_option( 'current_theme', default );
    
    }
    
    ?>
  2. robahas
    Member
    Posted 3 years ago #

    I realized after posting that this is all wrong-headed. I need something that applies to each user. This code changes the theme for all users! Apologies....

Topic Closed

This topic has been closed to new replies.

About this Topic