Forums

Script in header, but only for certain categories.. (2 posts)

  1. sylo
    Member
    Posted 1 year ago #

    hey all

    im using sharethis for wordpress, not the plugin, but just the script.

    in the header we use <script type="text/javascript">var switchTo5x=false;</script> this is to avoid using there new widget.

    which works great all over the site.

    however, we have an exclusive category, and for reasons i need not explain, we need to use there new code, which means removing the above script.

    is there a way to modify the script, so it appears all over the site, EXCEPT for single posts page in the exclusive category?

    thanks

  2. Curtiss Grymala
    Member
    Posted 1 year ago #

    Change the code you mentioned above to look more like:

    <?php
    if( !is_singular() || !in_category( 'Your category name, slug or ID' ) ) {
    ?>
    <script type="text/javascript">var switchTo5x=false;</script>
    <?php
    }
    ?>

    That should do it.

Topic Closed

This topic has been closed to new replies.

About this Topic