【发布时间】:2015-11-20 21:15:34
【问题描述】:
Sublime text 显示错误,当我检查网络浏览器时,这条线错了吗?但我看不到错误 行开始 $output .= '
<article class="post">
<h2><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h2>
<p class="post-info"><?php the_time('F j, Y G:i '); ?> | by <a href="<?php echo get_author_posts_url( get_the_author_meta('ID')); ?>"><?php the_author(); ?></a>| Posted in
<?php
$categories = get_the_category( );
$separator = ", ";
$output = '';
if ($categories){
foreach ($categories as $category ) {
$output .= '<a href="' . get_the_category_link($category->term_id) . '">' . $category->cat_name . '</a>' . $separator;
}
echo trim($output, $separator);
}
?>
</p>
<?php the_content(); ?>
</article>
<?php endwhile;
else :
echo '<p>No content found</p>';
endif;
get_footer();
?>
【问题讨论】:
-
添加我们是否应该猜测错误是什么?
-
你能把错误贴出来让我们看看它说了什么吗?
-
Sublime 文本标记了这一行的 term_id) . '">' 。 $category->cat_name 。 '' 。 $分隔符;我现在不知道为什么?但是在浏览器上出现致命错误:调用未定义的函数get_the_category_link()。我是新手,但希望我能尽可能地解释它。感谢我能得到的所有帮助
-
你得到的错误是因为函数 'get_the_catgory_link' 实际上不是 Wordpress 函数。我认为您正在寻找的可能是
get_category_link()。 -
最后,问题解决了......如果我使用 get_category_link 而不是...... get_the_category 链接它可以工作。