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
- How to get posts published between a date and today?
- Difference between an archive and a page listing posts
- Display Random Author with Details in Sidebar
- Clear cache when a post is submitted [closed]
- Create an “All Posts” or “Archives” Page with WordPress 3.0?
- How to get previous 10 days post from a specific date – WP Query
- widget should display post archive by year and on click also by month
- 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?
- 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
- How can I control multiple editing of wordpress posts?
- Show the author’s count of total amount of posts assign to a custom taxonomy term
- WP rest api returns 404 only when author param is used
- How can I list random authors from current post category?
- Filter Posts By Tag
- Category List (Archive) Page Template By Category
- Exclude newest post from category X but show rest
- Reset Popular post query?
- Limit posts per author role (excluding admin) in home page
- Display posts with tag that matches current post title
- Why is querying posts messing up my pages?
- Getting the current author (it has changed) of a post, not the original author
- Multi row post list
- Showing author page if user has no post
- posts_per_page option limits the number of Gallery items
- How to display excerpt post on hamepage and archive pages?
- Display Posts on Custom Page
- Show comment number per author per day
- Get all comments of author’s posts
- Counter is skipping post when I still want it visible [closed]
- If contributor has published 2 or more posts then show otherwise hide
- Change post author without using wp_update_post()
- wp_query with ajax
- How to give classname to post if post has no content?
- singular posts using archive styling
- Custom posts listing widget always returns 1 extra result
- WordPress post filter menu
- Send email to author of post on post submission
- Get x recent posts by author?
- Get postlist for each category using query_posts?
- How to save posts position on homepage after random function?
- WordPress query portfolio posts
- Get latest author posts inside the loop
- How to get posts ordered by using their categories?
- WP_Query articles order by offset in collumns
- Display message depending on capability outside loop
- How do I disable the “by author” hyperlink on posts?
- Display 3 posts with different HTML markup using a loop
- Authors’ Links on Homepage Not Going to Author Post Pages
- How to view all posts (on site, not admin) that are uncategorized?
- How to assign a post to a post parrent?
- query for filtering published posts?
- get parent fields title, content excerpt etc
- AWS usage queries
- Pull in posts using post meta for REST API
- how to show comments only author which send own posts in wordpress
- How to fetch courses in all languages in WordPress?
- Change of author not updating
- How to show post views shortcode data for each post on Posts List Page?
- How can I use query_posts to loop through posts and construct my own content?
- Assign a day of the week to post, e.g: Assign Monday to post and have it only appear when the day is Monday
- On WordPress Search, how to search post from Author meta also
- Get posts from category from custom query
- Show 5 posts and than 3 posts offset with pagination
- How to hide meta from search result only on pages?
- WP_Query to get posts in a specific tag or has post_format
- Make recent post display recent updated, instead of recent published
- Numbering author posts in posts query
- Custom author search
- Page 2 has no posts?
- Sort / Filter Queries
- get_page_by_title() not working if special characters are present
- Modify WordPress loop after it has been run
- Ordering posts alphabetically by meta keys and title
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- How do I control the fallback query after the original query returned cero posts?
- Remove duplicated posts in the loop if post has more than one category
- Getting posts from multiple users?
- How to organise post by category and date
- Adding a category at even positions on main loop with modified pagination
- Display the current post author and his url in the post header
- How do I display the next 3 posts in the sidebar?
- Show all posts in category
- how to show all type of author posts in author page (SOLVED)
- Change from all posts to specific categories post on main page?
- Count words for all posts by all authors
- Word count for all posts of all authors
- Sort Posts Alphabetically Based on Specific Category (Divi)
- How to change url of posts?