- This topic has 6 replies, 2 voices, and was last updated 11 years, 1 month ago by
Tom.
-
AuthorPosts
-
January 27, 2015 at 9:30 pm #69396
Vsevolod Serbin
Hello!
At first I would like to thank you for such excellent job. Generatepress is one of the best WP Themes that I had worked with.I have a question. I use masonry blog layout, but in some categories I would like to use standart layout, with full-width blocks.
Is it possible to do without creating special templates as category-“slug”.php?
January 28, 2015 at 12:29 am #69409Tom
Lead DeveloperLead DeveloperHmm let me think about the best way to do this – will get back to you on this one in the morning.
Thanks!
January 28, 2015 at 12:13 pm #69537Tom
Lead DeveloperLead DeveloperAlright, it’s not overly easy, but it’s do-able.
First we need to add some custom PHP – this plugin is good for adding it: https://wordpress.org/plugins/code-snippets/
function generate_dequeue_scripts() { // If the category ID is 79, dequeue masonry if ( is_category( '79' ) ) : wp_dequeue_script( 'blog-scripts' ); wp_dequeue_script( 'jquery-masonry' ); wp_dequeue_script( 'blog-imagesloaded' ); wp_dequeue_style( 'blog-styles' ); endif; } add_action( 'wp_print_scripts', 'generate_dequeue_scripts', 100 ); add_action( 'wp_enqueue_scripts', 'generate_dequeue_scripts', 100 );You’ll need to replace “79” with the ID of your category.
To do multiple categories, you can do this:
if ( is_category( '79' ) || is_category( '80' ) || is_category( '81' ) ) :Now you’ll need to add a little bit of custom CSS:
.category-79 .page-header, .category-79 .inside-article { margin-right: 0; }Again, you’ll have to change the ID.
Hope this helps 🙂
January 28, 2015 at 7:59 pm #69743Vsevolod Serbin
That works!
Tom, thanks a lot!
Is it posible to use the same code for custom post types? I’m totally incompetent in PHP but I see the conditional tags.
I changed “is_category” to “is_tax” but that broke my site for a while 🙂I really appreciate your help and if this question is too much, I’ll understand.
January 28, 2015 at 10:41 pm #69798Tom
Lead DeveloperLead DeveloperYou can target custom post types like this:
$post_type = get_post_type(); if ( 'books' == $post_type ) : // Stuff in here will only happen to the "books" custom post type endif;February 4, 2015 at 9:30 pm #72369Vsevolod Serbin
Tom, thank you for help.
February 5, 2015 at 12:47 am #72435Tom
Lead DeveloperLead DeveloperYou’re welcome 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.