- This topic has 13 replies, 3 voices, and was last updated 2 years ago by Ying.
-
AuthorPosts
-
March 29, 2022 at 1:56 pm #2171657robert
Hello, I have several categories of blogs that i wish to show in a single column, whilst the rest of the site is categories is two columns.
I have read the below link but unfortunately need more simple instructions on how to impliment.Lets say for example that the name of the categroy is “Best Lounge in Colorado”
https://docs.generatepress.com/article/using-columns-in-the-blog/#changing-the-number-of-columns,
Wpuld it be possible to get a step by step guide on how to do this?.
Thanks!
March 29, 2022 at 5:00 pm #2171735LeoStaffCustomer SupportHi there,
The code should be something like this:
add_filter( 'generate_blog_get_column_count','tu_search_column_count' ); function tu_search_column_count( $count ) { if ( is_category() ) { return 100; } return $count; }
Then just replace
is_category()
with the right conditional tag as shown here:
https://codex.wordpress.org/Conditional_Tags#A_Category_PageThe
is_category( array( 9, 'blue-cheese', 'Stinky Cheeses' ) )
should be what you need with multiple categories.Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if this helps 🙂
March 30, 2022 at 10:19 am #2172763robertThis worked thanks so much. How would I add a filter so that the defined category page also showed all the contents of each article instead of just the first 25 charactors?… And is it possible to remove the read more button from these specific categories?.
The only other issue is that when i create a custom block using generateblocks and apply it to a category, the new category is still not one column. With this method I have deactivated the read more button and show all post content instead of the excerpt.
thanks
March 30, 2022 at 10:22 am #2172769YingStaffCustomer SupportHi Robert,
This should be the filter you are looking for:
https://docs.generatepress.com/article/option_generate_blog_settings/March 30, 2022 at 10:28 am #2172772robertthanks!! So it would be something like this?.
How would I apply this to specific categories?….
add_filter( ‘option_generate_blog_settings’, ‘lh_custom_search_results_page_settings’ );
function lh_custom_search_results_page_settings( $options ) {
if ( is_search() ) {
$options[‘read_more_button’] = false;
$options[‘date’] = false;
$options[‘categories’] = false;
$options[‘tags’] = false;
$options[‘comments’] = false;}
return $options;
}March 30, 2022 at 10:49 am #2172790YingStaffCustomer SupportYou just need to replace
is_search()
withis_category('your-category-slug')
.For multiple categories, the conditional tag would be something like:
is_category( array( 9, 'blue-cheese', 'Stinky Cheeses' ) )
.March 30, 2022 at 10:56 am #2172794robertthe below seems to not have any effect……
add_filter( ‘option_generate_blog_settings’, ‘lh_custom_search_results_page_settings’ );
function lh_custom_search_results_page_settings( $options ) {
if ( is_category(‘best-lounge’, ‘best-chair’) ) {
$options[‘read_more_button’] = false;
$options[‘date’] = false;
$options[‘categories’] = false;
$options[‘tags’] = false;
$options[‘comments’] = false;}
return $options;
}March 30, 2022 at 11:23 am #2172805YingStaffCustomer SupportTry use this format:
is_category( array( 'best-lounge', 'best-chair' ) )
March 30, 2022 at 11:45 am #2172818robertthanks so much….when I add the array I get a syntax error….
add_filter( ‘option_generate_blog_settings’, ‘lh_custom_search_results_page_settings’ );
function lh_custom_search_results_page_settings( $options ) {
if ( is_category( array(‘best-lounge’, ‘best-chair’) ) {
$options[‘read_more_button’] = false;
$options[‘date’] = false;
$options[‘categories’] = false;
$options[‘tags’] = false;
$options[‘comments’] = false;}
return $options;
}March 30, 2022 at 1:05 pm #2172880robertahh, this bit of code worked….
So I cannot choose to view the entire article with these options?. I just have the 25 charactor excerpt to fix….
add_filter( ‘option_generate_blog_settings’, ‘lh_custom_search_results_page_settings’ );
function lh_custom_search_results_page_settings( $options ) {
if ( is_category(‘best-lounge’, ‘best-chair’) ) {
$options[‘read_more_button’] = false;
$options[‘date’] = false;
$options[‘categories’] = false;
}return $options;
}March 30, 2022 at 2:17 pm #2172922YingStaffCustomer SupportTry this filter to show full content:
add_filter( 'generate_show_excerpt', 'show_full_content'); function show_full_content($show_excerpt) { if(is_category(array('category1','category2'))) { return false; } return $show_excerpt; }
March 30, 2022 at 2:20 pm #2172923YingStaffCustomer Supportwhen I add the array I get a syntax error….
You are missing one
)
here:if ( is_category( array('best-lounge', 'best-chair') ) {
It should’ve been:
if ( is_category( array('best-lounge', 'best-chair') ) ){
March 30, 2022 at 2:36 pm #2172930robertthanks so much!
March 30, 2022 at 2:47 pm #2172933YingStaffCustomer SupportYou are welcome 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.