Pass parameters to shortcoder
-
I had created a shortcode in functions.php, but would like to use shortcoder for it. The code is below. The question is, how can I pass the $atts and $tag attributes to shortcoder? Typical usage is [wbpsb title=”first%20degree%20rage”].
function wbpsb_shortcode($atts = [], $content = null, $tag = '') { // normalize attribute keys, lowercase $atts = array_change_key_case((array)$atts, CASE_LOWER); // override default attributes with user attributes $wbpsb_atts = shortcode_atts([ 'title' => 'www.ads-software.com', ], $atts, $tag); // load sales buttons for this title. The title is all lowercase using every word in the proper title with %20 in place of spaces. Here are some example formats for the title: // lockout // paper%20wings include "https://wildbluepress.com/wp-content/themes/magazine-pro/wbp-maincontentsalesbuttons.php?title=".$wbpsb_atts['title']; // return output return $o; } function wbpsb_shortcodes_init() { add_shortcode('wbpsb', 'wbpsb_shortcode'); } add_action('init', 'wbpsb_shortcodes_init');
The page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Pass parameters to shortcoder’ is closed to new replies.