Support » Themes and Templates » Changing theme

  • Good evening, guys!

    I wanted to ask your help to realize one of my ideas.

    My website works on some theme. I can access it by typing just a domain name (so by index.php).
    Can I make following trick?

    If someone will access my website, as an example, from index2.php – website will load a different style.css (or different theme) for homepage and all following pages, that user will watch.

    For example, by index.php I can see a full version of my blog, but by index2.php I will see all pages of blog without, let’s say, sidebar.

    Can we realize it?

    Thanks for your help and hope for answers!
    This question is really interesting for me, because it opens new huge posibilities for my blog 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • Up? 😀

    Yes… Let’s say you have a page called index2.php you can put this code in it, in the same root folder where index.php is (please note I do not use wordpress)


    Once you have done that, test to see if you can access the website as you usually would. If that works… then inside your wordpress files, look for this line of code… (I looked at the source code of this website to make the line of code below)

    <link href=”” type=”text/css” rel=”stylesheet” />

    Now… that is the link to the external spreadsheet… So where ever it is inside your wordpress files you should be able to do somthing like this.

    if($_SERVER[‘PHP_SELF’] == ‘index.php’){
    echo ‘<link //—-the rest of the code for the first spread sheet.
    echo ‘<link //—-the rest of the code for the second spread sheet.

    This is a link to the php documentation on the server variable. This tells you the entire “State” of the application or the information which is currently held in the SERVER global variables.

    Variables are just a fancy term for something that contains data. Keys and Data.

    So try doing this as well… find the line of code that has the link to the external spreadsheet, and then, print this in the php code and see what the variables look like when you call it through the index.php file and then see what it looks like through the index2.php file.

    // NOTE: I tried to put a pre-format tag here but the comments took it out so I am writing the greater than and less than html traingular brackets in square brackets instead…


    That way you can get the right filename and path for use with the if/else switch which decides which html line to print.

    Is this making sense to you? I am subscribed and pretty much taking easy today so let me know if I can help.

    I am not a wordpress, so there is always a possibility that there are many other different ways to do this.

    Let’s say I understood your idea, except for this part:

    if($_SERVER['PHP_SELF'] == 'index.php'){
    echo '<link //----the rest of the code for the first spread sheet.
    echo '<link //----the rest of the code for the second spread sheet.

    If you are not occupied, can I contact you somewhere please?

    Well, lets explain it in English. When the website runs… you just need a way to add a “marker” or there need to be something different about the internal code that you can use to tell the website to do something different.

    In this case, you want to make a different file name called index2.php

    It could also be done by accessing a different domain name too, right?

    Or even a different sub-domain.

    So the only thing we have to do is be able to know when the different domain, sub-domain or file is called. Right?

    the $_SERVER variable holds all the information coming through the website, in terms of which domain is being called, which file name is being called, even the IP address of the the person accesing the website, so if you wanted to, you could serve somebody different content that everybody else.


    if($_SERVER[‘PHP_SELF’] == ‘WHAT I EXPECT’){
    // do this
    // do that

    Is that making sense?

    Try printing out this… I use it all the time, it is the best way to get a good eye view of what is happening. Only don’t use square brackets. Use HTML brackets. So put this in two different files… The first one in index.php



    and then in index2.php do the same and you will see the print out from each one is different.

    So that makes the

    if(){ }else{}

    statement make a decision based on what the $_SERVER globals are equaling.

    I am not really anywhere except on twitter or on email, but you can contact me at – I am not skype or anything.

    I am contacting you right now.
    If anybody has another ideas, suggestions or other stuff – don’t hesitate to comment here 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Changing theme’ is closed to new replies.