今天我在下面创建此功能,以显示有关用户,日期,帖子浏览量,评论等的一些帖子信息..但是当我在其他文件中调用函数时,请告诉我错误说Parse error: syntax error, unexpected '.' in C:\wamp\www\ype\wp-content\themes\yallanpe\functions.php on line 118
请问如何我可以纠正这个错误
<?php
function YPE_show_post_info(
$post_user,
$post_tags,
$post_date,
$post_views,
$post_comments
) {
$post_user = '<span class="dashicons dashicons-admin-users"></span> '.the_author_posts_link();.' ';
$post_tags = '<span class="dashicons dashicons-tag"></span>'.the_category(' / ');.'';
$post_date = '<span class="dashicons dashicons-calendar-alt"></span> '.get_the_date(get_option('date_format'));.' ';
$post_views = '<span class="dashicons dashicons-visibility"></span> '.getPostViews(get_the_ID());.' ';
$post_comments = '<span class="dashicons dashicons-admin-comments"></span> '.comments_number('0','1','%');.'';
?>
<p class="text-muted">
<?php
echo $post_user;
echo $post_tags;
echo $post_date;
echo $post_views;
echo $post_comments;
?>
</p>
<?php
}
?>
答案 0 :(得分:0)
那么它可以在.
;
试试这段代码:
<?php
function YPE_show_post_info(
$post_user,
$post_tags,
$post_date,
$post_views,
$post_comments
) {
$post_user = '<span class="dashicons dashicons-admin-users"></span> '.the_author_posts_link().' ';
$post_tags = '<span class="dashicons dashicons-tag"></span>'.the_category(' / ').'';
$post_date = '<span class="dashicons dashicons-calendar-alt"></span> '.get_the_date(get_option('date_format')).' ';
$post_views = '<span class="dashicons dashicons-visibility"></span> '.getPostViews(get_the_ID()).' ';
$post_comments = '<span class="dashicons dashicons-admin-comments"></span> '.comments_number('0','1','%').'';
?>
<p class="text-muted">
<?php
echo $post_user;
echo $post_tags;
echo $post_date;
echo $post_views;
echo $post_comments;
?>
</p>
<?php
}
?>