Apply scripts to certain pages

This is an Intermediate tutorial. You should be familiar with PHP.

Headway makes it easy for you to add scripts to your WordPress site with the ability to add scripts to the Header and/or Footer. This option is found in the WordPress » Headway » Options » Scripts/Analytics

conditonal-scripts

What is a little known fact is those boxes also parse PHP. Convenient, we know! A limitation is that if you place scripts or code in those boxes, those scripts or code get added to every page/post/archive you have.

What if you want to apply a script to only one page

Aha. You may think that you have to install a new plugin to do this. Of course, you don’t. All we have to do is make use of WordPress’s already existing conditional tags.

So for example, if you wanted to apply something only on your Portfolio page, you could do something like this:

The is_page conditional tag checks to see if a page is being displayed. You can then fill in the parameters to select one page or multiple pages. For more on is_page, please see the WordPress Codex

Spread the word!

5 Responses

Leave a reply

Copyright © 2016 Vesped Inc. All Rights Reserved. Proudly Powered by Headway and WordPress