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