Tutorials WordPress How to Include Custom Post in WordPress Author Archive Page

How to Include Custom Post in WordPress Author Archive Page

Is your WordPress theme not showing custom post on Author Archive page? Add the following code snippet to functions.php file. This WordPress hook will include custom post types in WordPress Author archive page.

//include snippet in author archive template
function custom_archive_query( $query ) {
	if ( is_author() && $query->is_main_query()) {
		$query->set( 'post_type', array( 'post', 'deals' , 'books' ) );
	}
	return $query;
}
add_filter( 'pre_get_posts', 'custom_archive_query' );
Total
0
Shares
guest
0 Comments
Inline Feedbacks
View all comments
Previous Post

How to Add Google Prettify Syntax Highlighter in WordPress

Next Post
Appium Code Snippets

Sample env.rb File for Setting up Android Testing Using Appium and Ruby

Related Posts
By clicking “Allow All”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. Cookie Notice
Allow All
0
Would love your thoughts, please comment.x
()
x