Don’t try to shove everything into a single attribute, or a single shortcode even. The string parsing you have to do will get more and more complicated. Try this:
function myshortcode_cb( $atts ) {
$atts = shortcode_atts(
array(
'cat' => '',
'title' => ''
),
$atts
);
// var_dump($atts); // debug
return "{$atts['cat']} :: {$atts['title']}";
}
add_shortcode('myshortcode','myshortcode_cb');
With this:
[myshortcode cat="key1" title="Title 1" /]
And create a shortcode for each case.
Related Posts:
- Conditionally Loading JavaScript/CSS for Shortcodes
- Pass boolean value in shortcode
- Escaping quotes from shortcode attributes
- How to add ‘class’ attribute into shortcode [audio]?
- Automatically add this attribute to the gallery shortcode
- How to handle valueless attributes in shortcodes?
- wpautop() when shortcode attributes are on new lines break args array
- Remove width and height attributes from [gallery] output
- Add attribute to existing Shortcode
- Shortcode displays only default attribute values
- Extending Shortcode attributes
- Remove HTML content if attribute is not set / variable attributes
- Global, network-wide shortcodes or text replace functions
- getting values from a shortcode with an include
- Why are Shortcodes Disabled in Widgets by Default?
- Add attribute to shortcode dynamically
- Replace / Remove Shortcode after 1st run / post
- Caption shortcodes not including caption as attribute
- Conditionally Loading JavaScript/CSS for Shortcodes
- Check if CTP category taxonomy is set in shortcode
- Passing variable in nested shortcodes
- How to use a nested shortcode to render the value of an attribute in parent shortcode
- Which wordpress function is the caption shortcode linked to?
- How to process a single attribute in a SQL request twice times?
- shortcode atts not working
- Second attribute of shortcode is not changing why?
- Replace custom gallery shortcode with default gallery shortcode
- Shortcode Attribute contains clone of all shortcode attributes
- How can I define the output of shortcode attribute value?
- Remove width and height attributes from [gallery] output
- shortcodes output before content [duplicate]
- Shortcodes, HTML tables, and multiple rows
- How get a shortcode working in category description
- display shortcodes outside of the_content
- How to prevent tinymce macro from inserting nbsp;?
- Pros and cons of actions over shortcodes
- How to enqueue script based on post category?
- Disable oEmbed for a Single Shortcode or at Least All Internal Links
- How to check if this is the nth instance of a given shortcode in a post
- conditional shortcode not working
- Correct way to pass information between seperate shortcode functions
- Shortcode output is screwed up when arrow symbol “
- How best to apply do_shortcode in media.php for captions
- Searching in shortcode contents
- Applying filters to the_content() to separate content if any `add_shortcode()` is found?
- Wp_localize_script from Shortcode [closed]
- Localization inside shortcode not working
- Get shortcode attribute outside of WordPress
- Overriding shortcode $atts for featured products
- How to create a shortcode for embedding pdf in iframe?
- shortcodes – style them or change/remove the square brackets?
- Woocommerce, ordering products by default on shortcode pages
- Gravity forms customize field markup for the same form appearing in different places
- Calling an attribute from a plugin shortcode
- Edit shortcode in post content programatically
- How to change to local video player on shortcode ultimate to video.js?
- Adding shortcode field to edit gallery / Gallery Settings
- Shortcode not showing anything
- return unformatted content in encosing shortcode
- Redirect to another page using contact form 7? [closed]
- How to display Feedburner subscription count as plain text via a shortcode in post/page editor of my WordPress blog?
- Function result goes outside div
- Shortcode in my childtheme is not working
- How to Make Archive ShortCode
- Use a shortcode to display custom meta box contents
- Are Shortcode Attributes Always Passed As Strings?
- Show form per shortcode
- Default WordPress shortcodes not working?
- Pass fileurl parameter into shortcode from Advanced Custom Fields
- caption shortcode using image alt as caption
- Shortcode arguments to another shortcode
- Sanitize or treatment of string in editor via shortcode
- Can’t render shortcode when html tag contains hyphen
- Not to escape a text
- Color on Shortcode insert that creates a button
- shortcode doesnt work on excerpt
- Adding Author URL to Nav Menu via Shortcode
- Shortcode result appears above page content
- Pagination for custom posts loop
- Modify [caption] shortcode so and are not used?
- How to Call Related Post based on Categories Inside Post Content with Shortcode?
- How to strip header tags & shortcodes from the_excerpt()
- shortcode display metainformation as linked image
- Multiple shortcodes only use attributes from one of the shortcodes on custom plugin
- Cannot modify class property from shortcode handler function
- Reusable Dynamic Taxonomy Shortcode
- Can’t place endwhile in the loop properly in a shortcode
- How to reduce the image size inside an icon? [closed]
- How to insert visual compser post grid shortcode in a custom page template? [closed]
- Shortcode tags appear on mobile themes
- Manipulated shortcode output
- Where is escaped the shortcode?
- restrict access to specific urls on a specific period of time
- Str_replace using shortcode with multiple changes
- Custom field in a shortcode?
- Changing layout of defaul gallery output to masonry
- shortcode change variable base on user
- Inserting shortcode is blanking excerpt – any ideas?
- How to enable on custom shortcodes
- Nested ShortCode works inside the_content, but not outside of it