How to add code to head of single page/post?
I've been trying to add coding between the <head> and </head> of a single page or post, but I can't figure out how to do this. Can someone help me please?
Thank you Yoni |
What are you trying to add?
You may have to edit header.php and put it there |
On one page I want to add some JavaScript that I need for a converter that I will have on the page. If I try putting the script in the page (post) itself, it disappears after I move from "html" view to "Visual" view, and back again. I'd rather have it in the head anyhow.
On another page, I need to add css for just that page (mapping a photo). I know that the css can probably be added in the HTML/CSS Inserts, but being a newbie to all this, I don't exactly know how. Thanks |
you are going to have to edit the theme code for the first page. You need to edit header.php and just after line 42 (version 3..3) which is
HTML Code:
<?php wp_head(); ?> HTML Code:
<?php if (is_page(35)) {.......}; ?> |
Thanks. I'll try my hand at this and let you know if I get it right.
|
I tried putting the JavaScript in the header.php. At first it didn't work, but my son happen to be visiting at the same time. He played around with it a bit, added something, and got it to work. Thanks.
Now there is a very strange thing happening. After I save the post itself, with the form, Wordpress adds <br /> on every line all by itself. This messes up my whole page. I tried encasing my code with <div>, <p>, and whatever else I could think of, but it doesn't help. I even tried putting it in a table (not that I actually thought it would help - more out of desperation), but still nothing. Is there anything I can do about this, short of disabling wpautop? I am using Wordpress 3.3.1. Thanks |
wordpress has a 'habit' of doing that and people have ben complaining for years. The editor shouldn't add html in that you didn't add. You might try the 'TinyMCE Advanced' plugin
|
I am already using the 'TinyMCE Advanced' plugin. How can that help, short of disabling the wpautop? I really don't want to totally disable it, only fix up the one or two pages that it is messing up. Is there nothing I can do to keep WP from putting a certain <br /> where it doesn't belong?
Thanks |
You might want to post this question over on wordpress.org.
|
OK. Thanks.
|
Would it be possible to add such php modifications to the header using a child theme?
|
All times are GMT -6. The time now is 05:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.