i'm working on my first WP site and need to display an author's role next to their post. Something like "Jimmy | Administrator". Looking at the author metadata available: http://codex.wordpress.org/Function_Reference/the_author_meta doesn't give me a way to access that. I'm sure there's a quick easy way to do this and i just don't know it!! Thanks!
相关问题
- Display product ACF field value in Woocommerce tra
- Adding a custom button after add to cart button in
- How to add a “active” class to a carousel first el
- Setting custom order statuses as valid for payment
- change the font size in tag cloud
相关文章
- wordpress新增页面如何个性化设置
- select query in wordpress
- Get WooCommerce featured products in a WP_Query
- Woocommerce update shipping methods in checkout vi
- Change order status just after payment in WooComme
- Publishing or uploading failed. Error message: “Th
- Facebook Login With WP JWT Auth
- Wordpress development process
UPDATE: Place this in your functions.php file:
Then call this within your Wordpress Loop. So:
...will print: 'Jimmy | Administrator'
COMPLETE ANSWER: The User Object itself actually stores roles, and other kinds of useful information. If you want more of a general function to retrieve the role of any given user, simply pass in the ID of the user you want to target with this function:
And if you want to grab the author of a given post, call it like so:
RESPONSE TO LAST COMMENT:
If you need to grab data outside of the Wordpress Loop (which I imagine you're trying to do on an Archive and Author page), you can use the function from my Complete answer like so:
That will output the information you want in your "user | role" format.