Showing Custom Post Type on Post Author Archive Page

As the title says, I need to display custom post types also the post authors page (http://domain.com/author/authorname)

Now i’ve got a function that should do this, But because the way that this theme has the page coded I need assistance please.

function custom_post_author_archive($query) {
if ($query->is_author)
$query->set( ‘post_type’, array(‘custom_type’, ‘post’) );
remove_action( ‘pre_get_posts’, ‘custom_post_author_archive’ );
}
add_action(‘pre_get_posts’, ‘custom_post_author_archive’);

Can someone please assist here

Thanks, I also want to display a title at the top of the author posts page that says “Posts By NAME

Thanks!

Sorry for the delay here.

Do you still need assistance for it so we can help you?

Yes please, still need assistance. Feel free to email me if you need to via webmaster(at)bcsv(dot)org(dot)au

You can try achieving this by using the attached small plugin specially developed for you that contains following custom code.

Please change the post type ‘page’ in the following plugin code to whatever you want to include.


function custom_post_author_archive($query) {
if ($query->is_author){
$query->set( 'post_type', array('page', 'post') );
}
}
add_action('pre_get_posts', 'custom_post_author_archive');

/**
 * Show the title in header
 */
function travelify_header_title() {
	if( is_author()  ) {
		$travelify_header_title = __( 'Posts By', 'travelify' )." ".get_the_author();
	}else if( is_archive() ) {
		$travelify_header_title = single_cat_title( '', FALSE );
	}
	elseif( is_search() ) {
		$travelify_header_title = __( 'Search Results', 'travelify' );
	}
	elseif( is_page_template()  ) {
		$travelify_header_title = get_the_title();
	}
	else {
		$travelify_header_title = '';
	}

	return $travelify_header_title;

}

Sadly there is an error activating the plugin… See screenshot attached

You are getting this error because the function travelify_header_title added in the above plugin is already used in the virtual museum author posts plugin you are using on your site.

Please try disabling virtual museum author posts plugin.

Thanks movin.
That plugin is the one you listed above.
As a reference for the client knowing what purpose it serves, I renamed it to Virtual Museum Author Posts.

Sorry to be a pain

Please do not change anything in the plugin and use it initially as it is which i provided you and if it works then change it.

If it doesn’t work for then would you mind if i log in to your site and do some troubleshooting? If this is ok then could you please share me your site log in details privately by checking the option “Set as private reply” when replying to this topic?

Hey Movin!

Sure.

Username is colorlibsupport
Password is fds^&*3gf9

The error still came up, and when looking at the file it was referencing, the line of code it was referencing has been highlighted in the following attached screenshot.

Cheers again!

Thank you for sharing the site details but you didn’t share your site URL?

I’m so sorry.

http://bcsv.org.au/login
Or
http://bcsv.org.au/admin

Hey Movin!
Just looking for an update if I can please.

Thanks mate :slight_smile:

It seems the issue is occurring on your shared site because you have modified the default theme.

Please share me the file BCSV/library/structure/header-extensions.php from your modified theme so that i can help you to resolve the issue.

Hello movin. File is attached.

Thanks!

I saw the following code in your shared file which is conflicting with plugin code either remove this code then use the plugin or just replace this code with plugin code and do not use plugin in this case.


if ( ! function_exists( 'travelify_header_title' ) ) :
/**
 * Show the title in header
 */
function travelify_header_title() {
	if( is_archive() ) {
		$travelify_header_title = single_cat_title( '', FALSE );
	}
	elseif( is_search() ) {
		$travelify_header_title = __( 'Search Results', 'travelify' );
	}
	elseif( is_page_template()  ) {
		$travelify_header_title = get_the_title();
	}
	else {
		$travelify_header_title = '';
	}

	return $travelify_header_title;

}
endif;

Movin you are awesome!
Thank you so much for your time and effort :slight_smile:

You are most welcome here :slight_smile: