• Resolved kkopchynski

    (@kkopchynski)


    I am editing my site starofyourbirth.com and I want to put clickable buttons on some pages. It runs wordpress 4.0 and a child theme of twentyeleven with just a few modifications. I edit using Firefox. Here is the html code I am using:

    <button style="background-color: #e2a514;" onclick="location.href='http://store.starofyourbirth.com/p1061016394'" type="BUTTON"> Star of Your Birth Store for
    September 3<br /> </button>

    I put this in on the text tab of the editor and save/update.
    If I switch back to the visual tab to do more work, and then come back to the text tab, the onclick="location.href='http://store.starofyourbirth.com/p1061016394'" is gone from the button code.

    I have another site, computerhelpsite.net, that is still on WordPress 3.8.4, also running a child theme of twentyeleven that would have very similar (and not many) modifications of the parent. I do not have the problem of vanishing code on this site.

    I have tried disabling TinyMCE Advanced and that did not help. Nor did telling TinyMCE advanced to stop stripping p and br.
    I also tried making a button with the form tag but the problem persisted.

    Thanks in advance for any help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi there. Is there any reason you specifically need to use a button? Why not just use an anchor standard href and style it th css?

    Alternatively use a php code plugin that renders the shortcode in the_content ()

    Thread Starter kkopchynski

    (@kkopchynski)

    I am not very fluent in css or php, it is pretty easy to add html when I need it, and I need to not have this eat up a lot of my time. It seems reasonable to me to be able to do this and not have WordPress eat the code.

    If i was you i would use this code below, however the best way for wordpress to not eat your code is to disable the auto P filter, or create custom templates which works the best possible way without changing a line of code. Templates are really the way to go especially for custom post types. However enter the code below and im 100% sure it will work. Let me know if you need CSS styles. Its better thana button i promise.

    <a style="background-color: #e2a514;" href='http://store.starofyourbirth.com/p1061016394'" > Star of Your Birth Store for September 3 </a>

    [link moderated – keep support on this site]

    First of all it isn’t the problem of wordpress. It is associated with tinymice check this out. Your onclick code will be removed on switching from text mode to visual mode.

    The above link also specify reason why it do so. You can try the code below, and it will work without any change to functionality or design

    <a style="background-color: #e2a514;" href="http://store.starofyourbirth.com/p1061016394">
    <button style="background-color: #e2a514;" type="BUTTON"> Star of Your Birth Store for
    September 3
    </button>
    </a>

    Please check it and verify ..

    Thread Starter kkopchynski

    (@kkopchynski)

    Waynmeyer: Thank you for the idea, I will try it in the next couple of days. I agree that your strategies are good, I would love to do them sometime, but they involve more time than I have now and I think that what I am trying ought to work. I believe I tried to disable the “auto P filter” in the tinymce settings and it did not work.

    codemovement: Thank you also for the code snip and I will try that soon. I have seen other threads on this, and from those I am given to understand that tinymce is the default editor of WordPress, so to my mind it is a WordPress problem, and specifically a WordPress 4 problem. My WordPress 3 site seems to be not affected.

    Perhaps someone officially connected to WordPress can comment on whether this is intended behavior? Is a more html-friendly editor available that can replace tinymce?

    Thank you

    Thread Starter kkopchynski

    (@kkopchynski)

    Waynemeyer: Yes, this code survives a trip to the visual tab. This looks like a link with a colored background. That was going to be my fallback solution. I already started to do this directly in the visual editor with tinymce advanced plugin. This code will be handy to paste directly with fewer mouse clicks should I ever want or need to do it. Thank you

    codemovement: yes, this is a button that survives going to the visual tab. Thanks very much for a quick html lesson.

    I want a button to give a bit more visual interest to pages lacking in same due to my shallowness of knowledge. Said knowledge has become ever so slightly deeper. Thanks again

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘href codes vanish from html buttons’ is closed to new replies.