gpt4 book ai didi

php - 自定义短代码始终出现在内容顶部

转载 作者:行者123 更新时间:2023-12-05 09:24:37 24 4
gpt4 key购买 nike

我已经创建了一个自定义短代码并可以获取要输出的信息,但是它没有显示我在内容层次结构中放置它的位置 - 它总是打印在帖子/页面的顶部。关于为什么会发生这种情况的任何线索?

在我的 functions.php 中:

function sc_pdf($atts, $content = null) {
$pdfname = the_field('pdf_title');
$pdfimage = the_field('pdf_file');
$pdflink = the_field('pdf_thumbnail');
return '<p>'.$pdfname.'</p><p>'.$pdfimage.'</p><p>'.$pdflink.'</p>';
}
add_shortcode("peedeef", "sc_pdf");

最佳答案

由于您使用的是 the_field 方法,我假设您使用的是 ACF 插件。

您应该使用 get_field 而不是 the_field 因为 the_field 将输出指定的字段。

function sc_pdf($atts, $content = null) {
$pdfname = get_field('pdf_title');
... etc

关于php - 自定义短代码始终出现在内容顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10188594/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com