Skip to content

Instantly share code, notes, and snippets.

@alanef
Created April 23, 2024 21:14
Show Gist options
  • Save alanef/80a4f477afb2498e88912efc676478ef to your computer and use it in GitHub Desktop.
Save alanef/80a4f477afb2498e88912efc676478ef to your computer and use it in GitHub Desktop.
<?php
/*
use like [myshortcode type=feedback]
*/
add_shortcode( 'myshortcode', function ( $atts ) {
$atts = shortcode_atts( array( 'type' => '' ) );
return apply_filter( 'myshortcode_' . $atts['type'], '' );
} );
add_filter( 'myshortcode_ad', function () {
return 'Hello World!';
} );
add_filter( 'myshortcode_feedback', function () {
return 'Hello World!';
} );
add_filter( 'myshortcode_thanks', function () {
return 'thanks';
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment