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 know my way around WP as probably an intermediate user. In the near future, I will have to integrate the design of a template from a completely different theme into a theme I'm currently using. The idea is to keep the look of the front page of one theme the same, and the use the design of another theme's regular blog post pages -- and sort of hack them together.

My question is the following: Would the best course of action be the following:

  1. Define a new template page in the preexisting theme and copy the code from the other theme's template page across to that;

  2. Check for any associated files (e.g. header.php/footer.php, rename them so as not to interfere with the theme's preexisting files), copy them across, and then change the names of the links in the template page accordingly;

  3. Obviously copy the stylesheet, JS and any associated images across.

Or is there a better way to do this?

Many thanks.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Think Twice

I have to start by saying that this seems like a really odd idea. Having a front page that's totally different from the rest of the site will break a lot of user expectations and cause confusion. Is it really two completely different themes or do you just want a custom layout on the front page? If the latter, a custom implementation honestly might be simpler. This is particularly the case if there are advanced theme options or metaboxes used to maintain the front page. I'm going to stick only to front-end issues here as that's really the only thing I can safely make assumptions about. But let's assume it's not.

Copy all the necessary templates

I'd use the non-home theme as the main theme and integrate the front into there. So, from the "front page theme" determine which files you need to include. If there's a front-page.php (assuming you're using a static front page), you'll copy that. (Save the old front page with a new name if there was one.) In the new front-page.php file, look for anything included with include(), require(), get_template_part(), get_sidebar(), get_footer() etc. From the front page theme, copy all of those files into your new theme. For all of these files, include a suffix (e.g. sidebar-front.php, header-front.php). Finally in your copied front-page.php change functions to use the suffixed version (e.g. get_sidebar( 'front' ))

Conditionally Load Scripts & Styles

Now, in your main theme's functions.php file, you'll load the scripts and styles you'll need onto the correct pages. Copy any scripts and stylesheets you know are used on the front page theme. Again, suffix theme to make sure there's no overlap.

Now, add conditional wp_enqueue_scripts() and wp_enqueue_styles() calls to load your stylesheets. If either header.php is linking the stylesheets, delete those lines. Your code will look something like this:

function wpse_58889() {
    if( is_front_page() ) {
        wp_enqueue_style( 'style_front', get_template_directory_uri() . 'style-front.css' );
    } else {
        wp_enqueue_style( 'style_front', get_template_directory_uri() . 'style.css' );
        wp_enqueue_script( ...... );
    }
}
add_action( 'wp_enqueue_scripts', 'wpse_58889' );

This step will involve moving any existing styles and scripts enqueued in the main theme's functions.php into those conditionals so they don't conflict with other styles on the new front page.

Theme Functionality

As I said, I'm not even going to guess on what's required for this. You'll have to do a lot of poking around and copy over any register_sidebar() calls relevant to the front page along with theme options and metabox stuff. At this point in the process you may run into a LOT of file-dependencies and you may end up integrating half the old theme into the new one. The whole time, you'll have to continue watching out for naming conflicts in files, functions, and more!

Conclusion

In the simplest cases, this process won't be too hard, but if you're new to PHP and WordPress Theming (more the latter than the former, imho), this could get really nasty really fast. Even though a lot of these changes are straight-forward in the abstract, there are a lot of places where a small oversight could really make things haywire for a while.

Good luck.

share|improve this answer
    
Hi there. I'm not new to PHP and I've worked with WP enough to realise that it's silly: unfortunately, it's not really my decision and this is precisely the implementation that I've been told to work with. I'm aware that it won't be easy, but I was wondering if there was any shortcut to this that I wasn't aware of previously. This is a pretty simple case IMO, we just want to use two templates throughout the site (the home template from one theme and a default page template from the other). Thanks for your advice; I really appreciate it. –  marchon Jul 18 '12 at 16:01

If you want to completely copy the design then you can create custom header and footer files such as header-custom.php and footer-custom.php. These custom header and footer files can be used by passing the slug of custom files as a parameter to the functions in wordpress. e.g.

get_header('custom');

and

get_footer('custom');

Please note that you'll have to create separate page templates that can be used to have different styles of pages. See http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates for help on creating custom page templates.

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.