Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Usually I would get a post title no problem, however now I need to achieve something like this:

The Example is written for this title

As you can see two words are links in the title, another problem is that there could be any number of links, as it will depend on a content. How can I achieve this? will I have to use additional fields in WordPress? how to show WordPress which words in the title are links? And in addition, I will need to somehow store url for the link.

share|improve this question
1  
Can I ask why? This sounds problematic from a UI/UX point of view –  Tom J Nowell Apr 19 '13 at 15:18
    
@TomJNowell Title will essentially be song name with artist / artists in it. I want to make artist names links to their twitter / facebook profiles. –  Ilya Knaup Apr 19 '13 at 17:32
    
So then could you not automatically generate titles rather than attempt to do a the_title call? Turning the title box into a full blow tinyMCE instance is not a solution to your problem it's a kludge and that's where you seem to be headed –  Tom J Nowell Apr 20 '13 at 18:33
    
@TomJNowell perhaps, I'm still new to wordpress and would like to achieve this in best possible way. Could you by any chance expand on the idea of automatically generating titles? –  Ilya Knaup Apr 20 '13 at 20:37
    
Instead of calling the_title, you'd just echo one out at runtime inside h1 tags. nothing unusual about it really, have post meta specifying the artist etc and then use that. The specifics of how are very dependent on how your storing your data etc, so I wont go into it as that would be off topic –  Tom J Nowell Apr 20 '13 at 22:03
add comment

2 Answers

up vote 1 down vote accepted

The easy way of doing this is to not display the title on your page template, and have a h1 header as the first thing in your content.

share|improve this answer
add comment

Agreed with Tom on this being a questionable UI/UX practice, but here's some code for educational purposes (it goes into your theme's functions.php):

add_filter( 'the_title', 'wpse0419_modified_post_title');
function wpse0419_modified_post_title ($title,$id) { 
    if ( $id == get_the_ID() ) { // narrow down to current item's title only
        $meta_url = get_post_meta($id, 'your_meta_key_url', true);
        if($meta_url){
            $title = $title . "(<a href='" . $meta_url ."'>modified title</a>)";
        }
    }
    return $title;
}

You can read up on filters in this Codex article, and about storing custom variables in post meta in this one.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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