WordPress: Using the Title Attributes with AIOSEOP

I have seen many websites and bloggers tout the benefits of using Michael Torbert’s All-in-One Search Engine Optimization Pack (AIOSEOP) plug-in for WordPress. I, myself, use it on most of the websites and blogs I set up. It has a lot of great features built in.

One of the features built into the plug-in is the ability to set completely different titles for the page depending on where that title is being displayed. You can theoretically set up a page to use a different name/title in each of the following locations:

  • The browser’s title bar (the title element found in the <head> section of the document)
  • The heading shown at the top of the page/post
  • The text shown in navigation menus
  • The “title” attribute of links to the page (generally appears as a tooltip when you hover over the link)

However, these different title settings within AIOSEOP only seem to work when you use specific WordPress functions to generate the elements in your template. For instance, the “menu label” only works with the wp_list_pages() function. Unfortunately, I very rarely use wp_list_pages() to create my navigation menus.

There is good news, however. The AIOSEOP plug-in stores its information in the postmeta table, so you can use the get_post_meta() function to retrieve the menu label, the post title or the title attribute for each post. To do so, simply write a statement that looks like:

echo (($t = get_post_meta($post->ID, '_aioseop_menulabel', true)) == '') ?
    apply_filters( 'the_title', $post->post_title ) :
    apply_filters( 'the_title', $t );

If you want to display the title as set by AIOSEOP, you would use “_aioseop_title” instead of “_aioseop_menulabel”, and if you wanted to retrieve the title attribute, you would use “_aioseop_titleatr”.

I hope this information helps those of you that might be scratching your heads, wondering why the menu label isn’t working properly with AIOSEOP. I know I will definitely be referring back to this post in the future when I am doing the same.

2 Responses

  • teebee

    In the paragraph right after the echo statement you say:

    and if you wanted to retrieve the title attribute, you would use “_aioseop_titleatr”.

    Should there be two t’s in the parameter as in “_aioseop_titleattr” or is it just the one?

    • I think it’s one of those things kind of like the PHP ‘referer’ variable. It probably should be spelled “titleattr”, but the initial developer did not spell it that way, so it’s not.

      Therefore, to answer your question, when trying to access that property within your WordPress database, you need to be sure you spell it “_aioseop_titleatr” rather than “_aioseop_titleattr”.