• I need to edit – precisely to insert some code into header.php file of my active theme.

    Trying to do so from WordPress gives an error.

    From what I gather, plugin “Subscribe to Comments Reloaded” is known to cause the problem. I know I could deactivate it.

    However, it seems simpler to me to just download the header.php to my computer, edit it, then upload the edited version.

    THE QUESTION:
    Is there any reason I shouldn’t do it this way? Could it cause some problems?

Viewing 9 replies - 1 through 9 (of 9 total)
  • I don’t think it is a problem to download, edit and then upload header.php.

    But remember that it is best to make any modifications to the theme files by creating a child theme and then copying files to be modified to the child theme folder.

    You may be already doing this, but I just wanted to mention that.

    Thread Starter Relja

    (@relja)

    Thanks for the reply.

    As for the theme changes, I just don’t edit theme. Sticking to a theme that suits me (Catch Base) the way it is. This is the first time I’m editing anything. It’s for an ads serving purpose – I don’t think there will be any edits apart from that in the near future. Just copy/paste 10 lines of code that are required to be put “just before the </head> tag in the header.php”.

    My plan was to:
    1) download the original header.php, and keep an original copy.
    2) make a copy for editing.
    3) instert something like this:
    original content goes to here
    // begining of my code editing – comment so I can edit it back easier
    required code by the app
    //end of my editing
    </head> (the original content continues here)

    4) upload the edited version to the server.

    • This reply was modified 6 years, 8 months ago by Relja.
    • This reply was modified 6 years, 8 months ago by Relja.

    what error WordPress gives to you?
    is it not letting you save the file?
    it could be file write permission error.

    “If you modify a theme directly and it is updated, then your modifications may be lost. By using a child theme you will ensure that your modifications are preserved.”

    It’s worth taking a read at the Child Themes documentation, where you will find other helpful resources listed at the bottom of that page, for example “How To Make A Child Theme“.

    If you don’t want to go through the process of creating a child theme yourself, here are two plugins that can do it for you:

    I hope this helps!

    Thread Starter Relja

    (@relja)

    @vinit
    The error has been discussed in WordPress help forum. From what I gathered, many have encountered the problem since the relatively recent WordPress updates.

    Also, I had found a text explaining that “Subscribe to comments reloaded” plugin can also cause the problem.

    WordPress editor takes long time trying to update, returning this:

    “Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.”

    @armando Duran

    Thanks, I will take your advice and see about a Child Theme – sounds like a better, more sensible long term solution, even if it takes some more time right now.

    Hi @relja, if you have a screenshot with the error with StCR I can help you to fix it, only if the problem is related to StCR. I haven’t seen an error editing the theme files in the WordPress backend.

    Thread Starter Relja

    (@relja)

    @reedyseth

    The error doesn’t mention StCR, just writes, below the update button:
    “Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.”

    So then how can you confirm the error is coming from StCR? As a Developer and Sysadmin you only trust what you can see on the logs and errors given by the software, on this case is PHP, so enable the error display and debug settings and you will get a more detail error, if this is not the case then you will have to hire an expert on this matter to assist you finding the real error and then report it back to here.

    Thread Starter Relja

    (@relja)

    Makes perfect sense. Not sure how to enable debuging, nor if it would be fine to do on a live site? :/

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Editing header.php?’ is closed to new replies.