• Resolved Mike

    (@mduschak)


    We have a plugin that allows users to customize the slug of a custom post type via the register_setting() function.
    We run a flush_rewrite_rules() on save of the settings page.

    This works great.

    The problem is that the Yoast table ‘_yoast_indexable’ does not update the ‘permalink’ column for the custom post type.

    This results in breadcrumbs not pointing to the correct url for our custom post type.

    Question:
    Is there a Yoast hook or filter we can fire after we flush_rewrite_rules() that will update the permalink value stored in the ‘yoast_indexable’ table?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @mduschak,

    Just to be sure that we understand, you’d like to manually call a function to update the Yoast indexables for a certain post after you’ve changed the post slug dynamically. Is that correct?

    Also, can you give us more details about what hooks or functions you’re using to change the page slug? We may need to forward this to the developer team for more information.

    Thread Starter Mike

    (@mduschak)

    Hi @priscillamc,

    That is correct, we created a custom admin settings page that allows users to change the slug for a custom post type.

    Example is a post type called ‘programs’ which would have a slug of ‘programs’. On the settings page users can change the slug to something like ‘academic-programs’ so the slug would be ‘www.site.com/academic-programs’. The slug value is saved the the DB using register_settings(). We fire flush_rewrite_rules() whenever the settings page is saved/updated. Using register_post_type_args() $args[‘rewrite’][‘slug’] we are able to use our new slug value from the DB for the rewrite slug.

    Currently all permalinks for the custom post type update exactly as expected where ever they are in use but for one instance: Yoast breadcrumbs.

    The Yoast issue we are experiencing directly relates to custom breadcrumbs not updating with the new permalink for the custom post type.

    We had expected that the permalink saved in the indexables table would be updated when flush_rewrite_rules() is run, but that is not what is happening.

    I have found that after changing and saving the slug on our settings page, we then go to the Yoast settings page /admin.php?page=wpseo_titles#top#post-types and click ‘save’ the breadcrumb permalink will be updated with the correct slug.

    If we do not perform this manual step, the breadcrumbs will continue to use the old version of the slug.

    Our hope is there is a function that allows us to programmatically trigger this permalink update whenever our settings page is updated.

    Thank you for your help.

    • This reply was modified 3 years, 9 months ago by Mike.
    • This reply was modified 3 years, 9 months ago by Mike.
    Thread Starter Mike

    (@mduschak)

    In an effort to give you more details to work with, I will add that the xml sitemap generated by Yoast correctly respects/reflects the changes that we make to the slug using the examples listed in my previous reply.

    Unfortunately Yoast breadcrumbs do not repect/reflect the slug changes.

    I hope this helps.

    To anyone else experiencing this issue, I have found a solution using the wpseo_breadcrumb_links filter to intercept and update the breadcrumb. This eliminates any issues caused by the yoast_indexable table being out-of-date and full of incorrect data.

    Storing and managing duplicate data across multiple database tables is a terrible idea.

    Plugin Support Michael Ti?a

    (@mikes41720)

    Hi,

    When you run the SEO data optimization (which includes the Yoast indexables), it’s expected to be a one-time process, as it should already store the values in a table in the database for which we use to output as front-end meta.

    It sounds like your set-up is highly customized in order to generate the customized slug of the CPT and then running the flush_rewrite_rules() command. We’re not sure if this is expected behavior that it isn’t updating the breadcrumb links, but we would recommend logging a bug report on GitHub — https://yoast.com/help/how-to-write-a-good-bug-report/

    Plugin Support devnihil

    (@devnihil)

    We are going ahead and marking this issue as resolved due to inactivity. If you require any further assistance please create a new issue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Update CPT slug after flush_rewrite_rules’ is closed to new replies.