Automatic short URL in posts

I installed yourls on a custom short domain. Then added an acf field to posts. Then when a post is added or modified, call yourls API to get the shortlink, and save that link in the custom field add_action(‘acf/save_post’, ‘update_related_posts’, 20); function update_related_posts($post_id) { global $old_field_value; // Check if the save is an auto-save, in … Read more

Where does the redirect from shortlink to permalink happen?

That’s handled by the redirect_canonical function, set up as a default template_redirect filter. So it can be customized either by : a template_redirect filter, with a priority value lower than 10, so it runs before the redirect_canonical function (which will eventually skip the next filters by making a redirect). a redirect_canonical filter called by the … Read more

How to append short url to specific external links

Mostly from https://stackoverflow.com/questions/7118823/check-if-url-has-certain-string-with-php Check if the url has your string, then spit something different out based on it. Perhaps something like… $url=”http://” . $_SERVER[‘SERVER_NAME’] . $_SERVER[‘REQUEST_URI’]; if (false !== strpos($url,’forms.woo.com’)) { echo ‘?pageurl=” . home_url() . get_the_ID(); // there”s your page id url } else { the_permalink(); // plain old permalink }

Custom short url for wordpress post

Without a plugin or service? You can’t. There’s no such thing. From the documentation for wp_get_shortlink() (emphasis mine): This function exists to provide a shortlink tag that all themes and plugins can target. A plugin must hook in to provide the actual shortlinks. Default shortlink support is limited to providing ?p= style links for posts. … Read more

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