• Resolved y4

    (@y4)


    I’ve created an archive.php. The file is getting different designs for each category. I also want to make a design for tags page in blog.

    Please look at the following codes which is in archive.php:

    $category = get_the_category();
    $cat_id = $category[0]->cat_ID;
    
    if ( cat_id == 1 and !is_tag() ) {TEMPLATE FOR CATEGORY 1}
    if ( is_tag() ) {TAG PAGE TEMPLATE}

    I know the “!is_tag” doesn’t work. But, what should i use instead of it? That’s all problem. If i resolve this, i could be resolved all of the other “if not” problems as “is_day()”, “is_month()” and “is_year()”.

    I hope i could explain my problem. Thanks in advance.

Viewing 8 replies - 1 through 8 (of 8 total)
  • MichaelH

    (@michaelh)

    Wouldn’t it be more like this?

    if ( $cat_id == 1 && !is_tag() ) {TEMPLATE FOR CATEGORY 1}

    Related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy
    Conditional Tags

    Thread Starter y4

    (@y4)

    yes, of course. i said the different designs used for each category.

    MichaelH

    (@michaelh)

    “yes, of course” meaning yes you agree with the code change I suggested?

    Thread Starter y4

    (@y4)

    did you suggest something?

    if you did, you suggested what i already wrote.

    and you asked whether something would be more like that. i said “yes, of course” for that question.

    so, the problem is “!is_tag”. it doesn’t work. and, what must be instead of it? or, is it a code which works? i hope you know the solution of this problem.

    MichaelH

    (@michaelh)

    Works fine for me in the WordPress Default theme’s wp-content/themes/default/archive.php when viewing a category archive.

    <?php
    if ( ! is_tag() ) {
      echo 'this is not a tag archive';
    }
    ?>

    Please note that I did suggest a line of code DIFFERENT than your line of code.

    Thread Starter y4

    (@y4)

    it did NOT work, either.

    i applied my code with your code change. but it hasn’t currently worked.

    it displays the results of both a “if” template, which is for a category, and the “if”, which is for “is_tag”.

    so, the problem is going on. and “! is_tag” doesn’t work.
    where is the wrong?

    Perhaps the problem is that you could be receiving query vars for both at once..

    In that case, your code just needs to account for that.. ie..

    if( is_tag() && is_category() ) {
    // whatever
    }
    elseif( is_tag() ) {
    // whatever
    }
    elseif( is_category() ) {
    // whatever
    }
    else {
    // It's neither, so do whatever
    }

    Thread Starter y4

    (@y4)

    i just found the is_category function while searching. but thanks a lot to you though ??

    by the way, “is_category” must be in front of other conditions as the is_tag in your code.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘the “if it’s not tag” problem’ is closed to new replies.