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 '18 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 – Latheesh V M Villa Jun 14 '18 at 17:12
  • @LatheeshVMVilla is possible that you custom post are not properly registered. – Fernando Baltazar Jun 14 '18 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? – Latheesh V M Villa Jun 16 '18 at 14:08

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' );
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.