Skip to content
Advertisement

WordPress – template part break wordpress columns layout

I think that some help will be appreciated. I have this code that will load two template part for a wordpres custom theme:

JavaScript

As you can see under the hood I’m using bootstrap 4 so it’s supposed that the content will align itself inside the same row.

I have a col-8 inside the main-news.php and a col-4 inside the side-news.php so I supposed that I will have the contents aligned, but this will not happen and my layout will break.

this is the code inside the main.news.php teplate part:

JavaScript

this is the content of side-news.php

JavaScript

How I can fix the layout to have the col-8 and the col-4 on the same row line?Maybe I need to nest the loops or what? See the scree to understand what’s happening now

enter image description here

Advertisement

Answer

your mistake is inside the main-news.php file. look, you defined these (col-sm-12 col-md-8 col-lg-8 ) for your first div tag in the main-news.php file so your div takes those columns and then you defined these (col-sm-12 col-md-8 col-lg-8 ) columns for the div tag inside of the loop at the same file so both divs take more than 12 columns just inside the main-news.php file whereas you defined (col-sm-12 col-md-4 col-lg-4) for the div inside of the side-news.php file again so these definitions break your code.

Solution: You should delete the columns definition from one of the divs inside the main-news.php file.

GOOD LUCK!!!

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement