WordPress.org

Support

Support » Themes and Templates » static text below category archives tag

static text below category archives tag

  • babelianquest

    @babelianquest

    Hi,
    I’m working on the Twenty Ten theme / WP 3.4.2 and I need to add a static text below the category archives title.

    Let me explain:
    if I click on one category (e.g. named “cats”), i’m landing on a page containing all articles linked with the “cats” category. Just below the title: “Category Archives: Cats”, I’d like to add a quotation.

    For that purpose, I added a div block in the category.php file just after </h1>. After refreshing the page, it works, BUT the same quotation appears for any category and not only for the “cats” category.

    After some researches on google, i came accross this piece of php code, that i adapted:


    <?php $post = $wp_query->post;
    if (in_category('categ-1')) {
    include('category_templ1.php')):
    }
    elseif (in_category('categ-2')) {
    include('category_templ2.php'));
    }
    else{
    include{'categoy.php');
    }
    ?>

    I created two files: one per category with one different quotation on each. These files are located in the same directory as the category.php file which will remain the same (id est without the quotation).

    My question is: where should I put this? In the “function.php” file?

    Thanks in advance for you help

Viewing 9 replies - 1 through 9 (of 9 total)
  • esmi

    @esmi

    Forum Moderator

    Are you using a child theme?

    babelianquest

    @babelianquest

    I am, but i only put the “child” css file in the other directory (i called it 20-10-child): wp-content/themes/20-10-child/style.css.

    The two files category_templ1.php and category_templ2.php are still located along the other php files of the Twenty Ten Theme (wp-content/themes/twentyten).

    I did it so as to see them in the admin panel.

    Maybe that’s the wrong method?

    esmi

    @esmi

    Forum Moderator

    Yes – that’s wrong. Your custom template files should be in the child theme’s folder.

    babelianquest

    @babelianquest

    Ok, it’s now fixed! The files are in the right folder.

    What should be done now with the php code to redirect the category page?

    esmi

    @esmi

    Forum Moderator

    Sorry? What code?

    babelianquest

    @babelianquest

    Well a code used to change the template of each category.

    I need to let a quotation appear below the “category archives” title which depends on the category selected.

    I found on the net this one (adapted for the context):


    <?php $post = $wp_query->post;
    if (in_category('categ-1')) {
    include('category_templ1.php')):
    }
    elseif (in_category('categ-2')) {
    include('category_templ2.php'));
    }
    else{
    include{'categoy.php');
    }
    ?>

    But i do not know where i should insert this? Inside function.php?

    Any help is appreciated !

    esmi

    @esmi

    Forum Moderator

    Are you referring to categories or archives? What do these _templx files contain?

    babelianquest

    @babelianquest

    Let’s imagine i’m clicking on one category, then i’m landing on a page with links to all articles related to this category.

    I’m referring to this kind of pages!

    And the _templ files contain almost the same content as the category.php file: i just added a <div> after the title, which includes a quotation.

    So i have one file per category, in the child theme folder

    <–Sorry for my lame english–>

    esmi

    @esmi

    Forum Moderator

    Then you don’t need multiple category template files. Something like:

    <?php if( is_category( 'foo' ) $quote = '<div class="quote>[Quote A here ]</div>';
    elseif( is_category( 'bar' ) $quote = '<div class="quote>[Quote B here ]</div>';
    else $quote = '';
    echo $quote;?>

    in the main category.php template file should be enough.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘static text below category archives tag’ is closed to new replies.
Skip to toolbar