Wordpress - 使用自定义字段调用相关 NivoSlider

发布于 2024-11-26 19:34:43 字数 383 浏览 5 评论 0原文

我目前希望在帖子内容区域之外的每个帖子上使用不同的 NivoSlider,因此我设置了一个自定义字段(“nivo_number”),我可以在其中输入 Nivo Slider 编号并使用

所以,目前我有:

<?php echo do_shortcode;?>("<?php echo get_post_meta($post->ID, 'nivo_number', true); ?>")<?php ; ?>

但是,这只是在网站上输出以下文本

do_shortcode("[nivoslider id='123']")

任何人都可以帮忙吗?如果没有意义,我会尝试进一步解释。

谢谢

I am currently looking to use a different NivoSlider on each post outside of the post content area, so I set up a custom field ('nivo_number') where I can enter the Nivo Slider number and call it within the template using

So, currently I have:

<?php echo do_shortcode;?>("<?php echo get_post_meta($post->ID, 'nivo_number', true); ?>")<?php ; ?>

However this just outputs the following text on the site

do_shortcode("[nivoslider id='123']")

Can anyone help? If it doesn't make sense I will try and explain futher.

Thankyou

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

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

发布评论

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

评论(1

二货你真萌 2024-12-03 19:34:43

我认为第二个 echo 是不必要的,我不知道这是否是问题所在,为什么不尝试一下:

<?php echo do_shortcode(get_post_meta($post->ID, 'nivo_number', true)); ?>

或者

<?php
    $nivo_number = get_post_meta($post->ID, 'nivo_number', true);
    echo do_shortcode($nivo_number);
?>

顺便说一句,自定义字段的值到底是什么?是[nivoslider id='123'] 还是123

刚刚注意到您的语法中有一个错误。这里 echo do_shortcode;?>(" 你要在 ( 之前关闭 ?>,这可能就是原因该代码不被解释。

I think the second echo is not necessary, I don't know if that is the problem, why don't you try:

<?php echo do_shortcode(get_post_meta($post->ID, 'nivo_number', true)); ?>

or

<?php
    $nivo_number = get_post_meta($post->ID, 'nivo_number', true);
    echo do_shortcode($nivo_number);
?>

BTW what's exactly the value of the custom field? is it [nivoslider id='123'] or just 123?

Just noticed an error in your syntax. Here echo do_shortcode;?>("<?php echo you're closing ?> before (, that might be the reason the code isn't interpreted.

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