您如何获得 single.php 上的帖子类别?
我试过了:
<h1><?php echo $this->escapeHtml($post->get_the_category()) ?></h1>
&
<?php echo $this->escapeHtml($post->get_category_parents( $cat, true, ' » ' )) ?>
&
<h1><?php echo $this->escapeHtml($post->get_the_category($post->ID)) ?></h1>
这是整个文件:
<?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->get_the_category($post->ID)) ?></h1>
<h1><?php echo $this->escapeHtml($post->getPostTitle()) ?></h1>
</div>
<div class="post-view">
<p class="post-date when"><?php echo stripslashes($this->__('<span class=\"by-author\"> by %s</span> on %s.', $post->getAuthor()->getDisplayName(), $post->getPostDate())) ?></p>
<?php echo $this->getBeforePostContentHtml() ?>
<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; ?>
我正在通过 Magento 的 Fishpig WordPress 集成来开发 WordPress,因此文件路径是 template/wordpress/post/view.phtml。