WordPress.org

Ready to get started?Download WordPress

Forums

Multiple single.php (3 posts)

  1. ic3y
    Member
    Posted 8 years ago #

    Hi everyone,

    I have four languages on my blog, this works without any problem. I just created a category per language. These categories are published on theire own page. So i also have four pages. You can simply create a new template for the page.php so every page with it's own language has it's own header in that language.

    However, when the visitors clicks on a headline it will always use the same single.php thus that page can only be one language..

    Is it possible to have multiple templates per single.php just like page.php has?

  2. ic3y
    Member
    Posted 8 years ago #

    I just found this:

    http://codex.wordpress.org/Category_Templates

    Iam going to check if it works. If it does, WP is even better than i already thought.

    Other suggestions are still welcome in case it doesn't work :)

  3. nieuws
    Member
    Posted 8 years ago #

    Found the solution together with ic3y. For everyone else with the same question here is how we did it.

    Duplicate your single.php, call it single1.php. Edit the original single.php to something simular as this:

    <?php
    $post = $wp_query->post;
    if ( in_category('11') ) {
    include(TEMPLATEPATH . '/single2.php');
    } else {
    include(TEMPLATEPATH . '/single1.php');
    }
    ?>

    In this example, if a certain post is created in category 11 it will load single2.php (you can create anything you want for that page). If it's not 11 the script will go to single1.php you're original file.

Topic Closed

This topic has been closed to new replies.

About this Topic