Never use query_posts
, use pre_get_posts
to modify any main query.
function wpd_exclude_author_category( $query ) {
if ( $query->is_author() && $query->is_main_query() ) {
$query->set( 'category__not_in', array( 42 ) );
}
}
add_action( 'pre_get_posts', 'wpd_exclude_author_category' );
Related Posts:
- the_author() returns empty string
- How to display posts by current user/author in a custom page template?
- Query posts distinct authors
- Guest Author – How to display posts on /author/ archive page
- adding my posts (author posts) in menu
- show latest authors blog post
- How to get alphabetic listing x other posts, based on first letter post?
- Add author section on Author archive posts
- Display posts on a custom page from only a specific category?
- Keep featured content post in homepage with original order
- How to get posts published between a date and today?
- How to show related posts by category
- Difference between an archive and a page listing posts
- Hook that get’s triggered when the author of a post is changed
- Prevent Authors from viewing each others Posts
- has_archive=false on the default post type
- Display Random Author with Details in Sidebar
- Clear cache when a post is submitted [closed]
- Display all posts from specific categories on a page
- How to show list of posts by author and category?
- WordPress: How to get the current logged in author page URL?
- How to add editor’s name to entry meta byline?
- Different permalink for posts and authors
- How to exclude latest x posts from a paginated query?
- Display content from a specific category
- Create an “All Posts” or “Archives” Page with WordPress 3.0?
- Post Format Archive template name for theme folder?
- post_name empty after wp_insert_post
- How to get previous 10 days post from a specific date – WP Query
- Number of posts per page setting is not working?
- Restrict the Number of Posts an Author can Publish (over time)?
- widget should display post archive by year and on click also by month
- Search posts by post author name
- Get the user type of an author
- Show the title of the latest post by author
- WordPress Posts Out Of Order after 3.1 Update
- Find most recent authors
- Query only Posts from Both of Two Category?
- Must permalinks always point to single post pages?
- Show author post count in sidebar – Variable
- Insert custom div between posts
- Can’t show comments count per post outside loop
- At my posts archive page, outside the loop, get_the_id() returns the top most post’s ID
- Get current users post URL?
- Get the author of the latest revision
- Filter posts by author and category simultaneously
- Display most recent post in category instead of archive?
- Custom Post Type & Author not associating, user post count is 0, api doesn’t return author in post objects
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- Only display posts with comments
- Single.php Active Category Class
- Post author is changed to admin after his post is modified by admin
- Link for the page archive for posts, like using custom post types with get_post_type_archive_link
- Order post by year DESC and month ASC
- WordPress get posts by date without query_posts
- How to Display Post View Count
- Get all posts by post_author
- get_post_type_archive_link(‘post’) returns current category archive
- Different amount of posts on homepage than paged pages
- Featured Posts for Category Pages
- How to get the latest posting time of archived pages in WordPress?
- How can I control multiple editing of wordpress posts?
- Multiple authors for single post without plugin
- Limit number of posts a user can make per minute?
- Cannot Update A Post, 404 Error
- Authors in menu, template list post by author
- Show the author’s count of total amount of posts assign to a custom taxonomy term
- Author must complete profile info before they can publish a post?
- Function to show random posts from a category
- WP rest api returns 404 only when author param is used
- Hiding posts in a list from specified categories
- change default post archive page link
- How can I list random authors from current post category?
- How would I get 1 latest post from a query for 5 posts?
- Filter Posts By Tag
- Can I set and show “important” post in my blog?
- Display all months with posts and inside each month show the 5 latest posts
- Display posts from #6 to #20 on archive page
- Exclude posts with empty post_content in wp_query
- Improving WP_Query for performance when random posts are ordered
- Create dropdown list post
- Category List (Archive) Page Template By Category
- I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
- How can I show wordpress posts based on author?
- previewing my posts on static page?
- Show info to author only
- Exclude newest post from category X but show rest
- Getting category posts from a certain year
- Reset Popular post query?
- Auto “expire” all of an authors posts on spcific date
- Yearly archive page for future year
- How to get the user meta data for a post?
- Which URL to enter into browser to show all posts in archive.php?
- Limit posts per author role (excluding admin) in home page
- How to display data in archive page?
- Inserting custom data to the_post() during loop
- How To Get Posts With A Specific Word
- How can I show many posts an author has per week?
- How to give capability (publish contributors posts) to author role?
- Why WP_Query(‘showposts=5’) shows only 1 post?