• Resolved CodePoet

    (@design_dolphin)


    I have searched on this, but I am having a difficult time finding anything as it seems no one has had this problem. Search terms used “if is_category not working”

    I am using the if statement in the footer to call javascript to choose a javascript file for tabs. Depending on the javascript 2,3 or 4 tabs are shown based on what (type of) page you are on. This works fine for the home page and the single posts.

    However, somehow it is not loading the javascript in the categories. It is loading the is_home javascript in the parent category, and nothing in the child category. If I leave out the is_home statement no javascript is loaded in the categories. I have tried is_category, in_category as well (as well as a number of other things).

    In the theme file I have:

    <?php if ( is_home() ) { ?>
    <script type="text/javascript" src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/scripts/widget-easy-tabs-2.js"></script>
    <?php } else { ?><?php } ?>
    
    <?php if ( is_archive() ) { ?>
    <script type="text/javascript" src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/scripts/widget-easy-tabs-3.js"></script>
    <?php } else { ?><?php } ?>
    
    <?php if ( is_single() ) { ?>
    <script type="text/javascript" src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/scripts/widget-easy-tabs-4.js"></script>
    <?php } else { ?><?php } ?>

    Does anyone know how to figure this out, or who can point me in the right direction? Many thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter CodePoet

    (@design_dolphin)

    Debugging turned up that there was an syntax error in the javascript file that was being called in the categories. This syntax error was caused by myself.

    I came to this conclusion after placing the javascript directly into the archive.php. As it was not working, but the link to the javascript was being shown I then proceeded to put one of the other javascripts in. At which point it worked.

Viewing 1 replies (of 1 total)
  • The topic ‘if is_category not working’ is closed to new replies.