-
AuthorPosts
-
April 29, 2015 at 2:30 pm #436686
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.April 30, 2015 at 2:29 pm #437457Hey Gian Maria!
You can add Blog Posts element to your “latest news” and “generic topics” and choose to display different blog style.
Regards,
YigitApril 30, 2015 at 3:00 pm #437489not sure I understood.
I don’t mean the layout of the blog page but the layout of the single post.May 1, 2015 at 10:23 am #437950Hey!
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,
IsmaelMay 1, 2015 at 11:15 pm #438300I’ll try monday morning.
Thanks a lot.May 3, 2015 at 10:11 pm #438603May 4, 2015 at 8:56 am #438762Do I have to put them inside wp-includes?
May 4, 2015 at 9:36 am #438785Ok, consider this thread resolved. Thanks.
-
AuthorPosts
- The topic ‘Different posts layout’ is closed to new replies.
