Wordperss Follow with variable


/ Published in: PHP
Save to your folder(s)

Wordperss Follow with variable
In double quotes you have ability to embed variable
post content: [twitter username='VeronicaDjeneva']Follow me Fools[/twitter]


Copy this code and paste it in your HTML
  1. <?php
  2. /*
  3. Plugin Name: Twitter Shower
  4. Plugin URI: http://www.scoldy.com
  5. Discription: Simple shortcode
  6. Version: 1.0
  7. Author: Ronnie
  8. Author URI: http://www.scoldy.com
  9. */
  10.  
  11. add_shortcode('twitter', function($atts,$content) {
  12. $atts = shortcode_atts(
  13. 'username' => 'VeronicaDjeneva',
  14. 'content' => !empty($content)? $content : 'Follow me on Twitter!'
  15. ),$atts
  16. );
  17. extract($atts);
  18.  
  19. return "<a href='http://twitter.com/$username'>$content</a>";
  20. });
  21.  
  22. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.