• Resolved Ngô Thắng IT

    (@thangnv27)


    I was created a post with wp_insert_post function.
    Breadcrumb display wrong:
    Home > Uncategoried > Post title
    It must be as following:
    Home > Category Name > Post title

Viewing 8 replies - 1 through 8 (of 8 total)
  • 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?

    Thread Starter Ngô Thắng IT

    (@thangnv27)

    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?

    Thread Starter Ngô Thắng IT

    (@thangnv27)

    *) 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.

    Thread Starter Ngô Thắng IT

    (@thangnv27)

    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>

    • Install and activate Yoast Test Helper plugin;
    • Go to Tools → Yoast Test → Yoast SEO → Reset indexables tables & migrations options to reset it;
    • Run SEO data optimization from the SEO → Tools page.
    • Let us know whether the issue persists.

    Thread Starter Ngô Thắng IT

    (@thangnv27)

    @mazedulislamkhan Thank you for your recommandation.
    @priscillamc ‘s solution did solve my previous problem.
    Thank both for your support!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Wrong breadcrumbs path’ is closed to new replies.