WordPress.org

Forums

activate script when a category is selected??? (2 posts)

  1. forgetfear
    Member
    Posted 1 year ago #

    im trying to get code to work on pages with a praticular category selected im using javascript inbetween the php but i cant get the code to work for the life of me this is what i have tried so far

    <?php

    $category = get_the_category();
    if (is_category('action')) { ?>

    script code

    <?php } ?>

  2. bemdesign
    Member
    Posted 1 year ago #

    Did you put the JavaScript code inside an HTML <script> tag? Although the best way to include JavaScript libraries and scripts is to use the wp_enqueue_script function.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags