简体   繁体   English

删除字幕简码表单类别存档-Wordpress

[英]Remove caption shortcode form category archives - wordpress

I have some strange problem in wordpress 我在wordpress中遇到一些奇怪的问题

How can i remove this [caption] short code for my category archive list http://start.neomedia.info/category/sport/ 我如何为我的类别存档列表http://start.neomedia.info/category/sport/删除此[标题]短代码

This caption works great in one article http://start.neomedia.info/diego-lopez-jestem-lepszy-niz-casillas/ but not on list it's appear and thats really strange. 该标题在http://start.neomedia.info/diego-lopez-jestem-lepszy-niz-casillas/上的一篇文章中很好用,但没有出现在列表上,那真是很奇怪。

what should i add in code ? 我应该在代码中添加什么? ( a replace function ?) (替换功能?)

I am not talking about CSS solution because this will not work. 我不是在谈论CSS解决方案,因为这行不通。

Can someone help ? 有人可以帮忙吗?

Although you didn't provide any code, I assume that you are using the_excerpt function in your category page. 尽管您没有提供任何代码,但我假定您在类别页面中使用了the_excerpt函数。

Caption is a shortcode, and by default shortcodes doesn't work in the excerpt. Caption是简码,默认情况下,简码在摘录中不起作用。 If you don't specify an excerpt for your post and let WordPress deal with it automatically, it will strip the caption and the image completely. 如果您没有为帖子指定摘录并让WordPress自动处理,则它将完全去除标题和图像。 As it is mentioned in the docs: 正如在文档中提到的:

An auto-generated excerpt will also have all shortcodes and tags removed. 自动生成的摘录还将删除所有短代码和标签。

Therefore, I assume that you entered manually the excerpt while creating the post, and copied and pasted there the caption code. 因此,我假设您在创建帖子时手动输入摘录,然后将其复制并粘贴到标题代码中。 That will prevent WordPress from removing it automatically, but it will treat it as normal text, and not a caption. 这样可以防止WordPress自动将其删除,但会将其视为普通文本,而不是标题。

To bypass this issue, you can add the following filter into your functions.php file, which will force the caption (and any other shortcodes) to be processed: 要绕过此问题,您可以将以下过滤器添加到functions.php文件中,这将强制处理标题(和其他任何短代码):

add_filter('the_excerpt', 'do_shortcode');

Please note that as far as I know the above will work only with manually added excerpts; 请注意,据我所知,以上内容仅适用于手动添加的摘录; it will not affect the automatically generated ones, where the shortcodes & tags will continue to be ignored. 它不会影响自动生成的代码,在这里短代码和标签将继续被忽略。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM