Support » Themes and Templates » Help modifying a one-file theme

  • Resolved amarie


    My biz partner and I hired a freelance WP theme developer to create a WP 2.x theme for us based on our design … a 3-col theme with a header and footer. Neither of us knew much about WP or blogs or themes or PHP, still don’t, but now that the site’s up and running we want to make some changes and have some time to learn about WP.

    Here’s the thing. In the codex and in various plugin documentation, they refer to “standard” theme files like sidebar.php, header.php, function.php, pages.php and so on. I see all these and more in our server in the folders for the classic theme and the default theme.

    But in *our* theme folder, there’s only this:
    /images/ [a folder]

    That’s it. So I opened up a copy of our index.php on my computer and it appears the developer just included the actual code and php for header, footer, the loop, and the two sidebars (each a div, one called navigation, one called column)in this one index.php file. The linked .css file positions everything.

    What does this apparently non-standard way of creating a theme mean for us mean long-term? I mean, there isn’t even a functions.php file in there and I know a few plug-ins call for tweaks to this file. We can’t use widgets either, is that correct? We would also like to have diff. right sidebars (the “column”)depending on the category that’s being shown. I’m not sure how to do that …

    I don’t know enough about WP or themes to even know if this is something we should be concerned about or not. For example I’m not sure how we’re able to create Pages just fine — admin has no problem with it — even though there’s no page.php in the theme folder.

    Thanks for any advice/clarification…


Viewing 6 replies - 1 through 6 (of 6 total)
  • A “one file” theme isn’t all that unusual. And there’s no reason you can’t copy that index.php to single.php or page.php and customize as desired if the urge strikes you.

    I wouldn’t say that what was built for you was all that non-standard really.

    WP has a Template Hierarchy that will determine what file is used for various displays. Long story short, index.php is the fall back for all.

    The disadvantage is exactly what you already noticed: less room for customized display of posts in different views. To be able to have different sidebars and other similar customization – you will have to “slice” the one-file index in different template files.
    This can give you a general idea how it is done.

    Okay, well I feel a little better now, thanks HandySolo. I was getting that sinking feeling there for a while.

    Right now the index.php file contains an “if” statement within the div for the right-hand column so that a chunk of HTML (our “about this site” text/images) only appears on the home page right sidebar and not in the right sidebar of any other page of the site.

    <?php if ( is_home() ) : ?>

    <div id="about">
    [code for our about information]

    <?php endif; ?>

    … and then it goes on to the HTML for the rest of the right sidebar that is common for all pages.

    If I wanted to swap in a diff. chunk of HTML for the “about” area, depending on what category page the user was on, how would I do that?

    I have a php-savvy friend who could help me … I’m thinking we would just add “elseif”s to this area… pseudo code:

    if the page = home, put the about section here
    elseif the page = podcast category, put the subscribe to podcast stuff here
    elseif the page = this category or this category or this category, put X here
    elseif the page = this Page, put Y here

    … and then go on to the common html for the remainder of the right sidebar.

    Would that work? Or would it better/faster/easier to maintain if we used includes (rather than the actual HTML)?

    Question 2: So if a plugin we want to use says “edit functions.php like this,” could I just put a duplicate of the functions.php file into our theme folder (copied from the default theme folder)? Ditto for other missing files that index.php doesn’t take care of?


    2a. Yes, you can copy over the functions.php
    2b. Unless you cut the original “complete” index.php file (see above) – the additional template files will not work.

    elseif the page = podcast category, put the subscribe to podcast stuff here
    elseif the page = this category or this category or this category, put X here
    elseif the page = this Page, put Y here

    The first link I provided talks a bit about category specific templates and has a link for more info. That might be a good way to handle some of your scenarios.

    Thanks moshu and Handy, I’ll give that a shot!


Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Help modifying a one-file theme’ is closed to new replies.