2016-04-28 90 views
0

我正在使用bootstrap和wordpress集成。Bootstrap 3自定义主题中的响应表代码替换

自举集成之前已有<table>的帖子。

为了确保引导的分量,我想补充的包装和类,以取代所有现有职位现有表标签:

<table>...</table>

<div class="table-responsive"> 
    <table class="table table-condensed table-bordered">...</table> 
</div> 

是否有一个功能或过滤器我可以实现在我的自定义主题的functions.php全局代码注入?

回答

0

快速过滤器,你可以在functions.php的使用,不知道这是最好的办法,但将这样的伎俩:

function wp_bootstrap_responsive_table($content) { 
     $content = str_replace(['<table>', '</table>'], ['<div class="table-responsive"><table class="table table-bordered table-hover">', '</table></div>'], $content); 

     return $content; 
    } 
    add_filter('the_content', 'wp_bootstrap_responsive_table');