admin管理员组

文章数量:1122833

So I wanted to create custom permalinks for my pages for an SEO project I’m working on.

I can customise the permalink fine as I have downloaded a custom permalink plugin, but the YOAST plug-in I’m using has a different slug that it takes.

For example, I want to change an existing post from:

/sports-therapy-services/

To

/services/sports-therapy/

So I can do this part fine. However, when I save changes, the slug that shows on YOAST is:

sports-therapy-services

It is replacing the slash with a dash.

Is there a way so I can put in slashes into the YOAST slug? Or is there a way to make the YOAST slug match what I have put into the custom permalink?

So I wanted to create custom permalinks for my pages for an SEO project I’m working on.

I can customise the permalink fine as I have downloaded a custom permalink plugin, but the YOAST plug-in I’m using has a different slug that it takes.

For example, I want to change an existing post from:

/sports-therapy-services/

To

/services/sports-therapy/

So I can do this part fine. However, when I save changes, the slug that shows on YOAST is:

sports-therapy-services

It is replacing the slash with a dash.

Is there a way so I can put in slashes into the YOAST slug? Or is there a way to make the YOAST slug match what I have put into the custom permalink?

Share Improve this question asked Feb 3, 2023 at 17:36 Frankie LevinFrankie Levin 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

If the YOAST SEO plugin's slug is not taking the custom permalink that you have set, there are a few potential solutions:

  1. Check the settings: Go to the YOAST SEO settings and make sure that the custom permalink setting is enabled.

  2. Disable pretty permalinks: Try disabling the "pretty permalinks" setting in WordPress and see if the custom permalink is honored. If it is, you can re-enable pretty permalinks and try a different solution.

  3. Use the wpseo_slug filter: You can use the wpseo_slug filter to set the custom permalink for YOAST SEO. Add the following code snippet to your WordPress theme's functions.php file:

    add_filter( 'wpseo_slug', 'set_custom_permalink', 10, 1 ); function set_custom_permalink( $slug ) { // Check if we are on the post type that should use the custom permalink if ( get_post_type() === 'custom_post_type' ) { // Set the custom permalink $slug = 'custom-permalink'; } return $slug; }

In this example, the code uses the wpseo_slug filter to set the custom permalink for the custom post type with the name "custom_post_type". Make sure to replace "custom-permalink" with the actual custom permalink that you want to set.

Note: The wpseo_slug filter may not work in all cases, depending on your WordPress setup and other plugins that you have installed. If this solution doesn't work, you may need to try a different approach or reach out to the YOAST SEO support team for further assistance.

本文标签: pluginsYOAST slug does not take the custom permalink I have made