This is pretty straightforward as far as shortcodes go:
function wpse_226998_post_author( $atts, $text ) {
if ( ! empty( $atts['id'] ) && $atts['id'] == get_the_author_meta( 'ID' ) )
return $text;
}
add_shortcode( 'post_author', 'wpse_226998_post_author' );
And in practice:
[post_author id="8"]This post is by author ID 8[/post_author]
Related Posts:
- Why are you using add_action for shortcode?
- How to get URL param to shortcode?
- Making a Shortcode [NEXT] and [PREVIOUS] to place into specific posts for post navigation
- How to display the site name in a WordPress page, or post
- Native “playlist” shortcode random playing… How?
- How to display the names of users from a specific group with a shortcode?
- shortcode for logo image
- Stop strip_shortcodes() stripping content inside shortcodes
- How do i link gallery thumbnails to different url’s using the wp native gallery?
- How to display some selected user meta data on a specific page with a shortcode?
- Gallery shortcode menu order fix no longer working on WordPress 4.0
- How to save a shortcode in a Gutenberg custom block?
- Is shortcode_unautop() broken?
- Some doubts about gallery shortcode in WordPress
- Shortcode displays only default attribute values
- Can a shortcode function this way
- Dynamically create shortcodes using add_shortcode and a callback
- Passing attributes to shortcode dynamically
- Stop parsing shortcodes
- How can I make a shortcode from this code?
- Meta tags in shortcode
- Adding PHP/HTML code inside page from custom template
- How to change page title (from a plugin) in twentytwentyone theme
- shortcode javascript not working on custom template file inside theme folder
- shortcode get thumbnail size
- Shortcodes Keep Wrapping in
- Stop auto formatting in shortcodes
- Get URL Param Plugin and Inserting Result in Widget Code
- Problem with using custom shortcode with ACF WYSIWYG field
- Add shortcode support to custom field
- Preserve shortcode content formatting
- Shortcode help: If no image entered take default
- Populate shortcodes with table data and get next row
- Running shortcode with variable that is modified
- Reloading a Mediaelement audio player
- Shortcode is not processed when added to option field using wp_editor
- How to apply an ID to Shortcode Embedded iframe
- Adding Shortcode Values to wp_head
- wp_list_pages shortcode jumps above previous content
- Shortcodes: closing shortcode not being processed
- Retrieving post excerpt as a shortcode
- Using $this from child class inside shortcode function
- Insert PHP code via shortcode?
- Trying to call dynamic content as a shortcode attribute
- What is the correct syntax to append a URL using a shortcode for an iframe?
- Shortcodes in RSS excerpts
- How to trace shortcode to its functionality
- shortcode issue in the_excerpt
- If else with shortcodes
- Using shortcodes to communicate my page design
- enqueue script with get_shortcode_regex
- Use Contact Form 7 with Ajax
- How to get_post_meta in a shortcode in excerpt on archive pages
- WordPress upgrade adding additional quote marks to shortcode output
- How to build a shortcode for tabs
- Creating tabs shortcode
- SImple Example To Update User Info From Front End [duplicate]
- How to: Simple Nested Shortcode [closed]
- get_posts not working on homepage?
- How to turn this HTML code into a shortcode? (adding song lyrics and giving an id to a div)
- ACF repeater + group shortcode
- Custom shortcode skips every 2nd shortcode
- Wrap template code with shortcodes
- my form does not insert any data in the database
- How to cache a custom API call?
- Can Someone Help me to Correct my shortcode for displaying a category?
- Shortcode custom query not passing value
- Simulate shortcodes with javascript
- How to create custom variables in wordpress
- How to use Shortcode from one WordPress page in another WordPress page?
- Unknow shortcode read on display site
- Onclick want to call shortcode in wordpress
- Working with Contact Form 7 pipes
- How to disable cache for the content returned by a shortcode
- Hide shortcodes content from the excerpt?
- WordPress Server Time not changing/displaying correctly
- Can we create a shorcode to move next page?
- Load next post by ID on a single page
- Plugin Shortcode value in post
- Add catagory attribute to custom shortcode
- Woocommerce Filter Main Loop by Tag [closed]
- Shortcodes: override a shortcode / change shortcode on the fly
- Class variables in shortcodes
- Separating Custom Template logic
- Defining the output of a WordPress Att
- Remove width and height attributes from [gallery] output
- Shortcode for sectors
- How to not show shortcode contents if cart is empty?
- woocommerce Product shortcode create [closed]
- Help with Shortcode Functionality
- Shortcode Site include in a other
- Why is my ajax live search not working when i use a shortcode to call it?
- How do write this type shortcode? [closed]
- WordPress functions.php shortcode is not working [closed]
- My first WordPress shortcode just returning []
- WordPress shortcode select option not working [closed]
- I have the query code but not the shortcode
- wordpress how to sort posts on custom data with plug-in “Search & Filter”
- How to reuse php templates as shortcodes?
- Shortcode attributes from meta query variables