permalink not showing correctly using wp_insert_post and post_name

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 slug to default post permalinks ONLY

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

Internal forward link with add_rewrite_rule

The code below should work for you as long as: Your CPT slug is location. You don’t have a custom query_var registered for your CPT location. You probably don’t have. Refer to https://codex.wordpress.org/Function_Reference/register_post_type#query_var for more information, it’s very usefull, btw. And I’m assuming the string nyc is the slug of your single custom post. function … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)