自定义 WordPress 摘录未添加

标签

发布于 2024-12-28 05:20:54 字数 772 浏览 2 评论 0原文

对于我正在使用的自定义摘录功能,我遇到了一些棘手的情况。

这里是具有自定义摘录功能的 Pastebin 的链接: http://pastebin.com/gK0AWQbt< /a>

这是使用该功能的博客索引: http://club16.abcguide.com/blog/

另外,我在这里使用的代码是:

这是单页上的帖子,格式正确:http: //club16.abcguide.com/newsletters/jan-2012/

本质上我正在使用的摘录函数不会生成我的

标签围绕元素,我不确定如何修改该函数以使其有效地执行此操作。

另外,如果我可以更好地控制摘录何时结束(甚至可能是每个帖子?如果我能让它识别一个特定的类别并在那里切入......)那就太棒了。

但专注于手头的任务,我迫切需要一个解决方案!

I'm in a bit of a sticky situation with a custom excerpt function I'm using.

Here's a link to the Pastebin with the Custom Excerpt Function: http://pastebin.com/gK0AWQbt

This is the blog index using the function: http://club16.abcguide.com/blog/

Also, the code I'm using here is: <?php echo excerpt(300); ?>

And here's the post on the single page, with proper formatting: http://club16.abcguide.com/newsletters/jan-2012/

Essentially the excerpt function I'm using isn't generating my <p> tags around elements, I'm not sure how I can modify the function to have it do this efficiently.

Also, if I can have more control of when the excerpt ends (maybe even per post? If I could make it identify a specific class and cut there..) that would be amazing.

But focusing on the task at hand, I'm in dire need of a solution!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲鸠 2025-01-04 05:20:54

默认情况下,摘录显示前 55 个字符,并删除所有 html 标签。如果您想增加摘录函数的长度,那么您可以使用如下所示的过滤器,只需将此代码片段添加到主题的functions.php文件中,并将函数调用包装在index.php文件中的ap标签内。

function new_excerpt_length($length) 
{
    return 300;
}
add_filter('excerpt_length', 'new_excerpt_length');

在 p 标记内的 index.php 文件中使用 the_excerpt() 而不是 the_excerpt(300)。

<p class="someclass"> <?php the_excerpt(); ?> </p>

By default excerpt shows first 55 characters and it strips out all html tags. If you want to increase the length of the excerpt function then you can us a filter like one given bellow, just add this code snippet in your functions.php file of your theme and wrap the function call inside a p tag in the index.php file.

function new_excerpt_length($length) 
{
    return 300;
}
add_filter('excerpt_length', 'new_excerpt_length');

Use the_excerpt() instead of the_excerpt(300) in your index.php file inside the p tag.

<p class="someclass"> <?php the_excerpt(); ?> </p>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文