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

twitter bootstrap - Why <i> items could not be enclosed within <li> items in WordPress?

programmeradmin2浏览0评论

I was creating a guide in WordPress with the Classic Editor. In the guide, I was about to create a separate section here,

/

I referred to some bootstrap snippets available on the internet. I pasted this code in the Text area

<ul class="list-inline small">
              <li class="list-inline-item m-0"><i class="fa fa-star text-success"></i></li>
              <li class="list-inline-item m-0"><i class="fa fa-star text-success"></i></li>
              <li class="list-inline-item m-0"><i class="fa fa-star text-success"></i></li>
              <li class="list-inline-item m-0"><i class="fa fa-star text-success"></i></li>
              <li class="list-inline-item m-0"><i class="fa fa-star-half-alt text-success"></i></li>
</ul>

When I switch to the visual section, the i element gets removed. How to prevent elements from getting removed while switching to the visual section?

I was creating a guide in WordPress with the Classic Editor. In the guide, I was about to create a separate section here,

https://www.payuoc/home-furnishing-decor/best-mattress/

I referred to some bootstrap snippets available on the internet. I pasted this code in the Text area

<ul class="list-inline small">
              <li class="list-inline-item m-0"><i class="fa fa-star text-success"></i></li>
              <li class="list-inline-item m-0"><i class="fa fa-star text-success"></i></li>
              <li class="list-inline-item m-0"><i class="fa fa-star text-success"></i></li>
              <li class="list-inline-item m-0"><i class="fa fa-star text-success"></i></li>
              <li class="list-inline-item m-0"><i class="fa fa-star-half-alt text-success"></i></li>
</ul>

When I switch to the visual section, the i element gets removed. How to prevent elements from getting removed while switching to the visual section?

Share Improve this question asked Mar 25, 2020 at 6:54 Nirmal KUmarNirmal KUmar 11 silver badge2 bronze badges 1
  • Try adding &nbsp; in between the span tags – RiddleMeThis Commented Mar 25, 2020 at 13:34
Add a comment  | 

1 Answer 1

Reset to default 0

You need a shortcode to deal with the removal of the <i> from the editor.

You'll have to add this to your functions.php of your theme/child theme.

function dd_fontawesome_shortcode ($atts) {
    $args = shortcode_atts( array(
        'icon' => '',
        'size' => '14',
        'color' => '#000',
        'type' => 'fa'
    ), $atts ) ;

    $output = '<i class="'.$args['type'].' '. $args['icon'] .'" style="font-size:  '. $args['size'] .'px; color: '. $args['color'] .';"></i>';

    return $output;
    }
add_shortcode ('dd-icon' , 'dd_fontawesome_shortcode');

Usage is like [dd-icon icon="fa-star"] or [dd-icon icon="fa-star" size="18" color="#eee"]

发布评论

评论列表(0)

  1. 暂无评论