• Resolved mattheo

    (@mattheo)


    I have this problem in a specific page of my wordpress website (using the classic editor): when I switch from text editor to visual editor I immediately lose all my links (placed in a div element).

    I give you a detailed example of what happen every time:

    
    <strong>I start editing my page and the section with href looks like this:</strong>
    
    <section class="cards-wrapper">
    <div class="card-grid-space">
    <div class="card">
    <div>
    <h1>Test di Primo Orientamento</h1>
    Un semplice e divertente test di 10 minuti con risultato immediato per avere qualche idea iniziale su quale facoltà potrebbe essere giusta per te.
    <div class="tags">
    <a href="https://www.universitaeuropeadiroma.it/test/"><div class="tag">VAI AL TEST</div></a>
    &nbsp;
    
    </div>
    </div>
    </div>
    </div>
    
    <strong>Then, if I switch to visual editor and come back to the text, it becomes like this</strong>
    
    <section class="cards-wrapper">
    <div class="card-grid-space">
    <div class="card">
    <div>
    <h1>Test di Primo Orientamento</h1>
    Un semplice e divertente test di 10 minuti con risultato immediato per avere qualche idea iniziale su quale facoltà potrebbe essere giusta per te.
    <div class="tags">
    <div class="tag">VAI AL TEST</div>
    &nbsp;
    
    </div>
    </div>
    </div>
    </div>
    

    As you can see the “a” element has disappeared and it’s very annoying because I have to replace all my links every time or switch to a previous edit and losing my recent ones.

    How can i solve this? I would like to be able to switch freely between text and visual editors without losing any code.

    Thanks a lot.

Viewing 1 replies (of 1 total)
  • ?? Try placing your <a> tags inside of the <div> wrappers instead. For example:

    
    <div class="tag"><a href="https://www.universitaeuropeadiroma.it/test/">VAI AL TEST</a></div>
    

    This works fine in my testing. I’m not 100% sure, but I imagine WordPress is stripping out the parent a since it’s an inline element with a block element child.

Viewing 1 replies (of 1 total)
  • The topic ‘I keep losing links when I switch to visual editor in WordPress’ is closed to new replies.