Hi,
is there a chance to have two kind of posts layout?
I have two blogs (one for latest news and another for generic topics) and I’d like to show their posts with different layouts (e.g. the latest news with small preview image and the other blog with big preview image).
Thanks for support.
Hey Gian Maria!
You can add Blog Posts element to your “latest news” and “generic topics” and choose to display different blog style.
Regards,
Yigit
not sure I understood.
I don’t mean the layout of the blog page but the layout of the single post.
Hey!
This will require another template, to be specific, another loop-index.php or single.php whatever direction you choose. Use conditional function inside the file. OR add this in the functions.php file:
add_action('template_include', 'load_single_template');
function load_single_template($template) {
$new_template = '';
// single post template
if( is_single() ) {
global $post;
// 'cat1' and 'cat2' are category slugs
if( has_term('cat1', 'category', $post) ) {
// use template file single-cat1-template.php
$new_template = locate_template(array('single-cat1-template.php' ));
}
if( has_term('cat2', 'category', $post) ) {
// use template file single-cat2-template.php
$new_template = locate_template(array('single-cat2-template.php' ));
}
}
return ('' != $new_template) ? $new_template : $template;
}
Create a file called single-cat1-template.php for the cat1 category. Do the same for cat2 category.
Best regards,
Ismael
I’ll try monday morning.
Thanks a lot.
Do I have to put them inside wp-includes?
Ok, consider this thread resolved. Thanks.