Use Native WP Short URL

  • iftekhar
  • May 2, 2016
  • 0 comment
  • 1926 Views
  • Print

By default whenever you write a post or page, WordPress stores and assigns an ID number for every single entry made into the database. This ID can be used to retrieve any particular post or page from front end as well. You can easily access certain post or page using following method and it should look something like this.

https://iftekhar.net/?p=123

If you do not have whole bunch of posts on your site, try with little lower number. Something should come up. Now, luckily WordPress permalink structure also allows it’s users to keep their permalink structure exactly what I just mentioned. Take a look at the screenshot provided below.

WordPress Permalink Settings PageWordPress Permalink Settings Page.

Even though using such permalink structure would make it lot easier to share your posts or pages, it is not recommended for SEO point of view. So, if you don’t want to use the “plain” permalink settings for your site yet still want to be able to share your post using short URL (more like bit.ly or goo.gl services), this is what you should do.

<?php echo get_bloginfo('url').'/?p='.$post->ID; ?>

Copy and paste this little snippet on your "single.php" page(within a <div> or <span> tag) and style it with css. You are good to go.

  •  
  •  

Comment

Leave a Reply

Note: Convet HTML, PHP, JavaScripts from Postable, before posting from comment section.
License: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution. Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.