• Resolved revistataller9

    (@revistataller9)


    Hi, I created a child for the Gateway theme and was able to enable the post formats. Now I’m trying to edit the CSS in a way my image posts use a full width template. I already read A LOT of threads here and in other forums but the solutions they post there don’t work for me. At this point I should say I know NOTHING about coding so, if you are kind to provide me with full specifications on how to achieve this, it would be much appreciated.

    Thanks in advance!

    PD: here’s a link to my website , and here is a link to an image post

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter revistataller9

    (@revistataller9)

    I′m the Jon Snow of coding

    Thread Starter revistataller9

    (@revistataller9)

    As it turns out, the way to achieve this kind of post (I’m talking about regular posts here, not a Custom Post), was to add this piece of code to the functions.php file on my child theme:

    add_action('template_include', 'load_single_template');
      function load_single_template($template) {
        $new_template = '';
    
        // single post template
        if( is_single() ) {
          global $post;
          // 'cat-1' and 'cat-2' are category slugs
    
          if( has_term('cat-1', 'category', $post) ) {
            // use template file single-template-cat-1.php
            $new_template = locate_template(array('single-template-cat-1.php' ));
          }
    
          if( has_term('cat-2', 'category', $post) ) {
            // use template file single-template-cat-2.php
            $new_template = locate_template(array('single-template-cat-2.php' ));
          }
    
        }
        return ('' != $new_template) ? $new_template : $template;
      }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Full width posts’ is closed to new replies.