如何在WordPress HTML中删除短代码
问题描述:
I have a custom theme where when I upload an image with caption, the caption shortcode is shown on the page: ...
. Using either of WP\'s default themes, I see no issue. On inspection, WP uses the_content()
, link, so I need to do some stripping. I get my posts with get_page_by_path()
:
1 2 3 4 5 6 7 8 9 10 |
<?php $post = get_page_by_path( $current_page->post_name, OBJECT, \'service\' ); // I assume this would work $content = the_content($post->post_content); //Blank page: echo $content; |
Echoing $post->post_content
shows the caption shortcode as mentioned above. How to get rid of if it? BTW, I need the caption values.
图片转代码服务由CSDN问答提供
感谢您的意见,我们尽快改进~
功能建议
我有一个自定义主题,当我上传带有标题的图像时,页面上会显示标题短代码:< code> ... </ code>。 使用WP的默认主题之一,我认为没有问题。 在检查时,WP使用 the_content()</ code>,链接 所以我需要做一些剥离。 我的帖子有
get_page_by_path()</ code>:</ p>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
&lt;?php $ post = get_page_by_path($ current_page-&gt; post_name, OBJECT,\'service\'); //我认为这样可以工作 $ content = the_content($ post-&gt; post_content); //空白页: echo $ content; < / code> </ pre> <p>回显<code> $ post-&gt; post_content </ code>显示如上所述的字幕短代码。 怎么摆脱它? 顺便说一句,我需要标题值。</ p> </ div> <h5>网友观点:</h5> <div> <p>You can get the post content like this</p> <pre><code>$post = get_post(123); //pass the id of the post $content = $post->post_content; $content = apply_filters(\'the_content\', $content); $content = str_replace(\']]>\', \']]&gt;\', $content); echo $content; |
or
1 2 |
$content=apply_filters(\'the_content\', get_post_field(\'post_content\', 123)); //123 is the post id |
after that just strip the shortcode also you can check if the post is having the shortcode in it or not by has_shortcode
由于网站搬家,部分链接失效,如无法下载,请联系站长!谢谢支持!
1. 带 [亲测] 说明源码已经被站长亲测过!
2. 下载后的源码请在24小时内删除,仅供学习用途!
3. 分享目的仅供大家学习和交流,请不要用于商业用途!
4. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
5. 本站所有资源来源于站长上传和网络,如有侵权请邮件联系站长!
6. 没带 [亲测] 代表站长时间紧促,站长会保持每天更新 [亲测] 源码 !
7. 盗版ripro用户购买ripro美化无担保,若设置不成功/不生效我们不支持退款!
8. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
9. 如果你也有好源码或者教程,可以到审核区发布,分享有金币奖励和额外收入!
10.如果您购买了某个产品,而我们还没来得及更新,请联系站长或留言催更,谢谢理解 !
GG资源网 » 如何在WordPress HTML中删除短代码
1. 带 [亲测] 说明源码已经被站长亲测过!
2. 下载后的源码请在24小时内删除,仅供学习用途!
3. 分享目的仅供大家学习和交流,请不要用于商业用途!
4. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
5. 本站所有资源来源于站长上传和网络,如有侵权请邮件联系站长!
6. 没带 [亲测] 代表站长时间紧促,站长会保持每天更新 [亲测] 源码 !
7. 盗版ripro用户购买ripro美化无担保,若设置不成功/不生效我们不支持退款!
8. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
9. 如果你也有好源码或者教程,可以到审核区发布,分享有金币奖励和额外收入!
10.如果您购买了某个产品,而我们还没来得及更新,请联系站长或留言催更,谢谢理解 !
GG资源网 » 如何在WordPress HTML中删除短代码