Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Wordpress Child Themes Custom Javascript
Avatar
Kenn
Somerset, UK
Member
Free Members
sp_UserOfflineSmall Offline
Sep 29, 2014 - 4:14 pm

Good evening all,

My customer has just upgraded their theme for two sites on their multisite installation the main site and the subsite for the forum sitename.com/forum

I have identified an issue with the forum toolset not opening due to a conflict with some Javascript that comes with the theme. On this subsite they aren't using the features that this script activates, however they are on the mainsite.

When you make a wordpress child theme can you have a custom js folder that it will call instead of the default/parent so I can comment out the two offending scripts without breaking the features on the main site.

I hope this makes sense I'm not sure how else to explain it.

Thanks

Avatar
Ike
Sawtry, UK
Member
Free Members
sp_UserOfflineSmall Offline
Sep 29, 2014 - 4:39 pm

I'm 99% sure that child themes only cater for stylesheet, templates and overlays I'm afraid.

Perhaps Mr Papa can clarify this when he is online later, but as far as I'm aware it's down to where the core plugin looks for theme files. It will start by loading the parent theme, then specifically look for these child elements and load them over the top.

Sorry, but like I said, if there is any way of doing it I'm sure we will find out!

Avatar
Kenn
Somerset, UK
Member
Free Members
sp_UserOfflineSmall Offline
Sep 29, 2014 - 4:55 pm

Hi Ike,

Thanks for the reply. I have an idea can you offer your opinion as to if this might work.

If I comment out the offending javascript in the theme file it will work on the subsite /forum

The theme comes with one of those 'Customizer' menu items where you can change the heading background colours, fonts etc. At the bottom of the customizer are two boxes one for custom css and one for custom javascript.

If I then paste in the commented out script into this box on the main site it will allow these features again and allow the toolsets to work again on the forum subsite and I'll ahve another happy customer?

Avatar
Ike
Sawtry, UK
Member
Free Members
sp_UserOfflineSmall Offline
Sep 29, 2014 - 5:02 pm

No I wouldn't have thought so. I'm not really a Javascript guy so I can't say for sure, but if the code is already present, it will need to be that code that is commented out. Adding something commented out will just be ignored and the original code would be unaffected.

Again, I can't be positive, but say if it were PHP that is how it would work.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 29, 2014 - 5:05 pm

you can make your child theme load different js, but it may take modification or use of many parent theme files in the child...  depends on how the parent loads it... if directly from functions.php then you just need a new one in the child...  if the theme has a deep hierarchical structure, you may have to copy over many files just to get to the location where you can change it..

Avatar
Kenn
Somerset, UK
Member
Free Members
sp_UserOfflineSmall Offline
Sep 29, 2014 - 5:17 pm

Hi both,

Thanks for the replies but I think I've got it. I basically commented out the js script from the themes js folder and then loaded it within the theme customizer on the main site only so it's activated on a site basis but not a network basis.

 

customizer.pngImage Enlarger

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 29, 2014 - 5:21 pm

sounds like a good way to go... thanks for the update...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17361
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625