Examples - aaemnnosttv/shortcode-alias-api GitHub Wiki

Alias with Defaults

For example, if you had a regular events shortcode, which had many attributes for filtering and displaying its output, these could be pre-set by an alias with defaults.

Let's imagine this is the shortcode that we want to create an alias for:

[events view=calendar dates=past range=1 title="Past Events"]

Register the alias:

add_shortcode_alias('past_events_calendar', 'events', array(
   'atts' => array(
        'view'  => 'calendar',
        'dates' => 'past',
        'range' => 1,
        'title' => 'Past Events'
    ) 
));

Now we can get the same result with a more expressive, cleaner dedicated shortcode:

[past_events_calendar]

The alias would be able to override any defined default, or use any other attribute simply by using the same attribute normally like so:

[past_events_calendar range=3 show_prices=true]

Gallery Override

Aliases can be used to "override" their target. The alias uses the same shortcode tag, without breaking the target.

add_shortcode_alias('gallery', 'gallery', array(
    'atts' => array(
        'link' => 'file', // always link gallery items to file by default
        'exclude' => array('prepend' => '1,2,3,') // always exclude these attachment IDs, in addition to any others passed
    )
));