Archived topic
Display posts as list on category page
5 replies · Started by Ayoosh on November 20, 2020
I am working on customizing few options on my site and like to customize the category page to show the posts and numbered lists ( I don't have any image and other stuff), here is how I might want to display the data on category page.
https://pasteboard.co/JBjPmQG.png
How can I do that without impacting any other page
Hi there,
you would need to use the option_generate_blog_settings filter to disable the elements you don't require:
https://docs.generatepress.com/article/option_generate_blog_settings/
Heres an example PHP Snippet that disables some elements on the category archives:
add_filter( 'option_generate_blog_settings', 'db_custom_category_archive' );
function db_custom_category_archive( $options ) {
if ( is_category() ) {
$options['read_more_button'] = false;
$options['date'] = false;
$options['categories'] = false;
$options['tags'] = false;
$options['post_image'] = false;
$options['column_layout'] = false;
$options['featured_column'] = false;
$options['masonry'] = false;
}
return $options;
}
Thanks for your response David, I do have following questions
1. With this hook , I am still seeing the excerpt in the category page. I am assuming this is because of the standard WordPress if we manually adding excerpt to our posts.
2. I still don't see this as an ordered list, is there a way I can work on the CSS using premium options? Current category page layout have too much space and all I need is a ordered list.
Note: I have removed the excerpt using the standard WP hook
You can check layout at https://staging.javadevjournal.com/category/spring-security/
Thanks
Ayoosh
So first off to remove the Excerpt, apply the PHP Snippet provided here:
https://docs.generatepress.com/article/excerpt_length/
Then add this CSS to display the Counter:
.archive.category .site-main {
counter-reset: section;
}
.archive.category .site-main article h2:before {
counter-increment: section;
content: counter(section) '. ';
}
.archive.category .entry-summary,
.archive.category .entry-meta {
display: none;
}
/*** Optional ***/
/* remove padding from article */
.archive.category .site-main article .inside-article {
padding-top: 0;
padding-bottom: 0;
}
/* Change the font size */
.archive.category .site-main article h2 {
font-size: 24px;
}
I have included some optional CSS to style the article and post title if you need to.
Hey David,
Thanks for your quick and wonderful response, I am able to fix most of the issue and layout is very close to what I was thinking :)
Thats great! - Glad to be of help