This code will do it:
global $post;
$user = get_user_by( 'ID', $post->post_author );
if ( in_array( 'author', $user->roles ) ) {echo "Author";}
You don’t even need global $post;
if you are if a query loop.
Related Posts:
- How to update custom fields using the wp_insert_post() function?
- Update value of a associative array with update_post_meta
- get value from get_post_meta then reuse it in another get_post_meta
- When working with a post, almost all wp_postmeta are deleted
- Post from front end form to post_meta
- How to display the date under the post title?
- How do I get a function to work in single.php
- Disable Attachment Pages Completely
- Inject post (from specific category) between posts in Loop
- Get meta_id along with meta_key and meta_value
- Remove option to allow trackbacks/pingbacks from post page options
- How can merge two arrays values in one array and save in database
- How to get year, month and hour in WordPress?
- the_post_thumbnail() based on the Post ID
- How to use multiple query with same meta key
- Why is my get_post_meta always empty
- Compare two meta key values against each other inside the get_posts array?
- Handling an Ajax form submit
- Use ajax to update_post_meta
- Print number of post (in reverse)
- Count number of published posts by type
- Automatically generate Post/Page from searched Database item?
- Get taxonomy terms only of the WP_Query current posts
- How to get 2 or multiple custom post types in wordpress functions.php
- Change description on specific WooCommerce product status change
- Displaying a button on each post
- Hide post if matches current month and year
- Use WP_Query in shortcode
- Creating bulk posts with Youtube videos
- How Display Posts on category
- Random order of WP_Query results with highest meta value
- Getting a specific post values to another div or modal
- Trying to remove post thumbnail with plugin
- Unreadable pagination
- how do I get a specific post from a post with a subcategory in WP
- Creating user status mode in WordPress
- Open post-content in archive page in a Modal box with bootstrap
- remove post that has no content
- How to show only subcategories in parent category not parent category?
- Get post id within comments loop
- WP Insert Post and then go to post
- Get latest post from all categories except one
- Parse error: syntax error, unexpected end of file
- Automatically add images to a menu
- Load Posts on Click via Ajax into a DIV
- How to catch wordpress post ID when it’s published
- How to use two meta_compare in an array?
- Store metakey value as an array
- Remove empty terms from array, sort alphabetically, update back to repeating field
- Only show first image in foreach loop
- WordPress yoast seo plugin – parse snippet var in meta description
- create front-end users post list by specific category
- Using rules in Posts
- show recent posts php code error?
- Error display post thumbnails for previous and next post
- Post to WordPress from another Server via PHP
- Save the value of a wp_dropdown_pages
- form $_post action value gets truncated after it passes through two forms
- Wrap posts p tags in div
- Wp Query : Order by distance lat,lon
- Generating 10 000 WordPress posts using PHP and avoiding Server Timeout error
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- WordPress Post Block Element not properly parsed with the_content filter
- Filter wordpress posts without searching the keywords in the post content
- Build A Custom SQL Query for WordPress Search
- WordPress Custom Form – Getting Query Vars, Weird Glitch?
- How to Send Pingbacks for all Posts in WordPress?
- Loop for recently (updated_post_meta) posts?
- Display articles with a different template in the home page | Solved |
- How can I check if a post with a particular slug or title exists?
- WordPress sorting posts by date and title using a dropdown
- How to get post titles by post ID and integrate with my code?
- Trying to get post ID outside loop on blog page
- Using zip code to display custom data in Admin Order Details
- Infinite looping next post link within a certain category on a post
- Enqueue script only on child pages of custom post types
- Attach and retrive multiple pdf files to post or page
- Send POST request to Flask app from functions.php file
- update_post_meta Not Processing Array Data (Not Sure What I Am Missing)
- Get list of posts from attachment
- Send Notification after post published was working but stopped after the last WP update
- How to insert text into post based on category – via single.php file
- Displaying POST content with HTML tags and all
- Generate random access token to a post page
- Updating Lat and Lng of posts automatically gives sporadic results
- Pagination in WP Queries
- Add div after every 4 posts then every 2 posts for a responsive loop
- Only display notification on single post
- Get posts associated with media attachment
- Can’t put a hyperlink on Featured Post’s Image
- Passed variable gets undefined variable error on insert on next page
- WordPress get_post_meta issue
- Automatically create a loop for post ID
- Why does WP_Query show only the same post even with different categories and endwhile?
- Display pages from specific page template
- get_post_meta is always empty when I use wp_mail
- Query posts by custom fields (object post)
- Excerpt all post content Content Same Size without word cutting off
- WooCommerce: write featured image dimensions to custom fields in product’
- transition_post_status hook, works – but not if the post is new