Permaliens & URLs
Structure recommandée
Configurez dans Réglages → Permaliens. Structure recommandée : /%postname%/
# Via WP-CLI
wp rewrite structure '/%postname%/' --hard
wp rewrite flush Custom Post Types
['name' => 'Portfolios'],
'public' => true,
'has_archive' => 'projets', // URL de l'archive : /projets/
'rewrite' => [
'slug' => 'projets',
'with_front' => false,
'feeds' => false,
],
'supports' => ['title', 'editor', 'thumbnail'],
] ); Redirections 301
# Ou via WP-CLI avec le plugin Redirection
wp redirection add --url=/ancien-slug/ --action-url=/nouveau-slug/ --match-type=url URLs canoniques
Yoast gère automatiquement les URL canoniques. Pour les forcer manuellement :
add_filter( 'wpseo_canonical', function( $canonical ) {
if ( is_paged() ) return $canonical; // Respecter la pagination
if ( is_shop() ) return home_url( '/boutique/' );
return $canonical;
} );