Short Links and Canonical URLs

Those long URLs containing your post titles are great for improving your search results, but they're awfully long! If you're sharing links on social media networks, e-mailing them, or including them in printed documents, you're probably interested in ways to shorten your links.

The default permalink structure always works, even if you've changed your permalinks to some other structure. Listing 7-18 shows how to include the default permalink in your Loop using the new the_shortcode() tag in 3.0, the results of which are shown in Figure 7-6. If you have installed the Stats plugin, you can take advantage of the link shortener feature. There are a number of other link shortener plugins you can install if neither of these appeals to you.

Listing 7-18. Displaying the default permalink in a Loop

<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink(); ?>"

title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>

<p>Sharing this post? <?php the_shortlink(); ?></p> <?php endif; ?>

Layout Test

Posted on Septembers. gQOfl tjy admin

This is a sticky post!!! Make sure it sticks!

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the igoos, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

This should then split into another page with images and other things...

Pages: 123

I Tagged taoi. tag2. tag3 18 Comments Sharing this post? This is the short link.

Figure 7-6. the_shortcode() in the post footer

Google sometimes penalizes sites for duplicating content. However, a single post on your WordPress site might appear on the home page, a date-based archive, a category archive, and the single post archive. It might also have three or four valid URLs if you're using a short link format. To resolve the duplicate content problem, Google recommends that you specify a canonical URL for each post—its home base, where all the archived copies will lead. As of version 2.9, WordPress automatically adds a canonical URL header as part of the wp_head() function. As of 3.0, it also adds the shortlink, as shown in Listing 7-19.

Listing 7-19. Canonical and shortlinks in the <head> section

<link rel='canonical' href='http://wordpress/2008/09/layout-test/' /> <link rel='shortlink' href='http://wordpress/?p=188' />

Link Building Secret Rituals

Link Building Secret Rituals

The Ultimate Blueprint Reveals 'Dangerous' Backlink Domination Methods That Guarantee Rank 1 On Google... this may SHOCK you. In this short report youll discover proven rituals you can apply on your sites to gain high-quality and long-lasting backlinks. This is going to be easy. On the next pages youll discover complete step-by-step, easy-to-follow plan for ultimate rank 1 Google domination.

Get My Free Ebook

Post a comment