wordpress编辑器在<a> tag</a> </span>中删除/重新格式化<span>标记

时间:2013-07-27 19:32:32

标签: wordpress wordpress-plugin tinymce editor

我有这段HT​​ML:

<p>
<a class="home_link sel_link" id="home_link_01" title="ABOUT" onclick="javascript: return home_link_click(1);"><span>ABOUT</span></a><br /> 
<a class="home_link" id="home_link_02" title="TEXTS" onclick="javascript: return home_link_click(2);"><span>TEXTS</span></a><br /> 
<a class="home_link" id="home_link_03" title="STILLS" onclick="javascript: return home_link_click(3);"><span>STILLS</span></a><br /> 
<a class="home_link" id="home_link_04" title="AUDIO" onclick="javascript: return home_link_click(4);"><span>AUDIO</span></a><br /> 
<a class="home_link" id="home_link_05" title="VIDEO" onclick="javascript: return home_link_click(5);"><span>VIDEO</span></a><br /> 
<a class="home_link" id="home_link_06" title="ARTWORK" onclick="javascript: return home_link_click(6);"><span>ARTWORK</span></a><br /> 
<a class="home_link" id="home_link_07" title="TRANSCRIPTS" onclick="javascript: return home_link_click(7);"><span>TRANSCRIPTS</span></a>
</p>

现在,当我把它放在Wordpress(3.5.1)deafult编辑器[或安装了TinyMCE Advanced(3.5.8)]并发布/更新它时,它很好。但是,一旦我第二次更新页面(在进行其他更改之后),上面的代码将重新格式化为:

<a class="home_link sel_link" id="home_link_01" title="ABOUT" onclick="javascript: return home_link_click(1);"></a><span>ABOUT</span>

<a class="home_link" id="home_link_02" title="TEXTS" onclick="javascript: return home_link_click(2);"></a><span>TEXTS</span>

<a class="home_link" id="home_link_03" title="STILLS" onclick="javascript: return home_link_click(3);"></a><span>STILLS</span>

<a class="home_link" id="home_link_04" title="AUDIO" onclick="javascript: return home_link_click(4);"></a><span>AUDIO</span>

<a class="home_link" id="home_link_05" title="VIDEO" onclick="javascript: return home_link_click(5);"></a><span>VIDEO</span>

<a class="home_link" id="home_link_06" title="ARTWORK" onclick="javascript: return home_link_click(6);"></a><span>ARTWORK</span>

<a class="home_link" id="home_link_07" title="TRANSCRIPTS" onclick="javascript: return home_link_click(7);"></a><span>TRANSCRIPTS</span>

知道该做什么/不做什么?

1 个答案:

答案 0 :(得分:0)

你的问题是你的<a>标签中没有href属性,所以我认为WordPress的TinyMCE编辑器将它们视为命名锚点而不是链接。

你需要做的只是在你的链接中加上一个假的href =“#”,它应该可以正常工作,如下:

<p>
<a href="#" class="home_link sel_link" id="home_link_01" title="ABOUT" onclick="javascript: return home_link_click(1);"><span>ABOUT</span></a><br /> 
<a href="#" class="home_link" id="home_link_02" title="TEXTS" onclick="javascript: return home_link_click(2);"><span>TEXTS</span></a><br /> 
<a href="#" class="home_link" id="home_link_03" title="STILLS" onclick="javascript: return home_link_click(3);"><span>STILLS</span></a><br /> 
<a href="#" class="home_link" id="home_link_04" title="AUDIO" onclick="javascript: return home_link_click(4);"><span>AUDIO</span></a><br /> 
<a href="#" class="home_link" id="home_link_05" title="VIDEO" onclick="javascript: return home_link_click(5);"><span>VIDEO</span></a><br /> 
<a href="#" class="home_link" id="home_link_06" title="ARTWORK" onclick="javascript: return home_link_click(6);"><span>ARTWORK</span></a><br /> 
<a href="#" class="home_link" id="home_link_07" title="TRANSCRIPTS" onclick="javascript: return home_link_click(7);"><span>TRANSCRIPTS</span></a>
</p>

我已对其进行了测试,虽然它会删除<p><br>标记,否则会保留<spans>标记中的<a>

所以,是的,只是添加href属性,似乎。