Created
January 5, 2019 09:16
-
-
Save Tsunamijaan/7ce7a8fb05816ac15b442c259ad8c44c to your computer and use it in GitHub Desktop.
How to register shortcode in wordpress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Single shortcode====== | |
| function single_shortcode( $atts, $content = null ) { | |
| return '<div class="singe_shortcode_wrapper">'.do_shortcode($content).'</div>'; | |
| } | |
| add_shortcode('single_shortcode', 'single_shortcode'); | |
| =========Shortcode with attributes======== | |
| function shortcode_with_attributes( $atts, $content = null ) { | |
| extract( shortcode_atts( array( | |
| 'attribute' => '', | |
| 'another' => '' | |
| ), $atts ) ); | |
| return ' | |
| <div class="shortcode_wrapper"> | |
| <h2>'.$attribute.'</h2> | |
| '.$another.' | |
| </div> | |
| '; | |
| } | |
| add_shortcode('shortcode_name', 'shortcode_with_attributes'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment