- This topic has 9 replies, 3 voices, and was last updated 4 years ago by
Tom.
-
AuthorPosts
-
February 25, 2019 at 12:33 pm #821323
Aart
Hi,
I have a custom post type called ‘recept’. I’m trying to do two things:
1. Show all ‘recept’ content on their authors’ respective archive pages.
2. Adding GP columns and masonry to all archive pages of this post type.I’ve managed 1) by creating a little plugin, but I’m having some trouble with 2). I have both columns and masonry working with the help of these code snippets, but I can’t get it to work on the author pages.
I hope you can point me in the right direction.
Best regards,
Aart
GeneratePress 2.2.2February 25, 2019 at 3:44 pm #821440Leo
StaffCustomer SupportHi there,
What’s the condition you are currently using?
Have you tried this?
https://codex.wordpress.org/Conditional_Tags#An_Author_PageEverything should be listed on that page.
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 26, 2019 at 10:55 am #822487Aart
Hi Leo,
I’m currently using this for the post archive pages:
add_filter( 'generate_blog_columns','tu_portfolio_columns' ); function tu_portfolio_columns( $columns ) { if ( is_post_type_archive( 'recept' ) ) { return true; } return $columns; }
I want to extend this to all archives, including the author archive, but I’m not sure how to do that.
February 26, 2019 at 4:41 pm #822728Leo
StaffCustomer SupportWhat if you just do this instead?
https://codex.wordpress.org/Conditional_Tags#Any_Archive_PageDocumentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 2, 2019 at 2:13 am #826303Aart
Hi Leo, thanks your help. I tried changing condition to is_author, like this:
add_filter( 'generate_blog_columns','tu_portfolio_columns' ); function tu_portfolio_columns( $columns ) { if ( is_author ) { return true; } return $columns; }
Sure enough it worked on the author archive pages, showing the content in columns. Unfortunately it also affected the rest of the site, causing page sections to overlap each other on single pages (like the comment box overlapping the content) and the homepage (which contains WP Show Posts).
So I guess this is not the full solution. I also don’t know how to apply this filter to both the post type archive and the author archives using the same code snippet. I’m sorry I don’t understand enough about PHP to do this myself, but I hope you can help me with the correct code.
March 2, 2019 at 9:38 am #826676Tom
Lead DeveloperLead DeveloperHmm, it shouldn’t ever happen on single posts. Is there a specific page where I can see that happening?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 2, 2019 at 10:23 am #826703Aart
Hi Tom, thank you for replying. I’ve turned on the snippet again, so now can see it in action on any page, like this one (link). You can also see something strange happening on the front page: the footer is where the main content should start.
This is the full snippet I’m using:
add_filter( 'generate_blog_columns','tu_portfolio_columns' ); function tu_portfolio_columns( $columns ) { if ( is_author ) { return true; } return $columns; } add_filter( 'generate_blog_masonry','tu_portfolio_masonry' ); function tu_portfolio_masonry( $masonry ) { if ( is_author ) { return 'true'; } return $masonry; }
I also tried disabling all GP Elements that are active, without result.
March 2, 2019 at 10:09 pm #827018Tom
Lead DeveloperLead DeveloperInstead of
is_author
, tryis_author()
.Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 3, 2019 at 12:03 am #827059Aart
Thank you so much Tom, that did it! π
So now I’m using this as the filter for columns in all relevant views (author, taxonomy, archive):
add_filter( 'generate_blog_columns','tu_portfolio_columns' ); function tu_portfolio_columns( $columns ) { if ( is_author() ) { return true; } if ( is_tax( array( 'keuken', 'gerechtsoort' ) ) ) { return true; } if ( is_post_type_archive( 'recept' ) ) { return true; } return $columns; }
It’s working great, thanks again!
March 3, 2019 at 9:21 am #827523Tom
Lead DeveloperLead DeveloperYou’re welcome π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.