WordPress Code Snippets

A fresh mix of code snippets and tutorials

Display short URLs in WordPress

38

Quick tip for the day: display short URLs using native WordPress functionality.

Just include the following code anywhere in the WordPress loop to display a short URL for the post:

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

For each post or page, this will display a URL that looks like this:

https://wp-mix.com/?p=7

Easy peasy.

Learn more

WordPress Themes In Depth


Show Support

Like our new Facebook Page to show support!