Not quite like that, but you can achieve the same result if you use a pre-defined value or argument in your shortcode to act as a “flag”:
[authoorsposts author="post"]
…then in your handler:
function wpse_209684_author( $atts ) {
if ( ! empty( $atts['author'] ) ) {
$author = $atts['author'];
if ( $author === 'post' ) // Our flag, make $author the current post author
$author = get_the_author_id();
else // Otherwise just accept a hardcoded author ID
$author = absint( $author );
}
}
Related Posts:
- Remove HTML content if attribute is not set / variable attributes
- Shortcodes and a list of IDs?
- Turning variable into a value set in shortcode
- Substite Category Slug in a Shortcode
- Check if parent page has child page of certain slug
- Variable inside shortcode or shortcode inside shortcode
- Multiple values for one variable
- Add audio file to post using custom term meta field as link [closed]
- Class variables in shortcodes
- Shortcode with multiple variables
- About redundant code when I use shortcode to output the HTML from a variable
- WordPress plugin shortcode not working
- the_excerpt and shortcodes
- How do I create a Shortcode that returns text if domain is .com, not .co.uk
- Remove specific shortcode from get_the_content()
- How to Output HTML tags in do_shortcode?
- Nested Shortcode Detection
- How to display html in a shortcode
- Custom form, shortcode, and submit handler
- Automatically add this attribute to the gallery shortcode
- Custom Shortcode and Button not Working after 3.9 update
- Hide Default Video Shortcode Controls on PageLoad
- shortcode not working [closed]
- Do not show child pages of child pages
- Adding span tags within wp_list_pages list items
- Change font-size within a shortcode
- How can I show the Jetpack Subscriptions form in a page? [closed]
- Is it possible to add a repeater field to TinyMCE’s option window?
- Shortcodes: Pros and Cons
- esc_attr not working in shortcode
- Raw output (preventing wpautop)
- Conditionally loading Facebook PHP SDK in shortcode
- Can’t understand $atts in functions?
- Are .MP3 files with capital letter extensions allowed in [audio] shortcode?
- How to handle shortcodes when using the JSON API
- Are shortcode functions applied while rendering the content, or are they executed and stored with the post content?
- is_admin() returns false in save_post hook with Gutenberg editor
- Why are Shortcodes Disabled in Widgets by Default?
- Get Posts shortcode plugin and meta_query?
- possibility to control embedded video timeline with buttons and links external to the player
- WordPress Gallery shortcode: Display one category ID only
- How to get gallery id inserted to a post?
- WordPress Shortcode show database row
- Video Shortcodes not working in WordPress
- Custom shortcode is not working in text widget
- Get post object in shortcode function
- How to insert image and text from admin panel throughout my theme
- Use shortcodes in terms description? [closed]
- Adding to the_content or a variable from within a shortcode function
- Shortcode: text content ends up outside html tags
- How to wp_redirect on ‘init’ hook on condition of current post id?
- Complex Slider Shortcode Help
- Using _e() on text inside video tags prints that text, instead of only showing when html5 element is not supported
- Youtube shortcode
- Shortcode will not pass attribute through to my function [duplicate]
- custom field value as shortcode parameter
- How to edit blog page in wordpress? there is no place to put shortcode
- How to transform WordPress user role code to WP shortcode?
- Can I use shortcodes in mail body
- Does short-code slow down my WordPress site?
- redirect if shortcode exists
- Shortcode Help Needed → attributes
- Video Shortcode & Video Poster Question
- How to use a nested shortcode to render the value of an attribute in parent shortcode
- ob_get_clean(); doesn’t return $value in shortcode?
- Ordering get_terms with ACF not displaying all terms
- Unique ID for WordPress shortcodes when used more than once on a page?
- Which wordpress function is the caption shortcode linked to?
- Content between shortcodes
- Parsing a shortcode through an author meta textfield
- Adding YouTube button to TinyMCE editor
- Shortcode strips formatting and returns at content top
- do_shortcode within a shortcode
- tiny_mce_before_init preventing custom shortcode icon appearing
- Custom Fields – Boolean Display of True/False to Yes/No
- Twitter bootstrap tabs
- jQuery Tabs in Shortcode API
- Using Shorcodes in Sharing Preview and Notifications Title from Post Title
- Echo Extra Shortcode HTML to wp_foot
- How can I use a plugin shortcode inside of a html form?
- Disable wpautop on Shortcode attributes
- remove shortcode pagination for specific url referrer
- If statement shortcode
- Shortcode PHP file for two conditions passed when do shortcode
- update_metadata() appends shortcode data for every page refresh
- Gallery shortcode is empty but magically creates a gallery
- Display tags cloud from a specific category ID with a shortcode
- How to avoid one code multiple times instead do that through some function? Shortcode, but I think shortcode is not used in main theme’s core files?
- Shortcode appeared twice on page, one time before content, one time where it’s really called
- Get current category and place it in shortcode
- Inserting a variable into a shortcode inside php
- Using shortcodes that wrap around code
- Shortcode for Admin Theme Option?
- Clarify: Enqueueing scripts within shortcode only loads in footer?
- What makes a placeholder resizable in Tinymce?
- How to use multiple values in “Shortcode”? [closed]
- php codes ruins shortcode structure
- Getting the wrong featured image on archive page
- wp:shortcode works in block theme template file but not PHP include file
- Which PlugIns have a [subpages] shortcode? [closed]