WordPress.org

Ready to get started?Download WordPress

Forums

Concurrent templates (6 posts)

  1. gabi_cavaller
    Member
    Posted 5 years ago #

    Hi,

    I would like to use concurrent templates within wordpress.

    Having a slight issue with this and just wondering what your solution would be.

    Templates are relatively easy to use and construct.

    However, if I wish to have a different template for each sub section of the website, it's a real pain. (even if I was able to choose a separate stylesheet it would be ok)

    Picture this scenario.

    http://www.domain.com/banking (red template)
    http://www.domain.com/pensions (blue template)
    http://www.domain.com/mortgages (green template)
    http://www.domain.com/insurance (yellow template)

    Now, I want each of those sections and every page within that to follow the template architecture.

    With Joomla, this is very easy to do, with wordpress, I am lost.

    Now, on the header, I can do an IF/Switch statement saying that if this page = x then the stylesheet = style1.css and so on;

    This method is too time consuming and not flexible enough.

    Any thoughts on this?

    Thank you in advanced for looking this and replying, I have searched through google but have not found the right answer. If you have any questions, please let me know.

    Thank you very much in advanced,

    Gabi.

  2. kennethwatt
    Member
    Posted 5 years ago #

    In header.php, put in a conditional tag, saying if the post is in the category x, use style1.css etc...

    See:
    http://codex.wordpress.org/Conditional_Tags

  3. gabi_cavaller
    Member
    Posted 5 years ago #

    I want to do this for pages mainly as I am using WP as a CMS.

    Thanks for the info though :)

  4. gabi_cavaller
    Member
    Posted 5 years ago #

    I suppose if I do this then it could work, not sure how I can achieve it though :)

    pseudo code!

    If parent = is_page(banking) then style_banking.css

    Based on

    http://www.domain.com/banking/page1
    http://www.domain.com/banking/page2
    http://www.domain.com/banking/page3

    Not quite sure how it would work on

    http://www.domain.com/banking/page1/sub_a

    Thanks,

    G.

  5. gabi_cavaller
    Member
    Posted 5 years ago #

    I think this might help.

    http://www.insitewebsitedesign.com/wordpress-conditional-tags-if-page-parent-and-children

    Need to figure it out.

    Hope this thread will be of help to someone.

  6. gabi_cavaller
    Member
    Posted 5 years ago #

    I think I have figured this out,

    In this instance, I want to have the page 'banking' and any sub-sequent pages to use stylesheet_banking.css

    In the header.php file in the template "test" directory, we need to change the code below;

    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

    To

    <?php if (is_page('banking') || $post->post_parent=="2") { ?>
    <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/stylesheet_banking.css" type="text/css" media="screen" />
    <?php } else { ?>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <?php } ?>

    post_parent is required, I derived this number by hovering over the page in the admin menu and it provided me with the number.

    Hopefully this should be ok,

    This is far from the best way of doing it, however, so far, it is working ok.

    Thanks,

    G.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.