Make WordPress Core

Opened 2 years ago

Last modified 8 months ago

#54964 new defect (bug)

get_permalink() does not use the correct slug rewrite base

Reported by: jakubaondrej's profile jakubaondrej Owned by:
Milestone: Awaiting Review Priority: normal
Severity: blocker Version: 5.9
Component: Posts, Post Types Keywords: needs-patch reporter-feedback
Focuses: rest-api Cc:



get_permalink does not work well for custom posts with slug rewrite.
E.g. I have implemented articles post type:

'rewrite'     => array('slug' => _x('articles','slug','mydomain')),...));

'articles' is translateD to slovak language as 'clanky'. But get_permalink({id_of_article}) returns localhost:10010/articles/my-title. It is wrong and i have recieve error 404, because right link is localhost:10010/clanky/my-title.

It works OK for older WP version.

Thanks a lot for any result.

Kind regards,
Ondrej Jakuba

Change History (5)

This ticket was mentioned in Slack in #accessibility by ryokuhi. View the logs.

2 years ago

#2 @joedolson
2 years ago

  • Focuses accessibility removed

This ticket was mentioned in Slack in #core-test by hellofromtonya. View the logs.

2 years ago

#4 @SergeyBiryukov
14 months ago

  • Component changed from I18N to Posts, Post Types
  • Focuses coding-standards removed
  • Summary changed from get_permalink to get_permalink() does not use the correct slug rewrite base

#5 @lopo
8 months ago

  • Keywords reporter-feedback added

I looked into this issue during the Yoast Contributor Day, I could not reproduce the problem in 6.4 beta 2.

This is how I tried:

  • I installed Yoast Test Helper from the repository
  • in Tools > Yoast Test, I enabled the custom post types
  • I created and published an item under the Book post type, it got id 6
  • I edited wp-content/plugins/yoast-test-helper/src/post-types.php to change from
    'slug' => 'yoast-test-books',
    'slug' => _x( 'yoast-test-books', 'slug', 'yoast-test-helper' ),
  • I set the site to use Italian
  • I installed Locotranslate from
  • Using Locotranslate, I translated yoast-test-books to libri
  • I edited the theme and added echo get_permalink( 6 );
  • I got http://localhost:8889/libri/book-title/ as expected

(notice that the link would return a 404 unless the permalink had been flushed, but it's not needed to get the translated URL).

@jakubaondrej can you check again if the issue is still occurring, and if so, can you provide instructions to reproduce?

Note: See TracTickets for help on using tickets.