- This topic has 8 replies, 2 voices, and was last updated 4 years ago by Tom.
-
AuthorPosts
-
April 12, 2020 at 12:19 pm #1236513George
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 #1236669TomLead 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; } );
April 12, 2020 at 4:34 pm #1236674GeorgeHi 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 #1236677TomLead 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.
April 12, 2020 at 4:43 pm #1236681GeorgeGreat, 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 #1236683GeorgeAlso, 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 #1237556TomLead 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 ); } } );
April 13, 2020 at 11:40 am #1237720GeorgeNailed 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 #1237962TomLead DeveloperLead DeveloperYou’re welcome 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.