简体   繁体   English

禁用Wordpress自动 <p> 标签仅用于特定输入元素

[英]Disable Wordpress auto <p> tag for specific input element only

I know I can prevent Wordpress from adding <p> tags entirely. 我知道我可以阻止Wordpress完全添加<p>标签。 However, this is not an option as I have to deal with an entire post archive which counts on these tags, and I am not going back in time to fix every post manually. 但是,这不是一个选择,因为我必须处理依赖这些标签的整个帖子存档,并且我不会及时退回以手动修复每个帖子。

So my question is, how can I disable the auto <p> tag for one page or even one element only? 所以我的问题是,如何禁用一页甚至一个元素的自动<p>标记? Specifically, I am using the CSS code .jumpsection:focus + #section-nav-menu {visibility: visible;} for the HTML below: 具体来说,我将CSS代码.jumpsection:focus + #section-nav-menu {visibility: visible;}用于以下HTML:

<div id="section-nav">
  <input type="text" value="GO TO SECTION" class="jumpsection"><p></p><!-- Grrr...Wordpress :( -->
  <div id="section-nav-menu">
    <ul class="contain">
      <li class="section-nav-item"><a href="#s1">SECTION 1</a></li>
      <li class="section-nav-item"><a href="#s2">SECTION 2</a></li>
      <li class="section-nav-item"><a href="#s3">SECTION 3</a></li>
      <li class="section-nav-item"><a href="#s4">SECTION 4</a></li>
    </ul>
  </div>
</div>

In other words, if I click on the input "GO TO SECTION", the section-nav-menu changes from visibility: hidden; 换句话说,如果我单击输入“转到部分”,则nav菜单的部分将从visibility: hidden;更改为visibility: hidden; to visibility: visible; visibility: visible; which worked before I turned the auto <p> tag back on. 在我重新打开自动<p>标记之前,这种方法已经奏效。 But as you can see in the HTML, Wordpress adds <p></p> after the input element, which to my big frustration breaks the functionality of :focus . 但是,正如您在HTML中看到的那样,Wordpress在input元素之后添加了<p></p> ,这令我大为沮丧,这破坏了:focus的功能。

If temporarily disabling the auto tags is not possible, any workaround for this specific problem (getting this pure CSS on-click dropdown to work) is also very appreciated!! 如果暂时不能禁用自动标记,那么也非常感谢您解决此特定问题的任何解决方法(使此纯CSS单击下拉菜单正常工作)!

You can use the ~ selector. 您可以使用~选择器。 Like this: 像这样:

.jumpsection:focus ~ #section-nav-menu {
  visibility: visible;
}

Demo here 在这里演示

Here is some info about the ~ selector 这是关于〜选择器的一些信息

You may be interested in this little plugin . 您可能对此小插件感兴趣。

Don't Muck My Markup 不要渣My我的标记

Here's the official description : 这是官方说明

Don't Muck My Markup lets you disable all auto-generated HTML markup from your posts and pages on a page-by-page basis. 别乱糟糟我的标记允许您逐页禁用帖子和页面中所有自动生成的HTML标记。

In a nutshell: 简而言之:

It adds a very simple box to the editor page that allows you to turn off the automatic mark up that the WordPress engine inserts. 它在编辑器页面添加了一个非常简单的 ,该允许您关闭 WordPress引擎插入的自动标记

The options include 选项包括

  • turning off all automatic mark up for all pages (which you don't want to do ) 关闭所有页面的所有自动标记功能(您不希望这样做)
  • turning off all automatic mark up for the specific page you're editing . 关闭您正在编辑的特定页面的所有自动标记。 (which is what I understand you want to be able to do) (据我了解,您希望能够这样做)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM