- This topic is empty.
May 21, 2013 at 4:26 pm #44946
I am currently building a WordPress theme where I am using jQuery to append and prepend some ornate images to a h4 tag with a class of beechheader in the page template markup. This idea was based on something I saw when Chris Coyier was creating the website for [http://kailinyong.com](http://kailinyong.com/ “”)
Before turning the static html files into a WordPress theme, the code below worked great. The code is in a separate file called test.js
The jQuery code appears to be enqueued correctly in the functions file and I have called the test.js code using
right before the closing body tag. Here is the code that worked fine statically but now doesnt work
// prepend some images to the headers
I tried adding
`` this is wrong
it should be:
Here’s a [most basic template using HTML5 Boilerplate](https://github.com/alenabdula/clean_wp/), I wrote for someone on these forums… See if you can get some helpful tidbits. -AlenMay 22, 2013 at 4:35 am #135983
Sorry I didn’t notice that I hadn’t copied all the code into the code section of my original question. My code actually mirrors yours. What I am looking for help with is how to implement the JQuery code which is located in the whatever.js file into a wordpress theme without the need for hard coding the entire path to the image.
Hope my explanation is clear and I can get to the bottom of this.May 22, 2013 at 7:55 pm #136114
I can post the site somewhere live and would be grateful for some ideas.May 23, 2013 at 5:54 am #136161
Many thanks Melindrea.
My site is at [http://sandpit.jonathanbeech.co.uk/](http://sandpit.jonathanbeech.co.uk/ “”)
Would you need to log into the WordPress admin area to view the functions.php file where the wp_localised_script does its stuff? I can supply those if needed.
If you view the source file of the sandpit page, there is a my data variable enclosed in someMay 23, 2013 at 6:40 am #136168
Thank you so much for that, you’re a star! I would get you a drink or two if you were here.
I got rid of the redundant code and it works great for me too, I imagine you are aware of how such issues can be grating for us developers. Its been a good learning experience troubleshooting this code, ie look at the console!
I will make this a topic for my blog when I get it running. The wp_localize_script posts I found on line seemed to be aimed more towards plugin developers.