• Resolved martcol

    (@hotmale)


    add_shortcode('rose' , function(){
    	return '
    	<div class="authorchoice">
    	<h3>Get in Touch</h3>
    	<p>This was written by Rose and you can contact her <a href="URL_to_mysite.co.uk/contact/?1mailto_id=2">here</a>.</p>';
    });

    So, that’s my first real bit of coding since starting out with WordPress a few years ago. All that it does is give each author on the site a link to the contact page with their email selected as the person to contact.

    What I think I would prefer is for the function to know who wrote the page or post the shortcode is used in and go from there or maybe, for there to be one function that makes each choice depending on an attribute selected like, [authorchoice name=rose]

    Would that be possible/difficult and if it’s not too hard to do, could someone just give me a couple of clues where to start?

    Thanks

    Martin

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘My First Shortcode Function’ is closed to new replies.