Archived topic
Custom post type page
12 replies · Started by David on June 26, 2019
Hello
I've set up a custom post type called memorials. I've then set up a archive-memorials.php and singe-memorials.php.
I've made some changes to the archive page to show the list of the custom taxonomy called memorialcategories.
What page do I need to change to be able to change the layout of this page...
http://185.20.51.60/~markettownmemori/memorialcategories/cemetery-memorials/
Here is the archive page...
http://185.20.51.60/~markettownmemori/memorials/
Thanks
Dave
Hi there,
when you say the layout does the Layout Element not achieve what you need?
https://docs.generatepress.com/article/layout-element-overview/
Hi David
I would like it to show in 4 columns on this page...
http://185.20.51.60/~markettownmemori/memorialcategories/cemetery-memorials/
Don't think that is achievable via the layout element is it?
Thanks
Dave
I've added this to my functions.php but no luck...
// COLUMNS FOR CUSTOM POST TYPE
add_filter( 'generate_blog_columns','tu_portfolio_columns' );
function tu_portfolio_columns( $columns ) {
if ( is_post_type_archive( 'memorials' ) ) {
return 33;
}
return $count;
}
http://185.20.51.60/~markettownmemori/memorialcategories/cemetery-memorials/
The return variable name ($columns and $count) needs to match.
And it should be 25 if you want 4 columns.
Let me know :)
I changed it to this, but still no luck...
// COLUMNS FOR CUSTOM POST TYPE
add_filter( 'generate_blog_columns','tu_portfolio_columns' );
function tu_portfolio_columns( $columns ) {
if ( is_post_type_archive( 'memorials' ) ) {
return 25;
}
return $columns;
}
Any other ideas?
This is working on the archive page now...
http://185.20.51.60/~markettownmemori/memorials/
But I can't seem to work out how to do the taxonomy category pages...
http://185.20.51.60/~markettownmemori/memorialcategories/cemetery-memorials/
Try this:
add_filter( 'generate_blog_columns', function( $columns ) {
if ( is_post_type_archive( 'memorials' ) || is_tax( 'memorialcategories' ) ) {
return 25;
}
return $columns;
} );
That's great - Thanks Tom :)
What's the best way to show the columns at 50% on mobile?
Thanks
Dave
Give this a shot:
@media (min-width: 415px) and (max-width: 768px) {
.generate-columns-container .grid-sizer,
.generate-columns-container article {
width: 50%;
}
.generate-columns-activated .generate-columns-container {
margin-left: -20px;
}
.generate-columns-container > * {
padding-left: 20px;
}
}
Thanks Tom :)
You're welcome :)