24

Aug

Estimated reading time: 1 minute, 44 seconds

robbclarke-wordpress
I’m big on WordPress, in fact, I’m using it for this site and most of the other sites that I’ve coded. Recently (when working on this blog) I decided that I wanted to generate the URL of the current page so that I could submit that specific page to social media sites, not just the root URL. I search everywhere but couldn’t find the solution that I was looking for and then it hit me.

If you want to dynamically generate the URL of the page/post that you are currently viewing then all you need to enter is:


This code generates and displays the current URL, which is great for submitting articles to Digg, Facebook, Twitter etc. etc.

What a big sigh of relief it was when I found that. The funny thing is that it’s been staring me in the face all along.

Various Codes to Generate Different URLs in WordPress

Below is a list of a number of variables used to generate various URLs using WordPress. The variable is on the left and the result is on the right.

admin_email = admin@example
atom_url = http://example/home/feed/atom
charset = UTF-8
comments_atom_url = http://example/home/comments/feed/atom
comments_rss2_url = http://example/home/comments/feed
description = Just another WordPress blog
home = http://example/home
html_type = text/html
language = en-US
name = Testpilot
pingback_url = http://example/home/wp/xmlrpc.php
rdf_url = http://example/home/feed/rdf
rss2_url = http://example/home/feed
rss_url = http://example/home/feed/rss
siteurl = http://example/home
stylesheet_directory = http://example/home/wp/wp-content/themes/largo
stylesheet_url = http://example/home/wp/wp-content/themes/largo/style.css
template_directory = http://example/home/wp/wp-content/themes/largo
template_url = http://example/home/wp/wp-content/themes/largo
text_direction = ltr
url = http://example/home
version = 2.7
wpurl = http://example/home/wp

You can easily display this information by substituting the variable in the following code for the desired URL:


Did that help? Share your thoughts below!

Exciting Stuff

  • 06/01/10: My article "The Ten Commandments of Social Media" was referenced in the June/July 2010 edition of Chartered Accountants Magazine. An online version of the article can be read here.
  • 01/02/10: I was featured in an article in the Daily Gleaner written by Molly Cormier.
  • 11/03/09: "The Ten Commandments of Social Media" is published at Noupe.com.
  • 08/22/09: I was featured in an article in the New Brunswick Business Journal written by Chris Fox.