[resolved] is_category(array()); (3 posts)

  1. syncbox
    Posted 7 years ago #

    I have a site that uses

    if is_category(array(x,x,x,x)) {
    include stuff;
    else {
    include something else;

    more or less.

    After upgrading to the latest version, I am getting this error for those lines:

    Parse error: syntax error, unexpected T_STRING, expecting '(' in /path to index file of this site

    where it is referring to the first is_category(array()) line

    I cannot see that another ( is required in that line per the documentation for conditionals... am I wrong?

    Is there another way to approach this? My if/ifelse/else code is more complex, but I am keeping it simple for this example... I've simplified it in the page and still get that error, so..

    The actual code:

    if is_category(array(9,10,14,15,16,25,27,28,33,67)) {
    include (TEMPLATEPATH . '/branding-chartus.php');
    elseif is_category(array(12,29,34,59)) {
    include (TEMPLATEPATH . '/branding-ondeck.php');
    elseif is_category(array(21,22,23,24,30)) {
    include (TEMPLATEPATH . '/branding-building.php');
    elseif (is_category(34)) {
    include (TEMPLATEPATH . '/branding-captain.php');
    elseif (is_category(44)) {
    include (TEMPLATEPATH . '/branding-crew.php');
    else {
    include (TEMPLATEPATH . '/branding-default.php');
  2. syncbox
    Posted 7 years ago #

    OKAY, it's like I finally ask here and then I figure it out. Oh well... if that works, then thanks for the help! :)

    The issue was that it needed (is_category(array(x,x,x,x))) {

    someone should update the documentation to indicate that like other conditionals, the parentheses are required around the is_category part, tool...

    It says:

    When any Category archive page is being displayed.
    When the archive page for Category 9 is being displayed.
    is_category('Stinky Cheeses')
    When the archive page for the Category with Name "Stinky Cheeses" is being displayed.
    When the archive page for the Category with Category Slug "blue-cheese" is being displayed.

    I see that farther down, in an example, it's used correctly. Oddly, this didn't cause any problems in an earlier version of WP, only now after updating to the 2.7x version.

  3. advan
    Posted 7 years ago #

    I had same problem, but in-category fixed it.
    My current code is like that:

    if ( in_category('3') ) {
    include 'promo_1.php';
    } elseif ( in_category('4') ) {
    include 'promo_2.php';

Topic Closed

This topic has been closed to new replies.

About this Topic