鱼猪马本托整合


Fishpig Magento Integration

因为我不是专业程序员,所以我无法为鱼猪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。

感谢任何帮助

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

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

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

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

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

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