Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am in the process of creating a wordpress mobile theme for one of my wpmu networks. I have created 2 + pages that show our other sites and a custom login form. Right now i have labeled them page-other-sites.php and page-login.php and created 2 pages in the backend. When you click on the link it loads the page-(slugs).php

Now instead of having to create a page every time is there a way to have my themes function.php file create a set of default pages.?

share|improve this question
    
Could you describe that more in detail? I just don't get around it. –  kaiser Jun 14 '11 at 11:08
    
I have currently 2 pages. One shows other sites and the other shows login they are named so that when i create a page in wordpress with the write slug they load the page. This page does not have any wordpress features just some php coding. What i was wondering is there a way for me to put some code into the functions.php files that will tell wordpress there are some external pages. These pages should load domain.com/login domain.com/other-sites not a full path to wordpress theme directory. Also it will not be a active theme but a theme that gets activated when a mobile devices enters –  xLRDxREVENGEx Jun 14 '11 at 17:17
    
Puh... have a hard meeting behind me, so I'm pretty tired at the moment. (Maybe stupid) Question: You are talking about how to add a set of page-other-sites.php? In this case, take a look at wp_insert_post() –  kaiser Jun 14 '11 at 18:43
    
@kaiser - I looked into the link you sent me and that is somewhat what i am looking for. But i do not wish to create a page in the db permanently but create a dynamic page in a sense. Make wordpress think that this is an actual page. I say this because i am not creating a mobile theme for a mobile blog but creating a mobile theme that a plug in calls if the user-agent is a mobile device. –  xLRDxREVENGEx Jun 15 '11 at 6:24
    
fake pages? They need fake permalinks, IDs, etc. Hard, maybe impossible to do. Simply switch stylesheets or templates. –  kaiser Jun 15 '11 at 14:59

1 Answer 1

up vote 0 down vote accepted

So instead of creating a theme for it i ended up using the template_redirect with an if statement to check the url for a certain thing.

function page_redirect() {
    if ($_SERVER['REQUEST_URI'] == $home . '/other-sites')  {
        require(TEMPLATEPATH . '/includes/other-sites.php');
    }
    if ($_SERVER['REQUEST_URI'] == $home . 'login')  {
        require(TEMPLATEPATH . '/includes/login.php');
    }
}
add_action('template_redirect', 'page_redirect');

Simply all this does is check to see if the requested URI is wpsite.com/other-sites or wpsite.com/login and if this is true then load this template instead. Since i am using some WordPress features though in these custom templates i have also made a check for the title since WordPress will return a page not found title.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.