Incorrect Post permalink used in Tweet
-
Hi!
Plugin is working as intended ie: its make auto post to Twitter when we publish post.
But we are using https://permalinkmanager.pro/docs/filters-hooks/how-to-filter-the-default-custom-permalinks/For example if our post permalink is https://example.com/a-very-long-slug-with-seven-words/slug-with-exactly-five-words/another-pretty-long-sentence-that-should-be-shorten
We trim it to make its length short https://example.com/a-very-long-slug-with-seven-wordsBelow is code used for this purpose:
function mp_limit_slugs_length($uri) { $max_words = 10; // If any part of URI contains more than 10 words, the slug will be limited to first 10 words $new_title = ''; $slugs = explode('/', $uri); for($i=0, $count = count($slugs); $i < $count; $i++) { $slug = $slugs[$i]; $words = explode('-', $slug); $new_title .= "/"; if(count($words) > $max_words) { $new_title .= implode("-", array_slice($words, 0, $max_words)); } else { $new_title .= $slug; } } // Remove trailing slashes $new_title = trim($new_title, "/"); return $new_title; } add_filter('permalink_manager_filter_default_post_uri', 'mp_limit_slugs_length', 10);
But problem is Twitter post uses the url which is saved while draft post ie: the long url but we want to use url which is created after wards ie: when post is published and url length is modified by using above code ie: filter
permalink_manager_filter_default_post_uri
Please suggest how we can make it possible.
Thanks!
- The topic ‘Incorrect Post permalink used in Tweet’ is closed to new replies.