- This topic has 8 replies, 2 voices, and was last updated 12 months ago by
Tom.
-
AuthorPosts
-
April 12, 2020 at 12:19 pm #1236513
George
I have my blog layout to not display as columns but I am using the following code to display columns on the Tutorials which is a custom post type category and News pages (news pages is the default blog):
add_filter( 'generate_blog_columns','gm_portfolio_columns' ); function gm_portfolio_columns( $columns ) { if ( is_category( 'tutorials' ) || is_post_type_archive( 'tutorial' ) || is_archive() ) { return true; } return $columns; }
It works but the Tutorials search results do not display as columns. On top of that, the Forums search results (bbPress) display as columns and I would like the forum search results to display as per Blog layout settings.
April 12, 2020 at 4:28 pm #1236669Tom
Lead DeveloperLead DeveloperHey George,
How are search results for tutorials determined? Just when the “tutorials” search term is entered?
You could try something like this to handle everything:
add_filter( 'generate_blog_columns', function( $columns ) { if ( is_category( 'tutorials' ) || is_post_type_archive( 'tutorial' ) || is_archive() ) { return true; } if ( is_search() && 'tutorials' === $_GET['s'] ) { return true; } if ( function_exists( 'bbp_is_search' ) && bbp_is_search() ) { return false; } return $columns; } );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 12, 2020 at 4:34 pm #1236674George
Hi Tom.
How are search results for tutorials determined? Just when the “tutorials” search term is entered?
You can search for tutorials on the tutorials page on the header through the search bar. Just type a relevant keyword from the tutorials underneath to get some results.
I put your code in, still the same behavior, though.
April 12, 2020 at 4:38 pm #1236677Tom
Lead DeveloperLead DeveloperStrange, give this a shot to fix the forum search:
.forum-search .generate-columns-container:not(.masonry-container), .forum-search .generate-columns-container:not(.masonry-container) .generate-columns { display: block; } .forum-search article { width: 100%; }
The GP columns won’t work properly in the bbPress search itself due to the HTML markup, so the above should just force full width.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 12, 2020 at 4:43 pm #1236681George
Great, that fixed the forum search results. The tutorial search results still display as per blog layout and not as columns. Just enter “wordpress” in the Tutorials search bar to get some results.
April 12, 2020 at 4:45 pm #1236683George
Also, the forum results display the load more button even with few results. Is it possible to have pagination there?
April 13, 2020 at 9:20 am #1237556Tom
Lead DeveloperLead DeveloperFor the tutorials, try this:
add_filter( 'generate_blog_columns', function( $columns ) { if ( is_search() && isset( $_GET['post_types'] ) && 'tutorial' === $_GET['post_types'] ) { return true; } return $columns; } );
For the load more, try this:
add_action( 'wp', function() { if ( function_exists( 'is_bbpress' ) && is_bbpress() ) { remove_action( 'generate_after_main_content', 'generate_blog_load_more', 20 ); } } );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 13, 2020 at 11:40 am #1237720George
Nailed it, Tom.
Here is the final code:
add_filter( 'generate_blog_columns', function( $columns ) { if ( is_category( 'tutorials' ) || is_post_type_archive( 'tutorial' ) || is_archive() ) { return true; } if ( is_search() && isset( $_GET['post_types'] ) && 'tutorial' === $_GET['post_types'] ) { return true; } if ( is_search() && 'tutorials' === $_GET['s'] ) { return true; } if ( function_exists( 'bbp_is_search' ) && bbp_is_search() ) { return false; } return $columns; } ); add_action( 'wp', function() { if ( function_exists( 'is_bbpress' ) && is_bbpress() ) { remove_action( 'generate_after_main_content', 'generate_blog_load_more', 20 ); } } );
Thank you, once more!
April 13, 2020 at 4:32 pm #1237962Tom
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.