themosis / framework

The Themosis framework core.
https://framework.themosis.com/
GNU General Public License v2.0
671 stars 121 forks source link

Custom Taxonomy rewrite route not found #704

Closed Neidra closed 5 years ago

Neidra commented 5 years ago

Hey everyone, I'm currently looking for rewrite my custom taxonomy but my route return error 404.. My taxonomy

Taxonomy::make("offres-category","offres","Offres","Offres")->set([
 'public' => true, 
'rewrite' => ["slug"=>"offres"],
 'query_var' => true 
]);

My route

Route::get('tax', ['offres_category', function (\WP_Post $post, \WP_Query $query) {
            return 'Hello World!';
        }]);

So without the rewrite i found the page /offres_catergory/<term> but with the rewrite /offres/<term> i found 404.

Someone have an idea ?

ps: wordpress give me the good URI in my taxonomy menu link (rewrited or not)

Neidra commented 5 years ago

I found my answer in wordpress. In fact the tawonomy rewrite is a bit counter-intuitive... We need to create the Taxonomy before the PostType for more explanation the post which helped me.

jlambe commented 5 years ago

@Neidra Sorry I missed your issue. Have you tried to flush the permalink before viewing the custom taxonomy term page after definition ? Generally, when defining custom post type and taxonomy (anything that generates new endpoint on the front-end), you also need to flush the permalinks before going further.

Neidra commented 5 years ago

@jlambe Thanks for the flush precision. I'll forgot it ;)