Is there any filter to change the permalink structure and set it to post name after theme activation automatically?

i have custom posts but won't work without changing the permalink?


  • 2
    Why do your custom post types not work without changing permalink structure? Maybe solve that problem instead?
    – Milo
    Jun 14, 2018 at 15:12
  • hmm because custom post get generated like - www.website.com/custom-post-type/the-page-under-custom post but is the permalink structure is different means after saving the post the url becomes like -www.website.com/1212sax2
    – user145078
    Jun 14, 2018 at 17:12
  • @LatheeshVMVilla is possible that you custom post are not properly registered. Jun 14, 2018 at 21:44
  • i used the same method as mentioned in the wordpress codex..whether permalink for the custom post works even if the permalink structure is changed?
    – user145078
    Jun 16, 2018 at 14:08

1 Answer 1


The flush rewrite rules to be considered while when custom posts are generated.

More info here https://codex.wordpress.org/Function_Reference/flush_rewrite_rules

This worked for me as when my theme is activated every thing works file

/* Flush rewrite rules for custom post types. */
add_action( 'after_switch_theme', 'flush_rewrite_rules' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.