是否可以拆分the_content()
分成三个大小相等的列?我试图通过获取我发现的代码来实现这一点here
<?php
$content = get_the_content();
$strings = wordwrap($content, (word_count())/3, "<br />"); //Put a {BREAK} every 500 characters
$chunks = explode("<br />", $strings); //Put each segment separated by {BREAK} into an array field
//Printing each chunk in a div
foreach($chunks as $chunk_content) {
echo "<div class=\'col-md-4\'>";
echo $chunk_content;
echo "</div>";
}
?>
这是我函数中的代码。php
function word_count() {
$content = get_post_field( \'post_content\', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
return $word_count;
}
这会创建多个片段,但有三个以上,因此文本在各个列之间仍然可以水平阅读。。。。。。我现在不知道为什么它不应该工作??希望有人能看看!