the_permalink Function Incorrect After Custom Post Type Rewrite
-
Hi,
I feel like I am probably making a stupid mistake, but can’t seem to figure out this issue. My permalink settings in the wp admin are set to post name (https://example.com/%postname%/). I have just modified my custom post type and its custom taxonomy slugs via the “rewrite” argument as follows:
custom post type:
'rewrite' => array( 'slug' => 'projects')
custom taxonomy:
'rewrite' => array( 'slug' => 'projects/category' )
The idea is that my custom posts will be located at https://example.com/projects/post-title and my CPT category archives at https://example.com/projects/category/category-name. The rewrites seemed to work as expected because my custom posts and archives are showing at those URL’s. The problem that I’m finding is that the function
the_permalink()
for these cpt posts is echoing out a URL of https://example.com/post-title, which is not actually where the post exists. To give a little more information, I am setting up the post data via the setup_postdata() before the_permalink() is called.I’ve tried refreshing permalinks, recreating my .htaccess files, using get_permalink(), changing around the rewrite slugs, changing themes, deactivating plugins, etc… I have a feeling that it may be something simple with the way my permalink settings and custom post type rewrite are interacting. Please let me know if you can fill me in with any valuable info.
- The topic ‘the_permalink Function Incorrect After Custom Post Type Rewrite’ is closed to new replies.