The $current_user
object retrieves the currently signed-in user. What you want is the ID of the author whose page you’re viewing. Try this:
global $wp_query;
$author_id = $wp_query->queried_object_id;
$author_posts = get_posts( array('author' => $author_id) );
$counter = 0; // needed to collect the total sum of views
foreach ( $author_posts as $post ) {
$views = absint( get_post_meta( $post->ID, 'post_views_count', true ) );
$counter += $views;
}
echo "{$counter}";
Echo out views, to see if there are any:
foreach ( $author_posts as $post ) {
$views = absint( get_post_meta( $post->ID, 'post_views_count', true ) );
var_dump($views);
$counter += $views;
}
Related Posts:
- Get $curauth level
- wp_list_authors including custom post types
- author.php shows profiles of all users not authors only
- Get author id from url
- Use different template than author.php for get_author_posts_url()
- Quest and filter posts by author ID on author page
- Is there a maximum number of author for a blog?
- Author page from blog post
- How to Modify Author Page for all Users?
- Get $curauth level
- WordPress function that retrieves both posts written by a specific author& posts that contain a tag matching author’s username on author archive page
- Display Authors Comments on Profile Page
- 5 blogs on one WordPress site
- Add admin bar link to edit author
- Creating a custom public user page
- Display all comments or recent comments per user on author page
- Limit the length of the Author Profile Biographical Text
- Author archive only for custom post type
- Show author archive pages for authors with no posts
- Refine custom posts by author
- How to make an author archive only for certain user role and show related CPT
- Creating distinct pages for author profiles and lists of posts by author
- Get the terms of a custom taxonomy for a specific author in author template
- Get data from plugin People list in author template
- Showing Author Information and Latest Post by author in lightbox when clicked on the name of the author
- pre_get_posts Tax Query not working for custom author page
- Hide Author.php template from specific user role
- How can I show a custom post type for users in the authors.php file?
- How to set back query var author_name after unset it?
- List user comments in author page
- Showing author’s page with no posts
- Create template “author” with a plugin
- Author Nickname URL Friendly
- pass query string on url to filter media
- Conditional tag based on the role of author in author.php
- How to add child page to author.php
- create a new page from a custom post type similar to an authors page
- Create Next and Previous Link to User orderby Last Name
- Display Authors in a grid loop
- Proper way to set author pages at root?
- Comments on Author page
- Showing author page if user has no post
- Post list based on the page author
- Display custom post type posts first, then default posts
- Is author.php a core file?
- Getting author URL outside the loop
- Pagination only won’t work in author template
- Most recent post is missing from Author page
- Author posts not appearing for custom post type
- Save buddypress xprofile data to author meta
- problem with wordpress author profile page URL
- next_posts_link and previous_posts_link problem
- Author template help. How to check if field exists in the profile?
- Get user posts with custom WP_Query on author.php
- Can I Include author login in post class?
- Adding Author Box Meta Links with Co-Authors
- Get 404 when try open author page
- WooCommerce get_author_posts_url() – Author URL redirecting to shop base
- wp_list_authors() returning the wrong member url
- Author Page Create Link to Page That Lists All Author’s Posts?
- Return subpages of an author if the parent page was published by an other author
- Unpublish Authors With not Fulfilled Fields
- Current author archive in navigation menu
- Display more than 10 posts on author.php file
- Get Authors Role
- Sliding-Doors Child Theme
- Display all authors in a theme template
- How do I enforce a specific custom post type on the loop
- Pagination in author, category, archive and tags pages does not work
- How to have certain WordPress settings set by default on a per author basis
- Create condition for Author bio Social Links
- How to Add a cutsom slug to my custom author role
- WordPress redirect to a subpage – how to create a template for subpage?
- Show all people who commented on all posts by an author
- Theme author.php transfer
- can’t see information on author page that don’t have posts
- Custom author url and page for another role
- User role templates
- How to create many author’s page?
- Return author name as a tag using get_author
- Buddypress profile link on author blogroll page
- Cant get unique_array() work on get_the_category() foreach loop
- Allowing comments on author pages
- Display content based on Author Custom Post type
- Missing content on author archive page
- Pagination for custom query throws 404 errors on last pages [duplicate]
- Hide page header on both index and author pages [closed]
- Author template – separate custom post type by custom taxonomy term for $curauth
- if else for custom $curauth-> field
- Show posts containing or not custom field
- Displaying posts limit: can’t get pagination to display [duplicate]
- Author.php not displaying post type posts
- Which page is referring to *all posts by author*?
- Customise Author Page?
- author.php get current id of author for advance custom field
- the_author function is displaying wrong name and url
- How to make the Post Author name fixed as “Editorial Staff” even if there are multiple authors?
- Change get_author_posts_url / Author URL via filter
- Create guest author page via php
- How to customize the author page in wordpress?