Skip to content

Instantly share code, notes, and snippets.

@benjamenjohnsondev
Created September 26, 2017 13:25
Show Gist options
  • Select an option

  • Save benjamenjohnsondev/31432c268c2970c0e7ad8c917957aa82 to your computer and use it in GitHub Desktop.

Select an option

Save benjamenjohnsondev/31432c268c2970c0e7ad8c917957aa82 to your computer and use it in GitHub Desktop.

Revisions

  1. @benjamenhogben benjamenhogben created this gist Sep 26, 2017.
    20 changes: 20 additions & 0 deletions button_shortcode.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    <?php
    function button_shortcode( $atts , $content = null ) {

    // Attributes
    $atts = shortcode_atts(
    array(
    'url' => '/',
    'class' => 'class',
    ),
    $atts
    );

    return '<a href="'. $atts['url'] .'" class="'. $atts['class'] .'">'. $content .'</a>';

    }
    add_shortcode( 'button', 'button_shortcode' );

    //[button url="/somewhere" classes="over the"]rainbow[/button]
    // will output: <a href="/somewhere" class="over the">rainbow</a>
    ?>