Skip Navigation

[Resolved] Posts align horizontal with views on the right

This thread is resolved. Here is a description of the problem and solution.

Problem: The grid system I have set up in a View appears to be broken when an odd number of posts is shown.

Solution: Use index=pad-last to close any open rows at the end of the loop.

<!-- wpv-loop-start -->
        <wpv-loop wrap="2" pad="true">
            [wpv-item index=1]
                <div class="row"><!-- Open Row -->
                    [wpv-post-body view_template="WordPress Archive 1 - loop item 3"]
                    
            [wpv-item index=2]
                [wpv-post-body view_template="WordPress Archive 1 - loop item 3"]
                </div><!-- Close Row ( Even ) -->
 
            [wpv-item index=pad-last]
                </div><!-- Close Row ( Odd ) -->
 
        </wpv-loop>
    <!-- wpv-loop-end -->

Relevant Documentation:
https://toolset.com/documentation/user-guides/digging-into-view-outputs/#loop-shortcode-wpv-item-and-the-index-parameter

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 3.70 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by tomS-10 6 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#618656
Skjermbilde 2018-02-22 kl. 14.41.59.png
Skjermbilde 2018-02-22 kl. 14.42.25.png
Skjermbilde 2018-02-22 kl. 14.42.11.png

I have an archive page designed with layout and built with Archive and Views.

Archive
Gets the latest 12 posts within the category

Views
Gets the latest 24 posts within a post type

Both of these works, but I am having some troubles with the archive part as I want the posts to be aligned horisontally 2 and 2. Ideally 3 and 3, but I found that harder to solve as I want them to be 2 and 2 on ipad and 1 and 1 on mobile.

Archive

<!-- wpv-loop-start -->
		<wpv-loop wrap="2" pad="true">
			[wpv-item index=1]
				<div class="row"><!-- Open Row -->
					[wpv-post-body view_template="WordPress Archive 1 - loop item 3"]
                  
			[wpv-item index=2]
				[wpv-post-body view_template="WordPress Archive 1 - loop item 3"]
				</div><!-- Close Row -->
     	</wpv-loop>
	<!-- wpv-loop-end -->

WordPress Archive 1 - loop item 3

<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 item maximg blacklink">
...
</div>

The problem is when the archive only shows a prime number. Then the views gets under the archive. Please see attachments.

How do I solve this problem?

#618821

Hi, it appears that the div.row element is never closed if the number of results is odd. Try adding another item with index=pad-last, where you close the div.row:

<!-- wpv-loop-start -->
        <wpv-loop wrap="2" pad="true">
            [wpv-item index=1]
                <div class="row"><!-- Open Row -->
                    [wpv-post-body view_template="WordPress Archive 1 - loop item 3"]
                   
            [wpv-item index=2]
                [wpv-post-body view_template="WordPress Archive 1 - loop item 3"]
                </div><!-- Close Row ( Even ) -->

            [wpv-item index=pad-last]
                </div><!-- Close Row ( Odd ) -->

        </wpv-loop>
    <!-- wpv-loop-end -->

https://toolset.com/documentation/user-guides/digging-into-view-outputs/#loop-shortcode-wpv-item-and-the-index-parameter

#618875

Thank you. That explains why it didn`t work as excepted. Thank you very much.