https://developer.ww.wp.xz.cn/reference/functions/get_post_type_archive_link/ should do the trick, and as the comments on there note, if it still returns “false” or doesn’t work in some way, make sure that you’ve set “has archive” to true.
Thank you, but I would like to call the link on breadcrumb, it’s mean that the link should be dynamic to each post type so I can not use a string.
Can you help me please figure out this problem? Here is my code:
function my_breadcrumb() {
$postType = get_post_type_object(get_post_type());
echo '<a href="'.home_url().'" rel="nofollow">Home</a>';
if ((get_post_type() || is_single()) && !is_search()) {
echo " » ";
echo '<span style="text-transform: capitalize;">';
echo esc_html($postType->labels->singular_name);
echo '</span>';
if (is_single()) {
echo " » ";
the_title();
}
}
};