douti0687 2015-02-18 11:43
浏览 14

一页上有不同的摘录选项

I want to be able to display various excerpt length, and different read more buttons that will say: "really? found out more" and "get more info" to different sections of the same page.

So far I found out from the wordpress codex that I can define excerpt length but I haven't been able to use it the right way :(

I defined custom excerpt length in my functions.php like this:

//Adds custom excerpt length
function custom_excerpt_length( $length ) {
    return 15;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

But when I add this to my desired section on the page the length of the excerpt affects to the whole page. This is my section's code:

<div class="col-md-6">
    <span class="dark-text"><?php the_excerpt('custom_excerpt_length'); ?></span>
</div>

How can I use that custom excerpt length just here and use one of my read more buttons from the beginning of my question?

Thanks guys!

  • 写回答

1条回答 默认 最新

  • dongpanbo4727 2015-02-18 11:51
    关注

    you should check this below link which are create custom multiple excerpt lenght.

    Multiple excerpt lengths in wordpress

    It should work for you .

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)