Skip Navigation

[Resolved] Alternate Loop Layouts

This support ticket is created 3 years, 3 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by nickK-8 3 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#1890849

I have a simple loop working for one of my archives and I was hoping to alternate the layout so that odd line would appear as 'text'|'image' (rather than 'image'|'text' as on the even entries).

Is this possible?

This is the relevant archive: hidden link

#1891447

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Yes, its possible but there is no native way, there is a workaround to do that.

If you can share access details I would be happy to implement that.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1893577

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now: hidden link

I've added the following custom shortcode to "Custom Code" section offered by Toolset, that is used to identify the current loop index is even or odd based where we pass the shortcocde as attribute [wpv-loop-index] that returns the current loop index:
=> hidden link

add_shortcode('check_current_index','func_check_current_index');
function func_check_current_index($atts){
  if( ($atts['index']%2) == 0){
    return 0;
  }else{
    return 1;
  }
}

Then I've wrapped your archive loop output with container block and I wrapped container block with conditional block. For odd number row, I've set the conditional statement as you can see with the following screenshot: hidden link

Then, added another conditional block to check for even rows and added there Grid block, you can see that with the following screenshot: hidden link

You need to adjust the output of first column for the even row as i've only added image to right column, you should add your desired output to your left column for even row to your following archive:
=> hidden link

#1894883

This is exactly what I needed! Thanks Minesh!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.