Convert a Word Press theme to Drupal

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
paddy_deburca's picture

The example WP theme I am trying to use is sodelicious_black.

page.tpl.php

Combine header.php, page.php and footer.php into on new file called page.tpl.php. In this new page.tpl.php file:

  • Replace your DOCTYPE and HTML lines with
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
  • Replace the TITLE with
    <title><?php print $head_title ?></title>
  • Replace the links to style sheets, RSS news feeds and the such with
    <?php print $head ?> <?php print $styles ?> <?php print $scripts ?>
  • Clean up the page.tpl.php by removing the obsolete calls to get_header() and get_footer()
  • Replace echo get_settings("home") with print base_path()
  • Replace bloginfo("name") with print $site_slogan ? $site_slogan : $site_name
  • Drupal uses syntax such as
        <?php if (isset($primary_links)) {
      print
    theme("links", $primary_links, array("class" => "navmenu primary-links"));
    }
    ?>

        <?php if (isset($secondary_links)) {
      print
    theme("links", $secondary_links, array("class" => "navmenu secondary-links"));
    }
    ?>

       
    for navigation, so replace the navigation block with this code
  • At the beginning of the main content block, Drupal customarily has a bunch of information such as
    <div class="post-main">
      <?php if ($breadcrumb) { print $breadcrumb; } ?>
      <?php if ($mission) { print "<div id='mission'>". $mission ."</div>"; } ?>
      <?php if ($tabs) { print "<div id='tabs-wrapper' class='clear-block'>"; } ?>
      <?php if ($title) { print "<h2". ($tabs ? " class='with-tabs'" : "") .">". $title ."</h2>"; } ?>
      <?php if ($tabs) { print $tabs ."</div>"; } ?>
      <?php if (isset($tabs2)) { print $tabs2; } ?>
      <?php if ($help) { print $help; } ?>
      <?php if ($show_messages &#38;&#38; $messages) { print $messages; } ?>
    </div>
    <?php print $content; ?>
  • The Search blocks are created by Drupal, so remove any code builds a search block – just remember where it was located (top, left, centre, right, footer regions)
  • Replace get_sidebar(); with print $sidebar_left . $sidebar_right;
  • The Recent Posts blocks are created by Drupal, so remove any code that builds a Recent Posts block – just remember where it was located
  • Clean up the code and balance all your DIV‘s and SPAN‘s

node.tpl.php

The single.php will get trimmed to become the node template – node.tpl.php

  • Start off by removing everything that is already in the page template – page.tpl.php – basically everything before and including the while (have_posts()) loop
  • Replace the_ID() with print $node->nid;
  • Replace permalink() with print $node_url;
  • Replace the_title() with print $title;
  • Replace the Author block with
        <?php if ($submitted) { print "<span class='submitted'>" . $submitted . "</span>"; } ?>
       
  • Replace the Category block with
        <?php if ($taxonomy) { print "<div class='terms'>" . $terms . "</div>"; } ?>
       
  • Replace the Comments block with
        <?php if ($links) { print "<div class='post-tags'>" . $links . "</div>"; } ?>
       
  • Add <?php print $picture ?> before the content to support user pictures
  • Replace the_content("Read more"); with print $content;

comment.tpl.php

The comment.php will get trimmed to become the comment template – comment.tpl.php

  • As before, start off by removing everything that is already in the page template – page.tpl.php – basically everything before and including the foreach ($comments) loop
  • Replace comment_ID() with print $comment->cid;

Results

And there you should have an almost working Drupal theme closely relating the previous WP theme.

  • Sodelicious homepage

Only local images are allowed.

  • Sodelicious content

Only local images are allowed.

  • Sodelicious edit

Only local images are allowed.

  • Sodelicious gallery

Only local images are allowed.

  • That’s all folks.

Comments

Thanks a lot for this

toma's picture

Thanks a lot for this tutorial, will bring some good wp themes to drupal :)

sodelicious_black and sodelicious2_green

paddy_deburca's picture

When I have ironed out the rough edges to both sodelicious_black and sodelicious2_green, I will upload both to Drupal Themes.

I also want to start to convert The Fresh theme from http://www.bartelme.at too.

One major part of the conversion process is the update of the WP templates replacing calls to wp functions with calls to similar Drupal functions. I am playing with the idea of creating in template.php, a list of WP functions that then call their Drupal equivalents.

This will make the initial translation easier - giving maximum results for minimum effort. A more 'professional' Drupal theme would, of course, use native Drupal functions.

Paddy.

Copyright?

jayjenxi's picture

I'm pretty new to this so please bear with me. How do I go about dealing with the copyrights of the themes? Should I approach the author and request for permission? Or are there themes that are free for conversions?

Copyright needs to be respected

paddy_deburca's picture

In the case of the Sodelicious_black, the theme is readily available for download from http://www.web2themes.com/2007/07/19/sodelicious-black-version/ and to the best of my recollection (and I just checked ) does not contain a specific copyright notice.

In some themes, there is a copyright.txt file that either includes a GPL copyright notice or a Creative Commons notice. In any case the copyright should be respected.

My feeling on this subject, is that once the theme has been released by the theme author for general consumption, then it should be consumable -- even on multiple platforms.

The designer, http://www.bartelme.at/, includes the gpl.txt as part of themes, opening such themes for conversion to other platforms, but requiring that the GPL copyright remains and that the theme remains open.

A fantastic source of inspiration is http://csszengarden.com/. A lot of the designs contain copyrighted images - meaning that you can convert the theme to Drupal or whatever else you like, but you can't use or even release the final theme to the general public without the express consent of the image creator.

You can also head off to http://www.oswd.org, grab a design and convert it. It is open source, you should be able to do that - but you should also give credit where credit is due. The theme author has spent time and effort creating the theme, comparatively you spend a little bit of time converting the theme - if the author has a 'theme created by' text in the theme, be nice and leave it there.

I am not a lawyer, and I freely admit that I don't know the in's and out's of copyright law. But I try my best to apply the following

  • if it contains a copyright that allows me to convert, so well and good - respect the copyright and if possible convert and maintain the copyright
  • if there is no copyright and the theme is freely available from popular theme sources for public use, convert - but don't add a copyright
  • if there is no copyright and the theme is not freely available - you may take inspiration from the theme but you may not copy the theme
  • if there are statements stating that you may not copy aspects of the theme without the authors consent - again, you may take inspiration from the theme but you may not copy the theme

This is my personal opinion and not a fact of law - please correct me if I am wrong.

Paddy.

Thanks for the information

jayjenxi's picture

I will try to work along these lines, unless someone comes along an point us in a more proper direction.

Legally copyright is in

femrich's picture

Legally copyright is in force regardless of whether there is a notice of copyright or not. What you should look for if you want to use a theme is a license (such as the GPL, in the case of Drupal) that specifically states permission is granted for people to use and convert the files.

Currently I have very little

neopet001's picture

Currently I have very little php knowledge, so maybe this tutorial is missing much thing to me, so I can't finish this by following all these.
I'll very happy and glad is someone could upload a finished pack of this converting theme tutorial.
If luckily I have one and find out what to do with, I'll join and contribute to the group much.
Thanks again dude

Automating Process.

psipi@drupal.org's picture

We're looking at building an app to do theme conversion.. if you want it.. let us know.. if you have wordpress themes to port over to 5 or 6 let us know.. if you're a theming or wordpress guru.. then please get in touch thanks

you can contact us via www.prodrupalthemes.co.uk who will be doing the work.

Hi, Did you succeed in making

Summit's picture

Hi, Did you succeed in making this process automated?
Greetings, Martijn

help me to find or convert a wordpress theme

techGuide1's picture

hi, I'm quite new to drupal and still learing. previously I've worked on wordpess a lot. I like one wordpress theme very much http://themes.mwolk.com/ardent. I want use this for my new drupal site. can anybody suggest any similar or near drupal theme if available. thanks in advance.

is this really working?

abdelatifs's picture

I have tried with another wordpress theme but it seems not to work.
I'm probably missing a step, i don't know wich one.

anybody succedded with this tutorial?

thanks

I followed this process, but

vimalramaka's picture

I followed this process, but after uploading the theme into the themes folder through ftp, my drupal system is not recognizing the theme.

Have you also made an .info

span's picture

Have you also made an .info file?

// Daniel Kvist

aah, I didn't, I'll give a

vimalramaka's picture

aah, I didn't, I'll give a try creating one

Hi,

edwin.trivinos's picture

Before you start converting a wordpress theme to a drupal theme read the drupal theme development guide at http://drupal.org/theme-guide, this is a good resource.

Edwin Alberto Triviños Ramírez
Software Developer - Desarrollador de Software
Cali - Colombia

Thanks for this

Kreapix's picture

Thanks for this

i like this post

captix's picture

i like this post

TurkVideo my drupal video site ;)

tnx a lot!

kaytan's picture

I love drupal! Aoooooh! yeah! :) ;)

This page is linked from the

heather's picture

This page is linked from the Drupal.org documentation.

Did anyone find out information about the licensing issues?

Is there a guideline for people to follow to convert themes from other systems into Drupal?

closure

Matt V.'s picture

Don't forget $closure. That is, replace wp_footer() with print $closure;

Thanks

muratkolukirik's picture

Thank you . Is this work still in Drupal 7

how to convert wp themes into drupal

noor_ullah's picture

i want to use wp ecommerce themes in drupal 8.2.4 and i am new here and now learning drupal 8 ... so can some one give me direction step by step to convert wordpress themes into Drupal apart from docomentation...
thanks in advance

Converting themes to drupal

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week