WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Disentangling Theme from Index.php (11 posts)

  1. jskirwin
    Member
    Posted 7 years ago #

    My theme and my index.php are entangled and I'm not sure how to separate them.

    What I don't understand is the relationship between the index.php included in the desired theme (chinared), and the index at the root of the site.

    The site is here: http://www.therazor.org

    Any help is appreciated.

    JSK

  2. yosemite
    Member
    Posted 7 years ago #

    The root one (short and sweet) just passes off to the theme.

    How about describing the problem?

  3. jskirwin
    Member
    Posted 7 years ago #

    The current index.php is anything but short and sweet.
    It's determining the layout structure of the page - based on the theme 3col which it refers to using the @import url( http://www.therazor.org/wp-content/themes/3col/style.css ) command in the header.

    It then formats the display using div tags, UL and LI tags.

    When I change the @import url link, what I get is a messy looking flat-layout of the posts.

    If I replace the index.php with the one that comes with the new theme, the site doesn't display at all and throws an error.

  4. moshu
    Member
    Posted 7 years ago #

    The index at the root of the site is the "short and sweet". (you should learn to read more carefully!)

    You cannot change 'arbitrarily' the link to another stylesheet.
    Every theme has its own index and its own stylesheet. You cannot mix them.

    You should also read about installing themes:
    http://codex.wordpress.org/Using_Themes
    (see 3.1. Adding new themes)

  5. jskirwin
    Member
    Posted 7 years ago #

    Moshu
    My apologies, but the existing index.php at the root of the site is very long and complicated. It is not like the shorter index.php found inside the chinared theme folder.

    Also, I read the installing themes link. According to it I should be able to change the theme within the Admin Console. Whatever I select in the console shows up as the active theme, but no changes appear to the site.

    Thanks for your help.

  6. moshu
    Member
    Posted 7 years ago #

    If you index at the root is NOT "sweet and short" - then somebody messed up your WP install.
    What WP version do you have?

    The root index should be like this:
    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    require('./wp-blog-header.php');
    ?>

    Nothing else.

  7. lhk
    Member
    Posted 7 years ago #

    Hi,

    I'm afraid that you also mix up CSS with template. Any theme consists of at least this index.php (in the theme's folder) AND the CSS file. Only together they function as a theme: the index.php is the architecture (or structure, if you will), the CSS file is what decides on the look and positioning.

    The root index file should never be meddled with. If it isn't as in Moshu's sample, either you or someone else did so obviously not knowing what they were doing.

    A common mistake is uploading a new theme, and placing the index.php of the theme not in the theme folder, but instead in the root folder.

  8. jskirwin
    Member
    Posted 7 years ago #

    Thanks for the feedback.
    I will try Moshu's "short and sweet" index.php when I get time tonight - and update you with the results.

  9. jskirwin
    Member
    Posted 7 years ago #

    I made the change (copied the example code into index.php file) and what's interesting is that my index.php file is down to 97 bytes from over 7000 - yet nothing has changed. Under view source I notice that the code is much "cleaner"; however I still can't change the theme under the Presentation tab.

    I'm thinking a reinstall after a backup is necessary. Any ideas to prevent that are appreciated.

  10. jskirwin
    Member
    Posted 7 years ago #

    Moshu's short and sweet did indeed fix this problem.
    You rock, Moshu.
    Yes you do.
    Go Moshu!
    Go Moshu!
    Go Moshu!

  11. lhk
    Member
    Posted 7 years ago #

    Oh yes, moshu rocks, wait till you get to deal with his encyclopedic knowledge of plugins ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags