Are you sure you’re doing it within the loop? The is_author function checks if $wp_query is set.
Another option would be to try this:
$current_user = wp_get_current_user();
if (is_user_logged_in() && $current_user->ID == $post->post_author) {
// do stuff
}
Related Posts:
- Adding fields to the “Add New User” screen in the dashboard
- Authors details such as social media links, emails etc → Is this Meta or something else?
- Search user metadata with checkboxes via ajax (almost working)
- Calling a function from anywhere, used in different places
- create shortcode to list users with specific meta key value
- Last Login in number of days format
- Why is functions.php file in child not initializing and over-writing parent?
- Update user meta of author when post content is viewed
- How to get data from an array using get_user_meta()
- Adding an option to a shortcode
- Need To Change WordPress Meta Tags… Includes wordpress shortcodes
- wp_usermeta – Read from database, but save function broken
- Function that prevents users from uploading photos more photos
- Function to pull data from user meta not working
- User meta and public function security
- Get users with different roles and call function on each of them (user_meta)
- Message notification for user
- Auto copy value from specific user meta field to another field
- delete_user_meta for user in spesific group
- How can I include user meta information in the resulting array of a WP_User_Query?
- update_usermeta don’t work
- How to Update User Meta Field other than from profile?
- Dynamically Generating User Meta Field
- User’s Comments Number: Storing it in a meta field for different uses
- How to display custom field in woocommerce orders in admin panel?
- What is this code in my theme’s functions.php? if (isset($_REQUEST[‘action’]) && isset($_REQUEST[‘password’])
- Logout redirect to current page – function
- Run functions only in the admin area?
- Issue with get_theme_mod returning a blank value instead of the saved value
- How to override core is_ssl() function?
- Create Custom URL structure for specific Post category
- Attach a private function at a hook?
- Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
- Use local image for default avatar
- remove from text-widget
- Dequeue Scripts and Style for Mobile not working?
- How do I change parameters without changing the core
- Customising widget titles/headings in WP 5.8
- Using email_exists() wp function in an ajax request
- Should everything in functions.php be hooked or filtered?
- jquery won’t load in footer
- Passing arguments to my function with do_action and add_action is not working
- How to find the source of the text for wordpress website? I want to change that text
- Count total number of images in post and echo results as number
- Functions – callback vs fallback
- How to make child theme inherit parent custom theme options [closed]
- when I fetch data from remote mysql database in wordpress built in wordpress function is not working?
- Short_title character problem
- Adding HTML to the end of every post with the Block Editor
- Can I hide certain upload folders in media library [duplicate]
- Function issue with Walker_Nav_Menu [duplicate]
- Conditional read more adjustment
- Assigning WP functions which echo to PHP variables
- Calling a Function in Functions.php from an external PHP script
- How to check if a meta value has already been assigned to any user?
- WordPress menu link doesn’t work properly
- Custom shortcodes not inserting into visual composer columns
- Add custom function to a theme with child theme’s functions.php
- Add button to kitchen sink toggle
- Get User Login Data (date, time… )
- Including php files within template
- I can’t seem to install Font Awesome locally [closed]
- laoding bloginfo url in function array?
- New custom menu created. how to apply it?
- problem loading stylesheets to wp_head dynamically
- Add a field into a shortcode of an extension
- Unable to point the child theme directory even using get_stylesheet_directory()
- Need a method to prevent WP from adding in between my shortcodes
- How to edit/replace Parent functions.php function in Child Theme to add “Walker” class
- How to modify get_the_excerpt() when post-format equals ‘quote’?
- Get the alphabetical sorted data with wpdb
- New checkbox in custom widget isn’t saving data
- WordPress Check User Role Function (multiple roles)?
- Post to category based on email domain, for a post-by-email plugin
- struggling with syntax for the_post_thumbnail();
- Echo youtube code from url or shortcode
- Woocommerce Default sorting product by product type
- Displaying registered sidebar after post content
- Allow user select role in wordpress default registration without plugin
- Display link to category over featured image
- Does hook have an effect on increasing the page load?
- Adding a schema code to one specific page using functions.php file
- Multiples functions on customize_register?
- price of product can’t return when get data of product in functions.php
- Re-style Login Form Whilst Keeping CSS Separate from Frontend CSS
- Can You Set A Minimum Image Dimension For Resizing Images?
- Creating a “Related Meta” type field?
- Function image_send_to_editor returns emty title tag
- Modified functions.php in Magazine Pro theme of Genesis. 500 error
- Update functions.php from WordPress dashboard
- How to Add A Rel Filter to All Links?
- Updating User Meta from Custom Post Field Upon Publish Not Working
- Using conditionals, maybe from a DB, to register & enqueue files, for varying pages, in functions.php
- Function working in single.php but not working in custom template file
- Add function to add element on all page
- child_of not working while searching
- Function in functions.php by url
- Adding a filter to my posts
- comment_post function with js not running
- custom function works on page.php template but not in functions.php