This sample function should get you started:
function mam_insert_link_for_tag () {
// use shortcode [mam_tag_link]
$output = '';
foreach (get_the_tags() as $tag) {
$name = $tag->name;
if ($name == 'basic') {
$output = '<a href="http://someurl.com/basic.html"> Basic Link</a>';
break;
} elseif ($name == 'intermediate') {
$output = '<a href="http://someurl.com/intermediate.html"> Intermediate Link</a>';
break;
} elseif ($name == 'advanced') {
$output = '<a href="http://someurl.com/advanced.html"> Advanced Link</a>';
break;
}
}
return $output;
}
add_shortcode('mam_tag_link','mam_insert_link_for_tag');
First, thank you for taking the time and coding this!
One more question.
I dont know what I am doing wrong. The code looks right, I changed the urls with the real urls and then went to single.php and I tried to call the shortcode like this: <div><?php mam_tag_link ?></div> and this didnt work also tried <div> <?php mam_insert_insert_link_for_tag ?></div> and nothing happens…
I dont know if i ask right is this a shortcode <div> <?php mam_insert_insert_link_for_tag ?></div> if not, can you tell what is the name of this?
Again thank you for your help!
I have to apologize!
I asked wrong, I did put the code in a post and it worked putting the link.
but what I really meant was to call the function from in a single.php and from the index.php with something like this. <div><?php mam_tag_link ?></div>
how do i call the function with the example I showed you.
Thanks!
Got it!!!
I found this http://codex.wordpress.org/Function_Reference/get_option
that helped me a little bit with the code below.
<div class=”right”> <?php echo mam_insert_link_for_tag () ?> </div>
Thank you again for taking the time the code works 100%!!!
WordPress rocks!!!
You are welcome. Now, please use the dropdown at top right to mark this topic ‘Resolved’.