Community Forums › Forums › Archived Forums › Design Tips and Tricks › Using different grids on multiple category page
- This topic has 14 replies, 3 voices, and was last updated 10 years, 4 months ago by Genesis Developer.
-
AuthorPosts
-
August 14, 2014 at 1:55 pm #118849MarijnParticipant
Hi all!
I've been looking everywhere and it seems impossible.... So my last hope..
I really want one of my category pages to have a different grid then the other category pages. Is this somehow doable??
I got like 5 category pages which are ok with the same grid look but now I made one category page on which logged-in users can post their own posts. But I want to have that category page look like sort of pinterest style, or just with 4 or 5 featured posts on a row..
Hope that someone can help me out!! Would be very much appreciated!
(oh.. and I'm not a programmer of any kind..)August 14, 2014 at 5:20 pm #118866Lauren @ OnceCoupledMemberCan you provide a link to your site? That would help with visualizing what you're asking for, and providing a more specific solution.
We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com
August 15, 2014 at 4:13 am #118944MarijnParticipantHI, thanks for your reply! The link to my blog page is: blog
So my blog page is showing 7 featured posts and now I want a specific category page to show 9 teasers in 3 columns...
August 15, 2014 at 6:07 am #118972Genesis DeveloperMemberadd_filter('post_class', 'grid_view_post_class'); function grid_view_post_class( $classes ) { if( is_category(ENTER YOUR SPECIFIC CATEGORY ID HERE)): $classes[] = 'one-third'; global $wp_query; if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns ) $classes[] = 'first'; endif; return $classes; } add_action('pre_get_posts', 'post_items'); function post_items( $query ) { if( $query->is_main_query() && !is_admin() && is_category(ENTER YOUR SPECIFIC CATEGORY ID HERE) ) { $query->set( 'posts_per_page', '9' ); } }
Add the above code in your functions.php file. Hope that it will help you.
August 15, 2014 at 6:40 am #118980MarijnParticipantHi Genwrock,
Thanks for your reply but that code resulted in an error.. I tried adding the category ID with and without the ' .
August 15, 2014 at 7:04 am #118989Genesis DeveloperMemberwhat kind of errors are you fetching?
August 15, 2014 at 7:09 am #118990MarijnParticipantHad to add the code again to reproduce the error and... now I started with the category between ' and no error.
I'm sorry for the misunderstanding..But I see no changes tot the grid, Do I need to change some more?
Thanks for your help!
August 15, 2014 at 7:13 am #118991Genesis DeveloperMembercan you give me category page link (which have grid style)?
August 15, 2014 at 7:16 am #118993Genesis DeveloperMemberoops.. I made a mistake. Please replace this line
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns )
by
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 3)
August 15, 2014 at 7:19 am #118995MarijnParticipantChanging that line gave me this error:
Parse error: syntax error, unexpected '&' in /home1/marijnb/public_html/pipstudioservies.nl/wp-content/themes/parallax-pro/functions.php on line 188
August 15, 2014 at 7:21 am #118996Genesis DeveloperMemberOk. Use the pastebin.com and put the full code of functions.php file. Next share the link. I'll look it
August 15, 2014 at 7:32 am #118999MarijnParticipantAfter the error I put back the original code you gave me and now it seems to work? So looks like you didn't make a mistake there..
See here: Link
August 15, 2014 at 7:39 am #119000Genesis DeveloperMemberPlease see the new version here http://pastebin.com/5VQQ7jjB . I modified the code little bit. Before there was a bug.
August 15, 2014 at 7:51 am #119001MarijnParticipantThanks so much!! Everything is fine now!
August 15, 2014 at 7:55 am #119002Genesis DeveloperMemberOk. Please mark this thread as RESOLVED.
-
AuthorPosts
- The topic ‘Using different grids on multiple category page’ is closed to new replies.