0

因为我不是专业的程序员,所以我无法为 fishpig magento 运行 ACF 集成。购买了 FishPig-ACF 插件和 ACF Pro。安装了两者并创建了一个名为“repeater”的自定义字段,正如作者在他的手册中描述的那样,我将此代码添加到/post/view.phtml

<?php $value = $post->getMetaValue('repeater') ?>

所以我的view.phtml看起来像这样:

<?php
/**
 * @category    Fishpig
 * @package     Fishpig_Wordpress
 * @license     http://fishpig.co.uk/license.txt
 * @author      Ben Tideswell <help@fishpig.co.uk>
 */
?>
<?php $post = $this->getPost() ?>
<?php if ($post): ?>
<?php $helper = $this->helper('wordpress') ?>
<?php $author = $post->getAuthor() ?>
<div class="page-title post-title">
    <h1><?php echo $this->escapeHtml($post->getPostTitle()) ?></h1>
</div>
<div class="post-view">
    <p class="post-date when"><?php echo stripslashes($this->__('This entry was posted on %s<span class=\"by-author\"> by %s</span>.', $post->getPostDate(), $post->getAuthor()->getDisplayName())) ?></p>
    <?php echo $this->getBeforePostContentHtml() ?>
    <?php $value = $post->getMetaValue('repeater') ?>
    <div class="post-entry entry std<?php if ($post->getFeaturedImage()): ?> post-entry-with-image<?php endif; ?>">
        <?php if ($post->isViewableForVisitor()): ?>
            <?php if ($featuredImage = $post->getFeaturedImage()): ?>
                <div class="featured-image left"><img src="<?php echo $featuredImage->getAvailableImage() ?>" alt="<?php echo $this->escapeHtml($post->getPostTitle()) ?>"/></div>
            <?php endif; ?>
            <?php echo $post->getPostContent() ?>
        <?php else: ?>
            <?php echo $this->getPasswordProtectHtml() ?>
        <?php endif; ?>
    </div>
    <?php echo $this->getAfterPostContentHtml() ?>
    <?php echo $this->getCommentsHtml() ?>
    </div>
 <?php endif; ?> 

但是在前面没有显示 ACF。

感谢您的帮助

4

1 回答 1

1

您已复制并粘贴以下代码:

<?php $value = $post->getMetaValue('repeater') ?>

此代码生成转发器值并将其保存在名为 $value 的变量中。而已。此代码不使用此值执行任何操作或将其打印到屏幕上,因此没有显示任何内容的事实是正确的。

要查看字段内的内容,请尝试以下操作:

<pre><?php print_r($post->getMetaValue('repeater')) ?></pre>

上面的代码会将转发器字段的值打印到屏幕上。假设您为当前帖子的该字段设置了一个值,该值是一个包含您设置的数据的数组。然后,您将需要使用 foreach 循环来循环遍历数组并处理/显示数据。

于 2015-06-13T16:28:19.337 回答