Created
May 30, 2023 15:59
-
-
Save dantetesta/443bd5c65fd656874774aef5c55f1b38 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function custom_produtos_rewrite_rule() { | |
| add_rewrite_rule( | |
| '^([^/]+)/?$', | |
| 'index.php?post_type=produtos&name=$matches[1]', | |
| 'top' | |
| ); | |
| } | |
| add_action('init', 'custom_produtos_rewrite_rule', 10, 0); | |
| function custom_post_type_link( $post_link, $post ) { | |
| if ( 'produtos' === $post->post_type && 'publish' === $post->post_status ) { | |
| return home_url( "/" . $post->post_name ); | |
| } | |
| return $post_link; | |
| } | |
| add_filter( 'post_type_link', 'custom_post_type_link', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment