tryan326
9/6/2017 - 6:58 PM

Shortcodes

/* ------------------------------------------------------------------
   Activate Shortcode Functionality in Text Widgets & Post Titles	
   ----------------------------------------------------------------*/
   add_filter( 'widget_text', 'shortcode_unautop'); add_filter( 'widget_text', 'do_shortcode');
   add_filter( 'the_title', 'do_shortcode' );
   
   
/* ------------------------------------------------------------------
   Basic Shortcode
   ----------------------------------------------------------------*/
   function short_code_name (){
      return "do something";
   }
   add_shortcode( 'short_code_name', 'short_code_name' );
   
/* ------------------------------------------------------------------
   Advanced Shortcode w/ Atrributes
   ----------------------------------------------------------------*/
   function shortcode_name( $atts ){

    extract(shortcode_atts(array(
    "atrribute" => "something",
   ), $atts));

    return '<div>$attribute</div>';
  }
  add_shortcode( 'shortcode_name', 'shortcode_name' );