WordPress.org

Ready to get started?Download WordPress

Forums

Include Code If Certain Class is Displayed (4 posts)

  1. Connor Crosby
    Member
    Posted 2 years ago #

    I am making a theme and I want to display javascript only if a certain class is showing on the page. That way it doesn't load every time. How can I do this? I am not very good with PHP so if you could spell it out, that would be great!! :D

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    only if a certain class is showing on the page.

    where is that class coming from?

    is that an output from body_class() or so?

    or how else could you define the pages, where you want to load the js script?

  3. Connor Crosby
    Member
    Posted 2 years ago #

    I have an image slider and I only want the js to load if the class "slider" is on the page.

    Although, I only plan on having it on the homepage, so maybe the body_class() as well.

    Thanks!

  4. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic