We are sorry to hear that you’re having trouble with our plugin. Did you configure the category correctly from the SEO → Search Appearance → Breadcrumbs (tab)?
In addition, can you please confirm whether you have assigned the relevant post into the relevant category as well?
I understand.
The above error won’t happen if I use Admin Editor to add new post.
We’re confused. Do you mean the breadcrumbs show incorrectly when you’re not logged in or when you’re not logged in as an administrator?
*) Method 1:
I create a post with function wp_insert_post in functions.php
Return wrong breadcrumb path
*) Method 2:
I logedin to Administrator Dashboard and create a post with WYSIWYG editor
Return correct breadcrumb path
===============================
Can you test case and fix it?
Hi @thangnv27,
Since adding the breadcrumb using the WordPress editor is working correctly, we suspect that there’s an error in the code. We tested inserting a post and the category using 'post_category' => array(2) as one of the arguments and the category breadcrumbs appeared as expected.
You can find more details in the WordPress code reference about wp_insert_post.
After inserting I used wp_set_post_categories function:
===========================================
$post_id = wp_insert_post($my_post);
if ($post_id > 0) {
wp_set_post_categories($post_id, $category);
}
Thanks for sharing the relevant code snippet with us. Can you please confirm whether the issue persists when resetting the Indexables tables and migrations after publishing a post by using the wp_insert_post() method?
You can find the relevant steps below:
ul>
@mazedulislamkhan Thank you for your recommandation.
@priscillamc ‘s solution did solve my previous problem.
Thank both for your support!