WordPress.org

Forums

H1 titles not centering - revert to align left (13 posts)

  1. stardaug
    Member
    Posted 1 year ago #

    Updating to WP 3.9 completely wiped out my visual editor setup.

    But now I am experiencing a big problem since the update.

    Text with any H1 (or H2 etc) tag and "centered" does not stay centered when previewed or published - it reverts to align left.

    If the heading tag is removed, made "paragraph" again say, it centers properly. Its not a theme problem as I have tested this problem with different themes (2011, 2012, 2014) and same problem exists. It also appears to be effecting plugins like WP Edit (which is now replacing Ultimate TinyMCE) for WP 3.9.

    Anyone having the same problem or have any ideas how to fix this? Everything was working fine until I did the 3.9 update last night.

    Thank you.

  2. Undergod11
    Member
    Posted 1 year ago #

    Time to hard code.

    <h1 align="center">This is heading 1</h1>

  3. john_bryan
    Member
    Posted 1 year ago #

    Link?

  4. stardaug
    Member
    Posted 1 year ago #

    Hard coding doesn't help.

    I made a test page to demonstrate the problem: http://ontariostargazing.ca/test-page/

    Thanks!

  5. john_bryan
    Member
    Posted 1 year ago #

    The actual code that's being put onto the page is the following:

    <h1 style="\"text-align:" center;\">H1 title test aligned center<br> (but reverts to left align in WP 3.9)</h1>

    it should be:
    <h1 style="text-align: center;">H1 title test aligned center<br> (but reverts to left align in WP 3.9)</h1>

    That's why it isn't working. I can't say for sure what the reason for that is. If you're using the visual editor, a temporary workaround until you can figure it out would be to go to the text editor and fix the code manually. Did this retroactively hurt the other posts as well?

  6. john_bryan
    Member
    Posted 1 year ago #

    Sorry I missed the part where you said hard coding doesn't help. So you're saying that even though you're typing the code correctly, wordpress is mangling your code? It looks like it's trying to escape the quotes. Do you have any filters being applied to the $content var?

  7. stardaug
    Member
    Posted 1 year ago #

    Well I'm confused! You are right that the "\" show up in code. I looked at the page source.

    If I look at it though in admin within the visual editor "text" tab which shows the code, the "\" are not present.

    So somehow they are being inserted for some reason but only when H1 (or H2, H3 etc) tag is applied. And yes even if I type the code in manually WP mangles it.

    Everything was working fine until I did the update to WP 3.9.

    There is no filters being applied that I am aware of. Never used that.

    As for it effecting previous posts/pages using H1 and centered, I don't believe so. Not that I can see anyhow looking back. Seems to only be affecting new posts/pages now in WP 3.9.

    Thanks for the help so far!

  8. john_bryan
    Member
    Posted 1 year ago #

    What theme are you using? Can you post your functions.php file?

  9. john_bryan
    Member
    Posted 1 year ago #

    Are you using SEO Smart Links? If so go to the settings for that plugin and uncheck "prevent linking in header tags". There is something, either a plugin or a function in your functions.php that is trying to escape those quotes.

  10. stardaug
    Member
    Posted 1 year ago #

    You sir are a smart cookie!

    I did have SEO smart links enabled. I deactivated it and the problem is gone! H1 text centered works. I updated the test page.

    So would I be correct in that its a problem with SEO smart links plugin and WP 3.9 - compatibility?

    Thanks for the help and getting this fixed! :)

  11. john_bryan
    Member
    Posted 1 year ago #

    It would seem that way but I'm not 100%. A header that is linked should look like this:

    <a href="http://www.google.com"><h1>Header</h1></a>

    In order to prevent links in the header you could just do this:

    <a href="\"http://www.google.com\"><h1>Header</h1></a>

    but if you have inline styles like this:

    <h1 style="text-align: center">Header</h1>

    Then whatever method they are using to escape quotes must be a *little* bit too generous because it shouldn't be escaping quotes on the h1 tag itself.

    A workaround you could do would be to put the CSS rules in an external stylesheet.

    Glad you got it worked out. Maybe you should let the devs know there is a bug in their plugin.

  12. stardaug
    Member
    Posted 1 year ago #

    I sent the SEO Smart Links dev an email through his website about it. Gave him the link to this thread. Thank you again!

  13. LEjohn1
    Member
    Posted 12 months ago #

    This problem was giving me fits after the WP update to 3.9. Had to do a work around on each post in order to compensate for this coding dilemma in each heading tag I needed to center. Can't tell you how relieved I was to discover this thread and find out this solution worked for me, as well. Someone should post an article about this situation as I'm sure there are others out there struggling needlessly like I was. Thanks

    https://www.commonsenseforlife.com

Topic Closed

This topic has been closed to new replies.

About this Topic