Tagged: , ,

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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.

    #437457

    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

    #437489

    not sure I understood.
    I don’t mean the layout of the blog page but the layout of the single post.

    #437950

    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

    #438300

    I’ll try monday morning.
    Thanks a lot.

    #438603

    Hi!

    Please try and let us know so we can mark the thread as resolved.

    Cheers!
    Yigit

    #438762

    Do I have to put them inside wp-includes?

    #438785

    Ok, consider this thread resolved. Thanks.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Different posts layout’ is closed to new replies.