WordPress.org

Forums

Grandchild theme ? (5 posts)

  1. Tim Rogers
    Member
    Posted 4 years ago #

    hello everybody
    I'm trying to create hierarchical theme structure, for efficient coding:

    master theme (include all php files)
    -- child theme - for a general page structure (index.php, style.css)
    ---- grandchild theme - for colors and images (style.css, images dir)

    for changing my sites as a combination of structure theme and colors theme.

    But, when I point the third theme Template to the child theme, I get the page mixed up, with code from both templates, but more code, that I don't know where it comes from (ie. header code).
    I tried to search, but didn't find any documentation about grandchild themes.
    Is there someone here who did that before, and maybe can help me?

    Thanks
    Tomer

  2. govpatel
    Member
    Posted 4 years ago #

    I do not understand the reason behind complicating and creating grandchild theme as my understanding is that a child is enough to make your changes to the theme and use templates from parent theme.

  3. Tim Rogers
    Member
    Posted 4 years ago #

    I have a website's company, and we sell template websites (means the client don't get a specific design, he only can choose a ready one).
    In order to enlarge the designs pool, I wanted to create 5-10 template themes (with different page structure - navbar on top, on the left, 3 columns, etc.), and then 15-30 color themes, so you can choose a combination of structure and colors, from the pool. (75-300 different designs, totally).

    This may sound compatible with themes and child themes.

    BUT, I wanted to take out all the shared parts of the structure themes, to a "master" theme, which will include 404 page, search results page and other staff, which is shared for all themes, and I don't want to copy from theme to theme.

    Therefore, I need 3 levels, and that "grandchild" theme.

    Any Solutions how to do that?

  4. superpotion
    Member
    Posted 3 years ago #

    Essentially the problem is this. I am using a WordPress network/multi-site to build a website that has multiple sections. The sections all have a common layout and functionality, but each section has its own menus & content (solution: multi-site) and color-scheme (solution: grandchild themes).

    I built a child theme with twentyeleven as the parent. I was hoping to have a grandchild theme for each of the sections/sites, each with a style.css to reflect the unique color scheme and backgound images for some elements.

    But WordPress does not support grandchild themes (Error: The parent theme is missing. Please install the "child" parent theme), so how do I solve the problem?

    Answer: Do it using symbolic links in Unix/Linux.

    Create each 'grandchild' theme directory.

    $ cd /home/www/public_html/wp-content/themes
    $ ls
    child twentyeleven
    $ mkdir grandchild
    $ cd child
    $ ln -s * ../grandchild
    $ cd ../grandchild
    $ rm style.css images  # remove these symlinks ...
    $ mkdir images #  ... replacing with real objects
    $ cp ../child/style.css .

    Now we can edit style.css and have unique images for the 'grandchild' theme. And for any other changes, say you have a unique landing page, simply remove the symbolic link and create a new file landing-page.php in the 'grandchild' theme folder.

    Any updates to TwentyEleven will show up in the child and grandchild, and any updates to the child will show up in the grandchild... This is exactly what we want. :)

    Perhaps 'replicant' would be a better descriptor than 'grandchild'?

    PS. If you don't have shell access to your server, you can write a simple PHP script to make the links - using symlink() in a foreach loop.

  5. superpotion
    Member
    Posted 3 years ago #

    Forgot to add that the 'grandchild' theme's style.css imports both the parent and child style.css files, like so...

    /*
    Theme Name: grandchild
    Theme URI: http://potion.co.za/
    Description: TwentyEleven child - grandchild theme
    Template: twentyeleven
    Version: 1.0
    Tags: two-columns, two-menus
    */
    @import url('../twentyeleven/style.css');
    @import url('../child/style.css');
    #page {
        margin-top: 20px;
        background: url("images/page-background.jpg") top center no-repeat #FFFFFF;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic