Features
-
I am looking for a plugin that would allow me to run a shortcode from a button, a hyperlink or a menu item. Does this plugin supply the functionality?
-
Hi @luhmanr,
have you seen my previous reply? That code allows you to run a shortcode using a dropdown list. The same could be applied to links/buttons.
This plugin does not allow running shortcodes using links.
I did see your previous reply but after spending several hours I could not get it to work.
In such cases, people usually share their results.
So the previous code you mentioned puts the shortcode information in the address bar.
<form action=”/page-2″ method=”get”>
<select name=”my_action”>
<option value=”action-1″>Action 1</option>
<option value=”action-2″>Action 1</option>
</select>
</form>
At page-2, or within your custom shortcode, added to page-2:
if ( isset( $_GET[‘my_action’] ) ) {
$action = sanitize_key( $_GET[‘my_action’] );
if ( ‘action-1’ === $action ) {
do_stuff();
}
}Now, create a custom shortcode to handle that URL. Put the following code to the end of the functions.php file of your active theme:
add_shortcode( 'handle_my_action', function( $atts = null, $content = null ) { if ( ! isset( $_GET['my_action'] ) ) { return; } $my_action = wp_kses_data( $_GET['my_action'] ); // Now you can do whatever you want with the value // You can even call another shortcode return do_shortcode( '[someshortcode value="' . $my_action . '"]' ); } );Then add the following shortcode to page-2:
[handle_my_action].Is this what you were looking for?
It seems that you have gotten me real close. The result viewed on the page-2 is:
[someshortcode value=”%5Bgallery type%3D%27smugmug%27 view%3D%27album%27 album%3D%277tPbqC%27 nick_name%3D%27myname%27 sort_order%3D%27Descending%27 sort_method%3D%27DateTaken%27 count%3D%27100%27 more%3D%27More%27 layout%3D%27mosaic%27 album_sort_order%3D%27Album Settings%27 columns%3D%278%27 title_position%3D%27below%27 popup%3D%27hide%27%5D”]
Rather than an executed
[gallery type='smugmug' view='album' album='7tPbqC' nick_name='myname' sort_order='Descending' sort_method='DateTaken' count='100' more='More' layout='mosaic' album_sort_order='Album Settings' columns='8' title_position='below' popup='hide']
This topic is related to PHP functionality, rather than Shortcodes Ultimate. You should post your question at StackOverflow or somewhere else.
The topic ‘Features’ is closed to new replies.