最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

loop - How to add custom HTML markup and classes to the_content()?

programmeradmin2浏览0评论

I have HTML template for output from the_content() function. It contains elements with custom classes such as <blockquote>, headings or paragraphs.

<p class="mb-40">Nemo enim ipsam voluptatem quia voluptas sit
    aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione
    voluptatem
    sequi nesciunt. 
</p>

<blockquote class="mb-40 bg-white">
    <i class="zmdi zmdi-quote"></i>
    <p class="mb-0">
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget mag
        dolor. Cum sociis natoque penatibus
        et magnis dis parturient montes nascetur ridiculus ru mus. Do quam felis ultricies nec
        pellentesque eu pretium quis sem. </p>
</blockquote>

I have HTML template for output from the_content() function. It contains elements with custom classes such as <blockquote>, headings or paragraphs.

<p class="mb-40">Nemo enim ipsam voluptatem quia voluptas sit
    aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione
    voluptatem
    sequi nesciunt. 
</p>

<blockquote class="mb-40 bg-white">
    <i class="zmdi zmdi-quote"></i>
    <p class="mb-0">
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget mag
        dolor. Cum sociis natoque penatibus
        et magnis dis parturient montes nascetur ridiculus ru mus. Do quam felis ultricies nec
        pellentesque eu pretium quis sem. </p>
</blockquote>
Share Improve this question asked May 14, 2020 at 18:38 JurajJuraj 1542 silver badges11 bronze badges 3
  • 1 What is it you need help with? You should be able to paste this straight into the Editor in code/text view. – WebElaine Commented May 14, 2020 at 18:43
  • There is no option to pre-format HTML elements? – Juraj Commented May 14, 2020 at 18:47
  • What do you mean, pre-format? As Bob answered, you can usually just target elements by their existing markup, without having to add classes. But in both the Classic Editor and the Block Editor, you can add the classes in the Editor if you really have a need to. – WebElaine Commented May 15, 2020 at 14:51
Add a comment  | 

1 Answer 1

Reset to default 0

This sounds like something that should be handled in CSS without using classes, for examples

article blockquote {
  background-color: #fff;
}

Instead of adding .bg-white to the HTML tag. If you really want to add custom classes you could use a filter or get_the_content() and parse it manually.

发布评论

评论列表(0)

  1. 暂无评论