rcm_atul

Shortcode Attribute Usages

May 13th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. Register Shortcode in function.php
  2.  
  3. function basic_rrf_shortcode ($atts, $content = null){
  4. return '<div style="background:red;color:#fff;padding:15px">'.$content.'</div>';
  5. }
  6. add_shortcode ('rrf_shortcode', 'basic_rrf_shortcode');
  7.  
  8.  
  9. function basic_rrf_shortcode_extend ($atts){
  10.  
  11. extract ( shortcode_atts ( array (
  12. 'content' => 'null',
  13. 'color' => 'red',
  14. 'background' => 'yellow',
  15. ), $atts, 'rrf_shortcode_extend') );
  16.  
  17. return '<div style="background:'.$background.';color:'.$color.';padding:15px">'.$content.'</div>';
  18. }
  19. add_shortcode ('rrf_shortcode_extend', 'basic_rrf_shortcode_extend');
  20.  
  21. Usages
  22.  
  23. 1. [rrf_shortcode]This is shortcode content[/rrf_shortcode]
  24. 2. [rrf_shortcode_extend content="This is shortcode content" color="#000" background="yellow"]
Add Comment
Please, Sign In to add comment