Only run (non-theme related) javascript on pages it is needed
Hi,
I came across this Thesis-centric item about only adding the Contact Form 7 javascript on the pages it is actually needed... http://andrewnorcross.com/tutorials/...in-for-thesis/ What would be the proper hook to use this in Atahualpa? And it poses the thought more universally about other plugin javascript items and doing something similar and helping page loading.... Thoughts? Ken |
In case you are still looking for an answer, the following code should work.
Copy and paste it at the bottom of "functions.php" just before the "?>", and replace "200" with the page id or slug where C7 is enabled: Code:
//unload C7 |
I have several pages where I have cf7 embeded.
Can I add those id's togeter in the code with separator(,)? |
Quote:
PS: make sure you read properly, I think you have to play with "!". |
Be very careful giving out general advice without testing it
First: you can use the contact form 7 in a text widget - in this case you need it on ALL pages (unless you are using something like 'widget-logic' Second: the code given will probably crash your site it you ever disable the plugin. It should be wrapped in a test for the plugins avaliability. Third: if you are going to make changes to the theme code - remember to document it somewhere you will remember because the next time you update the theme, it will be gone. You might want to try adding t to the actual plugin code. Seems to me the plugin author should give an option for the pages to load this.... |
I think the code works/ i have no errors.
But how can I know the CF7 js an css files are not loaded on the pages, its not supposed to? |
You need to look at the source of the page. grab the page it loads on and the page it doesn't load on and compare the first 50 lines
|
thanks juggledad,
not learned one day is a day not lived the code mimi gave here works for me. The orriginal behinde the link, let my site crash. |
I'd personally put the code in the plugin, that's where I think it should be and atahualpa upgrades wouldn't effect it
|
Hi Juggledad,
Thanks for the text widget thought... Comes under a "Doh!" to me! Don't know if you are aware of the "Advanced Text Widget" plugin. It has a bunch of neat features such as being able to set what pages/posts it appears/doesn't appear, allows shortcodes & php, and can give a custom css style or ID. It can also give those traits to other plugins. Coupled with Atahualpa's custom widget areas, it can be very powerful! Thanks! Ken |
All times are GMT -6. The time now is 02:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.