Thank you, @Howdy_McGee! current_filter()
is exactly what I’ve been looking for. Here is what I did:
function french_example( $atts , $content = null ) {
$currentFilter = current_filter();
if ($currentFilter == the_content) {
return '<span class="ex" xml:lang="fr" lang="fr">' . do_shortcode($content) . '</span>';
}
elseif ($currentFilter == the_title) {
return '<span class="ex" xml:lang="fr" lang="fr">' . do_shortcode($content) . '</span>';
}
else {
return do_shortcode($content);
}
}
add_shortcode( 'ex', 'french_example' );
Related Posts:
- Custom shortcode being executed when saving page in wp-admin
- Change appearance of shortcode text inside editor
- Combining shortcode and get_template_part
- Escaping quotes from shortcode attributes
- Shortcode output always showing at top of page
- How to detect if a Shortcode is being called on a page?
- How to get current page title inside a page itself in a shortcode and in page content
- shortcode inside another shortcode
- Need MySQL Query or WP-CLI command to updates old URLs in Shortcodes [closed]
- Custom Shortcode AJAX 400 Bad Request
- WordPress gallery ‘post_gallery’ filter doesn’t work with feeds?
- shortcode to create dynamic dropdown box form shortcode attributes
- conditional shortcode not working
- Ajax not returning anything on form submit
- How do I add my own custom shortcodes?
- Can’t seem to get [shortcode]s to work
- Wraping $content into link with shortcodes
- nested Shortcode doesn’t work
- Slow page loading when using a simple shortcode on the same page multiple times
- TinyMCE get selected text and underlying HTML
- Remove and restore one shortcode
- Rewriting WordPress Gallery Shortcode with Bootstrap Carousel
- other shortcodes in Contact form 7 MAILS [closed]
- Remove empty p-Tags in Shortcode content before non p-Tags
- Using do_shortcode with variables?
- Using ACF field in do_shortcode()
- Display content from another site page using a shortcode
- Remove hyperlink on gallery shortcode
- Wrap shortcode inside custom block
- Combining similar shortcode functions?
- Creating a shortcode based on users preferences
- Get a post’s thumbnail url or display default image in shortcode
- basic shortcode – Why 1st paragraph not wrapped in p tag, but 2nd is
- unwanted P tags in shortcode, delay wpautop not working
- Convert HTML Script to Shortcode [closed]
- What is the Correct way to pass parameters in function
- Shortcode – Getting Categories appears on top of website
- How to Modify WordPress Default Image Gallery Shortcode
- Passing html tags as shortcode parameters
- Registration Form Shortcode
- Include tags in the body of a post
- Button Shortcode
- Remove shortcodes that are different (but same pattern) in each post
- Place a URL parameter value inside a WordPress short code
- Print shortcode in defined area
- WordPress shortcodes are not working
- Conditionally Loading JavaScript/CSS for Shortcodes
- Placing tags on wordpress visual editor using shortcodes
- Shortcode called twice
- Replacement for gallery_shortcode function not taking all attributes
- Add JS in footer via shortcode?
- how can i pass this attribute in this shortcode?
- How to add a same div on every page
- WordPress Shortcode / Only works in classic editor, gutenberg error / invalid json response
- Display a form partially with a shortcode
- Do shortcode in template file
- Modifying the wordpress login page and then referencing it with a shortcode problem
- Pass instance number to shortcode child
- Render shortcodes with get_post_custom
- Add shortcode within the_content()
- Pass a comma separated shortcode attribute to a function
- how to write short code in word press
- hard code shortcode only on specific category
- Set redirect for need login
- make user_id in a shortcode dynamic based on who’s logged in
- Shortcode not working in CPT taxonomy
- wp_enqueue_scripts does not work on admin page
- shortcode containing other shortcodes not returning content
- How to include shortcodes and pdfs in WordPress search without plugin?
- To know whether insert shortcode in custom meta box
- Gutenberg Shortcode will turn html to html entity
- Need help in setting up a transient using API Key and if possible updating it in the ACF field
- the_content() not showing the content in good order (with a shortcode)
- Execute shortcode in backend
- Shortcode not being executed
- Load gravity form via ajax using do_shortcode
- How to Enable embedding WordPress default gallery in comments?
- Print shortcode according to site language
- Video Short Code and Media Fragments URI
- Remove a short code and update it’s content (AJAX)
- How to process a single attribute in a SQL request twice times?
- Customise standard lists within my shortcode
- Timber – don’t display shortcode
- Use ACF array values in shortcode
- How to fix transparency in product sliders / featured products on home page?
- php in a shortcode
- How do I use “while” and “end while” inside of the echo do_shortcode with ACF Repeater?
- Problem in creating a shortcode form custom post type slider
- Which method to use when deleting posts from the front-end
- Add an access code form to call a unique page based on page without registration
- add php shortcode in return function
- Display post_meta in Shortcode
- Gallery Shortcode: using size=”full” doesn’t call the actual thumbnail image size
- style css to header for shortcodes
- WordPress Shortcode loads at the top
- What does this shortcode do?
- php code to shortcode [duplicate]
- create shortcodes for posts
- How Do I create a shortcode to dispaly a go to top button on any page or post
- filter custom field with checkboxes and show it with one shortcode