WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. forgetfear
    Member
    Posted 3 months 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 3 months 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.

Reply

You must log in to post.

About this Topic

Tags