I’m trying to have a page where a user can view all of the custom post types after they click on an author from a previous page, but I’m having no luck with anything I can find in the built-in PHP functions with WordPress.
Is this some easy to query? I haven’t found much online about it.
Something like this should work:
Reference
WP_Query
classUsing an Author Template file
You can do this inside an Author Template:
author.php
— this file belongs in your theme’s directoryThis
author.php
template code is shamelessly cribbed from the Codex, and should probably be considered a starting point, not an end product.Use
pre_get_posts
to add your custom post type to your author.php templateIn your functions.php, add the following code. This will add your custom post type to the main query so that it will appear on your author page
With this, there are no need to make any changes to your template files 🙂