请问typecho模板如何调用某一文章分类下面的文章呢?

我按照官方文档:

http://docs.typecho.org/themes/category-posts

的说明,调用第五个分类的内容,但是输出的结果不对。

代码如下:

<?php $this->widget('Widget_Archive@myCustomCategory', 'type=category', 'mid=5')->to($categoryPosts); ?>
<?php while($categoryPosts->next()): ?>
    <li><a href="<?php $categoryPosts->permalink(); ?>" title="<?php $categoryPosts->commentsNum('%d Comments'); ?>"><?php $categoryPosts->title(); ?></a></li>
<?php endwhile; ?>

请问问题出在哪里?

我用的1.0版。

阅读 4.3k
2 个回答

已自解决。

<?php $this->widget('Widget_Archive@index', 'type=category', 'mid=5')->to($categoryPosts); ?>
<?php while($categoryPosts->next()): ?>
    <li><a href="<?php $categoryPosts->permalink(); ?>" title="<?php $categoryPosts->commentsNum('%d Comments'); ?>"><?php $categoryPosts->title(); ?></a></li>
<?php endwhile; ?>

widget('Widget_Archive@myCustomCategory', 'type=category', 'mid=5')

改为

widget('Widget_Archive@index', 'type=category', 'mid=5')

@ 后面是为了区分多次调用。

新手上路,请多包涵

Thanks

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进