Post links broken after migration
Post links broken after migration
Post links broken after migration
Permalink for custom post type pages not working
CPT links error: each one links to next one further along in the list
OK so I’ve spent a couple of more hours working on this and was examining my database through phpmyadmin. In the table wp_terms I noticed that I had terms identical to my page’s slug. Turns out I had a tag named like this. I deleted the tag, and voila – no more 404 error. Hope … Read more
This is a pretty common problem. Unfortunately there are dozens of possible causes, which may be on the server level as well as the WordPress level. Therefore, it is impossible to pinpoint a solution for you. One thing you know is that the server settings you mention are working correctly at least in part, in … Read more
301 redirects after changing permalinks
AH! https://permalinkmanager.pro/docs/tutorials/how-to-remove-numbers-2-3-appended-to-the-permalinks/ So the automatic slug creation of -2, -3, ..etc is done by core in order to make slugs unique. But I knew there was a way to change the permalink and not the slug. I just couldn’t find code anywhere to do this so I resorted to using this premium plugin. global $permalink_manager_uris; … Read more
Add a url parameter to the current post and read it in a shortcode
In your second code you use undefined $post variable. Probably you meant a global $post, but as the second parameter to the filter is passed the ID of the post for which the link is created, and this does not necessarily have to be the current post of the loop. Try this: add_filter( ‘page_link’, ‘nocfcache_query_string’, … Read more
Literally found the answer 10 minutes after posting this question and spending a couple of hours on it before asking. Simply hook your function to post_link! 🤦 public function __construct() { add_action(‘post_link’, [$this, ‘post_links’], 10, 2); } public function post_links($link, $post) { if ($post->post_type === ‘post’) { return site_url(‘slug/’. $post->post_name .’-‘. $post->ID); } else { … Read more