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

css - Is there any known plugins that would replace WordPress classes in editor with their Bootstrap 4 equivalent?

programmeradmin1浏览0评论

Context: I'm using WordPress as a backend for article writing on a non-wordpress site (built with Laravel, using Corcel to access the data, if that matters). That website is built with Bootstrap 4, and when fetching the posts written in WordPress, there's a couple of classes that is added by WordPress for styling that, of course, does not translate to Bootstrap.

For example, when centering an image in a post, WordPress adds an aligncenter css class that, if rendered in a Bootstrap (4) context, does nothing. To acheive the centering of the image, I would have to manually add the mx-auto d-block classes to each and every images of the post... In every post. But I'd like this to be done automatically.

I did try to install some themes in WP that where specifically designed for Bootstrap 4, thinking it might force the editor to use the wanted classes, but it doesn't.

This question/answer provides a couple of example on how it could be acheived but before reinventing the wheel, I'd like to know if there is any know plugin that would do this? Or even some stylesheet that I could add to the non wordpress site that would understand WP classes in a bootstrap context maybe ?

A quick search in WordPress' plugin page and Google returns nothing in that regard, but I fear that I'm just lacking of the right search terms for a successfull search.

Context: I'm using WordPress as a backend for article writing on a non-wordpress site (built with Laravel, using Corcel to access the data, if that matters). That website is built with Bootstrap 4, and when fetching the posts written in WordPress, there's a couple of classes that is added by WordPress for styling that, of course, does not translate to Bootstrap.

For example, when centering an image in a post, WordPress adds an aligncenter css class that, if rendered in a Bootstrap (4) context, does nothing. To acheive the centering of the image, I would have to manually add the mx-auto d-block classes to each and every images of the post... In every post. But I'd like this to be done automatically.

I did try to install some themes in WP that where specifically designed for Bootstrap 4, thinking it might force the editor to use the wanted classes, but it doesn't.

This question/answer provides a couple of example on how it could be acheived but before reinventing the wheel, I'd like to know if there is any know plugin that would do this? Or even some stylesheet that I could add to the non wordpress site that would understand WP classes in a bootstrap context maybe ?

A quick search in WordPress' plugin page and Google returns nothing in that regard, but I fear that I'm just lacking of the right search terms for a successfull search.

Share Improve this question asked Dec 17, 2020 at 15:59 Jean-Philippe MurrayJean-Philippe Murray 1237 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I will provide an answer, because it works, but I'll be waiting for an answer that more straightfully answer my question (about a pluging, specifically).

What I realized after posting this question is that the starter theme that uses Bootstrap I installed thinking it would force the editor to use Bootstrap classes do display the post correctly, in a Bootstrap context (basically rendering, in the example in the question, aligncenter correctly). So I went on and took its CSS, stripped unwanted classes (CSS resets for example), and applied this sheet to my article pages only.

It works !

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论