After sleeping over the problem I decided to the code and tried this:
<a href="https://twitter.com/share?url=&text=<?php the_title(); ?>: <?php echo urlencode(get_permalink($post->ID)); ?> &via=username&count=horizontal" class="custom-tweet-button">Tweet</a>
All I can say is: it works as it should be. Next thing on my agenda is to incorporate a custom url shortener.
PS: It’s worth a mention that if you use certain themes, they might use a special %permalink% and %post-title% structure. Be sure to replace the default <?php the_title(); ?>
and <?php the_permalink(); ?>
with it.
Related Posts:
- How to Check if a Page Exists by URL?
- How to allow slashes in single posts when i click in the edit permalink button
- how to grab first link in post… and of course call it
- Paginated Posts – Social Media Buttons Share First Page URL
- WordPress not opening posts with only numbers if permalink is post_name
- Retrieve post ID from “querying” URL
- Post is blank when I click on the link
- Can Permalink structure of %postname%/%post_id% improve performance
- Can I show category name in url for only one of my categories?
- Permalink Short code showing unnecessary link text inside the loop
- How can I make a post sub link?
- Does having category name in permalinks affect SEO when having a post in multiple categories?
- How to add a ‘News’ section to specific posts in WordPress
- Prevent Archive URLs
- Category URL to use same string as Post URL Permalink
- Post & Category Archives URL structure
- How to change post template via url?
- Default post type doesn’t display in url
- Blog posts are not appearing as subs of Blog Page
- How to add paraent in Blog post URL in wordpress
- Access post from post id in URL
- How to add category to: ‘wp-admin/post-new.php’?
- Use category base slug in posts’ permalink
- Custom permalink structure only for default posts
- Post slugs and images cannot have same name?
- Change the Slug of Post Type post to baseurl/post/%postname%
- Pretty URL with add_query_var
- get_permalink returns default link
- Group Posts by First Letter of Title
- How do you get all the urls of images attached to a post?
- How to control which category will be picked for the slug of a post?
- how to get permalink using sql
- Change slug with custom field
- How to get the post id from a permalink?
- Is there a plugin that creates a WP post based on a Twitter account’s hashtag?
- Post custom permalink results in 404 for archive page
- Custom post type single (permalink) throws a 404 error
- Post in Multiple Categories to stay in current category (permalink, next previous post link)
- What Defines What Category A Post Picks (if in multiple)
- Custom post type permalinks breaking due to 3.1 bug fix
- How can a guest view the “Pending Review” Post?
- change default post archive page link
- How can I create custom button in post.php
- Remove slashes (both before and after) in relative post url
- Bulk update post slugs through database
- How to change permalink on post click on post listing page
- Mixing Tweets with Posts
- Assign category to new post via URL
- Problem with permalink routing?
- filter RSS feed in URL
- Switch to page template when using post permalink
- How to handle broken links created by permalink/slug changes?
- Visting slug for ‘post’ post type shows 404 not archive?
- How do I Redirect a WordPress Page?
- WP move posts to different path
- Make insterted image point to post url instead of attachment page
- custom word in custom permalink structure
- Unabled to Change Permalinks – Even Using the “Edit” (Resets to Original Permalink on “Update”)
- Inserting Media to WordPress Posts
- Custom Post Type, post-formats associated to custom post type > 404 archives
- Internal linking to posts permalink fail because of spaces and stripe at postname
- Link post images to post
- Problems with WordPress in subfolder, posts show a blank page
- how to create a sub section in posts
- Rewriting blog permalinks
- Change permalinks for posts & for custom post types
- WordPress posts have a different URL to the index
- Go back to the exact post page number
- How to set the post permalink using the WordPress REST API?
- unable to display two post per page in wordpress front-page.php
- How to 301 redirect from url with post id to permalink with post name (slug)?
- Custom Post Types and Broken Permalinks
- Custom permalink for wordpress page / post
- Permalink structure for two seperate blogs
- My post permalinks are always the same
- How to give priority to page than to posts permalink structure?
- Append a random string to a post permalink
- Multipage Post URL correction
- Fixing the WP Post Object for Custom Route
- All my posts don’t show, only the headline is displayed on the homepage
- Posts in Page – How to customize the URL?
- Is there a Standard Format for Clean URLs for Archives of Custom Posts?
- Is there a way to change the complete URL of the blog post for a redirecting tracking link?
- Can’t seem to replicate permalink structure for localhost development site
- WordPress rewrite url help needed
- Permalink of some posts change
- My posts section for logged in user
- Moving Posts to a new site and maintaining URLs
- How to mix pages and sub-categories in a url
- Changing permalink of custom category
- Change the default video URL in a post to shortcode format
- TCPDF and permalinks
- Overwrite URL on blog posts
- WordPress sub-posts and permalinks
- 301 Redirecting posts without %postid% (just %post_name%) in permalink to ones with %post_name%_%postid%
- How do I add /blog/ on my permalink without affecting the portfolio project types permalink?
- Permalink remain the same on each page
- Read more link not working [closed]
- Changes done in admin panel are taking time to reflect in the REST api responses
- Download button under all images WordPress