Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Disable Blog Example: Add new post types to author archives. By default only posts are shown on author archives, if other post types are to appear on the author archives, pass them with this filter.
<?php
add_filter( 'dwpb_author_archive_post_types', 'dwpb_example_filter_author_archive_post_types', 10, 1 );
/**
* Example: Filter `dwpb_author_archive_post_types` for Disable Blog plugin.
*
* Add new post types to author archives.
*
* By default only posts are shown on author archives, if other post types are to appear
* on the author archives, pass them with this filter.
*
* @since 0.5.0
* @param array $post_types an array of post type slugs for author archives.
* @return array
*/
function dwpb_example_filter_author_archive_post_types( $post_types ) {
$new_post_types = array(
'news', // a custom post type called 'news'.
'page', // the built-in 'page' post type, does not show up on author archives by default.
);
// array_merge below adds the post types.
// Alternatively you could do:
// return $new_post_types;
// to limit post types to only those above.
// Add the post types to those supported on author archives.
$post_types = array_merge( $post_types, $new_post_types );
return $post_types;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment