How to Display WordPress Shortlink in Your post

How to Display WordPress Shortlink in Your post

WordPress tutorial, How to Display WordPress Shortlink in Your post. From wordpress 3.0 version you can add the short link in your post through api.  For social networking you want to add the short links in your post.

How to Display WordPress Shortlink in Your post

Adding shortlink tag in head section is always good ieda for SEO. short link will look like as follows:

<link rel='shortlink' href='http://wp.me/p1kxw4-1uP' />

For adding short link in your single post you need to the following code in to your single.php file.

   if ( function_exists('the_shortlink') ) the_shortlink( __('Shortlink'), __('wordpress api short link'), ' · ' );

For adding the shortlink support in admin panel you need to add the following code in to functions.php file.

    add_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );

For adding the short link in head section add following code.


<link rel='shortlink' href='<?php if (function_exists('wp_get_shortlink')) { echo wp_get_shortlink(get_the_ID()); } ?>' />

For more detailed information you  can check following article.

Getting Shortlink in WordPress admin panel

How to Display WordPress Shortlink in Your post
How to Display WordPress Shortlink in Your post

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

2 thoughts on “How to Display WordPress Shortlink in Your post”

Leave a Reply

Your email address will not be published.