-
Author
-
February 9, 2015 at 20:14 #45295jorasikParticipant
How can I modify the author.php to include posts from two custom post types?
A bit new to all the PHP stuff so I would appreciate if someone can help me with that issue.February 9, 2015 at 20:34 #45297sharmstrModeratorgoogle http://designpx.com/tutorials/custom-post-types-author-archive/
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
February 10, 2015 at 12:49 #45382jorasikParticipantYes, i already tried google and adding to the function.php the snipped of code with my custom post types, for some reason it is not working.
By default i assume it should fall to archive.php the one which is in the parent theme. Not working for me. I added an author.php with the same structure and it is not working too.
Any suggestions or directions?
February 10, 2015 at 13:16 #45396sharmstrModeratorMy cpts show up in the author archive (archive.php site.com/author/authorname). So maybe its how your cpt is set up. Do they actually support Authors? For example, Kleos Testimonials and Clients are both CPTs, but they do not have Authors. http://codex.wordpress.org/Function_Reference/register_post_type
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
February 10, 2015 at 13:22 #45399jorasikParticipantI just managed to do it. It was a small mistake in the function from the first link. Now it works just fine for getting the author posts.
Here is what I am using, maybe someone else will need it too.
COPY CODEfunction custom_post_author_archive($query) { if ($query->is_author) $query->set( 'post_type', array('posttype1', 'posttype2') ); return $query; remove_action( 'pre_get_posts', 'custom_post_author_archive' ); } add_action('pre_get_posts', 'custom_post_author_archive');
-
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.