• Resolved TheXrion

    (@negarehgfx)


    I have problem with Displaying posts per row by my own custom query. I used css classes of my current theme while everything is good with default theme grid displaying So i Use the exactly the same css classes to displaying posts with grid for my custom query but each post is displaying in 1 row !

    This is my code

    function mycustomquery(){
    
            
                    
                    $args = array(
                        'post_type' => 'post',
                        'posts_per_page' => -1,
                        'meta_key' => 'car',
                        'meta_compare' => '>=',
                        'meta_value' => 'dodge', 
                        'orderby' => 'rand',
                        
                    );
                    $query = new WP_Query($args);
                    while($query -> have_posts()) : $query -> the_post();
            ?>
            
           <div class="fw-container">
                  <div class="fw-row">
                 <div class="post col-md-12">
                  <div class="post_list post_columns_3">
                 <div class="post_inner">
               
    
             <a href="<? the_permalink(); ?>"><? the_post_thumbnail('medium-thumbnail');?><?php the_title(); ?></a>
           
           </div>
           </div>
           </div>
           </div>
           </div>
    • This topic was modified 5 years, 7 months ago by TheXrion.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Can you post a link to a sample page? Maybe it’s a CSS issue instead of a code issue.

    Thread Starter TheXrion

    (@negarehgfx)

    Yes this is css issue but i cant post a link or screen shot of it because its running in local host and some other reasons , I describe everything in my post .
    The problem is : each post is in each row
    But exactly the theme that used same css style will shown for ex : 4 Post per row

    Best Regard

    OK, I think I see the problem. Try putting these DIVs outside the loop:

           <div class="fw-container">
                  <div class="fw-row">
                 <div class="post col-md-12">
                  <div class="post_list post_columns_3">
    

    That is, I think those should be one container for the whole listing of posts, and the way you have it set up, inside the loop, means that you’re going to get one row for each post.

    Thread Starter TheXrion

    (@negarehgfx)

    Thank you @crouchingbruin for your guidance That’s worked but with some changes (some <div>s should be use outside of the loop and some should use inside)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display 4 Post per Row Issue’ is closed to new replies.