1
我无法获取从WordPress管理面板添加的帖子标签。我正在使用fishpig magento扩展,并且一切都很完美。如何获得wordpress post标签在magento中使用fishpig
我使用的代码
$帖= $这 - > getPosts()取帖子;
我需要与每个帖子关联的标签。
请帮忙。
我无法获取从WordPress管理面板添加的帖子标签。我正在使用fishpig magento扩展,并且一切都很完美。如何获得wordpress post标签在magento中使用fishpig
我使用的代码
$帖= $这 - > getPosts()取帖子;
我需要与每个帖子关联的标签。
请帮忙。
您可以通过在帖子对象上调用getTags
方法来获取单个帖子的标签。下面是关于从后视图模板张贴标签的一个片段:
<?php $tags = $post->getTags() ?>
<?php if (count($tags) > 0): ?>
<span><?php echo (count($categories) == 0) ? $this->__('This post was tagged with') : $this->__('and was tagged with') ?> </span>
<?php $it = count($tags) ?>
<?php foreach($tags as $tag): ?>
<a href="<?php echo $tag->getUrl() ?>">
<?php echo $tag->getName() ?>
</a><?php if (--$it > 0): ?>, <?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
你的职位,而不是一个单一的岗位的集合,你可以在一个单独的职位叫getTags
因为你是遍历您的收藏。
foreach($posts as $post) {
$tags = $post->getTags();
}
谢谢!标签即将到来。 – Kajal 2015-04-01 05:02:43
有没有任何功能可以在fishpig中获取相关帖子? – Kajal 2015-04-01 05:22:40
真棒解决方案 – Jalpesh 2018-02-22 15:23:28