سلام
من از پشتیبانی سورس کدای استاد رو گرفتم و هنگامی که سایتم رو لود میکنم بهم یک ارور میده:
Fatal error: Cannot redeclare get_related_posts() (previously declared in C:\laragon\www\test\wp-content\themes\clab\app\user\functions\posts.php:3) in C:\laragon\www\test\wp-content\themes\clab\app\user\functions\posts.php on line 26
حتی کدا رو هم مجدد بررسی کردم و دیدم که درستن ، در واقع همون کدای استادن
مشکل کار کجا است؟ و این ارور یعنی چی؟
کدای post.php من هم اینااست:
<?php
function get_related_posts($post_id, $catgory_id, $count = -1)
{
$related_posts_collection = [];
$related_posts = new WP_Query([
'cat' => $catgory_id,
'posts_not_in' => [$post_id],
'posts_per_page' => $count
]);
if ($related_posts->have_posts()) :
while ($related_posts->have_posts()) : $related_posts->the_post();
$related_posts_collection[] = [
'title' => get_the_title(),
'category' => get_the_category(),
'thumbnail' => get_the_post_thumbnail(),
'link' => get_the_permalink(),
'excerpt' => get_the_excerpt(),
'authror' => get_the_author_meta('display_name'),
'avatar' => get_avatar_url(get_the_author_meta("ID"))
];
endwhile;
wp_reset_postdata();
endif;
return $related_posts_collection;
}
لطفا راهنمایی کنید