dougua9328 2015-07-12 07:33
浏览 23
已采纳

<p>标签跳过第一段

I have the following code which puts my Wordpress content into 2 columns (Bootstrap 3 framework). It splits the content at the 'read more' tag.

functions.php

function split_content() {
global $more;
$more = true;
$content = preg_split('/<span id="more-\d+"><\/span>/i', get_the_content('more'));
// first content section in column1
$ret = '<div id="column1" class="col-md-6">'. array_shift($content). '</div>';
// remaining content sections in column2
if (!empty($content)) $ret .= '<div id="column2" class="col-md-6"><p>'. implode($content). '</p></div>';
return apply_filters('the_content', $ret);
}

this puts it all in < p > tags etc. except for the first paragraph. All the filters/etc don't seem to affect the first paragraph of the first column, but works fine for everything else

  • 写回答

1条回答 默认 最新

  • douchen7366 2015-07-12 07:40
    关注

    You need to replace your 6th line with the below code. As you can see the first paragraph is generated by 6th line and thus missing p tag. It is mentioned in the comments section of the code as well.

    $ret = '<div id="column1" class="col-md-6"><p>'. array_shift($content). '</p></div>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度