Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Center area post/pages (http://forum.bytesforall.com/forumdisplay.php?f=32)
-   -   How to add code to head of single page/post? (http://forum.bytesforall.com/showthread.php?t=17284)

megavolt Apr 11, 2012 01:57 AM

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

juggledad Apr 11, 2012 02:51 AM

What are you trying to add?
You may have to edit header.php and put it there

megavolt Apr 11, 2012 03:10 AM

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

juggledad Apr 11, 2012 04:02 AM

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(); ?>
you will add something like
HTML Code:

<?php if (is_page(35)) {.......}; ?>
as for the css, yes put it in the 'CSS Inserts' option, just prefix the CSS selector with 'body.page-id-35' substituting what the page ID is in place ofthe 35.

megavolt Apr 11, 2012 08:14 AM

Thanks. I'll try my hand at this and let you know if I get it right.

megavolt Apr 11, 2012 11:36 PM

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

juggledad Apr 12, 2012 04:19 AM

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

megavolt Apr 12, 2012 05:10 AM

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

juggledad Apr 12, 2012 05:46 AM

You might want to post this question over on wordpress.org.

megavolt Apr 12, 2012 05:55 AM

OK. Thanks.

derekwbeck Aug 29, 2012 01:14 PM

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:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.