Is it possible to have my custom permalink structure on title tag of my blog?

my current permalink structure is this /%postname%/%location%/%mba_courses%/ where my location and mba_courses are custom taxonomies

Now I want this on my title tag, can I write something like this in title tag?

<title><?php echo (/%postname%/%location%/%mba_courses%/); ?><title>

I know this is a wrong code, and it won't work, but is their any way, where I can have this kind of title tag?


There is no way to cause your permalink structure to be reflected automatically in the title tag. Instead, you must create it yourself. This might get you started: (I had to make a lot of assumptions in this code.)

function my_title() {
    $post = get_queried_object();
    $locations = wp_get_object_terms( $post->ID, 'location' );
    $mba_courses = wp_get_object_terms( $post->ID, 'mba_courses' );
    $postname = $post->post_title;
    $location = $locations[0]->name;
    $mba_course = $mba_courses[0]->name;
    return "$postname | $location | $mba_course";

Then, in your single post template:

<title><?php echo my_title(); ?><title>

If your not using an SEO plugin you can use wp_title to put the permalink url as the tile.

<title><?php wp_title(' '); ?></title>
  • sorry for the above comment, but this is not what I want, My URL structure is in this way MBA-IN-INSEAD(post-name)/MBA-IN-FRANCE(location)/MBA-IN-ACCOUNTS(course name) In terms of SEO this is the best URL for an MBA website, so in same way I want it for my title tag, which should be something like this: MBA IN INSEAD | MBA IN FRANCE | MBA-IN-ACCOUNTS Feb 28 '11 at 13:05
  • @ntechi I misunderstood your question. I thought you wanted the url in the title tag.
    – Chris_O
    Feb 28 '11 at 13:34
  • its actually the URL's text, you are not completely wrong, but how can this be done? Feb 28 '11 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.