child theme problems with adding some scripts

  • merryandhealthy

    #6443

    Hi everyone,

    The problem I get, it takes along time. It is about adding some application scripts which are related to third party websites. When I try to add them into functions.php file in my child theme, I get that classical warning about ” ….Cannot modify header …..sent by (outsourced of …../child-theme/functions.php 12…14…etc ) … /wp-icludes/pluggable.php 880 …. ” . And then I can’t log into my wp-admin !

    Anyway…when I try to contact to my host provider, they told me that cause of my theme. So, I am here to get the right solution. BTW, I try to complete and solve that solution whether if there is an opening before or at the end of ( <?php , <?). So, it didn’t help me.

    I hope, I don’t do anything false…because as far as I know, I should put those kind of codes in functions.php. Well, some codes should be added before <head> or <body> tags and so on. Or not ??!

    Because of this problem, I can’t use some applications properly.

    Well,maybe I wrote a little confusing..but this is my case too… 🙂 So,could anyone help me please ?

    Ohhh…btw..my site is : http://merryandhealthy.com

    Prasanna SP

    #33196

    Where do you want to put your scripts? If it is before the closing </head> tag, you can just go to Graphene Options –> Advanced and throw your code in Custom <head> tags region.

    merryandhealthy

    #33197

    Thank you Prasanna…. Could you tell me also if it should be before the </body> tag, where I have to put the code ?

    Mod

    Kenneth John Odle

    #33198

    It depends on the scripts. Some go in the <head> element, and some parts get added to the <body> tag, and some scripts need to go into a text widget. So it depends on what kind of script you have.

    merryandhealthy

    #33199

    Thanks Kenneth, I had asked that, in child theme where I have to put the script code which should be inserted before the </body> tag ?

    ronangelo

    #33200

    You can use the wp_footer() action hook. It’s located just before the </body> tag.

    merryandhealthy

    #33201

    I get this error always when I click on my dashboard-widgets and gaphene options ;

    ” Warning: Cannot modify header information – headers already sent by (output started at …. /public_html/wp-content/themes/graphene-child/functions.php:12) in ….. /public_html/wp-includes/pluggable.php on line 880 “

    I had installed a quantcast code in my childtheme functions.php file.So, I deleted it but it still appears at me ! The weird thing in this matter, when I delete quantcast code, then on my website disappears another application by another site ( SiteLock Seal ).

    Can anyone help me, please ?

    Mod

    Kenneth John Odle

    #33202
    Quote:
    Warning: Cannot modify header information – headers already sent by (output started at …. /public_html/wp-content/themes/graphene-child/functions.php

    The infamous “Cannot modify header information” error message in WordPress is usually caused by having characters (a space, a line return) before the opening <?php tag or after the closing ?> php tag. Take those out, reupload the functions.php file, and you should be good.

    merryandhealthy

    #33203
    <?php
    function graphene_custom_header_width(){
    return 1165;
    }
    function graphene_custom_header_height(){
    return 99;
    }
    add_filter('graphene_header_image_width', 'graphene_custom_header_width');
    add_filter('graphene_header_image_height', 'graphene_custom_header_height');
    ?>
    <!-- Quantcast Tag -->

    ......

    This is what I have in my function.php. But this works well for a long time,actually since I changed the header image. So, where is the problem in this ? Could you make it clearer for me please ?

    Mod

    Kenneth John Odle

    #33204

    There should be nothing after the closing ?> tag, or you will get this message. So everything after that (quantcast, etc.) must go.

    Scripts do not go in the functions file. It is, by definition, for functions.

    Prasanna SP

    #33205

    I wonder why would need to throw that custom header height and width function to your child theme’s functions.php?! You can change the header image height in Graphene Options itself. And, the header width will be changed according to the container width you’ve set in column width settings.

    merryandhealthy

    #33206

    Ooopss! I really don’t remember it why I did. You’re absolutely right. I think, I was a little tipsy ! :))

    Anyway, I deleted my function.php in my child theme so it is totally free now and after that, except of an app ( sitelock seal ), all other functions work well.

    So…at the moment…

    Could you tell me when I need to insert a snippet code by other websites, where I have to put those codes in my child theme ?

    OK, already I know that, if it is before header I can put it into theme’s advanced option-custom header tag section. But if it should be before </body> tag in theme, so where I have to put it, I dont know.

    Could you make this issue clear for me, please ?

    Mod

    Kenneth John Odle

    #33207
    Quote:
    But if it should be before </body> tag in theme, so where I have to put it, I dont know.

    Try dropping it into an action hook widget area. But honestly, it depends upon the code and what it is supposed to do. It is difficult to give you precise instructions without knowing or seeing this code. Does the code documentation say anything?

    merryandhealthy

    #33208

    Thanks a lot Kenneth for response, actually I’d like to add three apps codes. 2 of them should be inserted before </body> tag in theme and other one before </head> tag. These are simple generated codes by third party website apps. They are quantcast,uservoice and sitelock trust seal apps.

    Which actions hook is the right one,I’m not sure…Could you tell me exactly please ?

    Mod

    Kenneth John Odle

    #33209
    Quote:
    Which actions hook is the right one,I’m not sure

    It depends on what they do. If they merely add functionality to your website, you could put them just about anywhere. (The header widget, for example.) If they need to appear in a specific place on each web page, you’ll have to make some educated guesses about which action hook widget area to use.

    I have never heard of these apps and have no familiarity with them. Is there documentation available for them? (iow, throw us a link).

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.