WordPress.org

Ready to get started?Download WordPress

Forums

Magic fields duplicate groups over 2 columns (4 posts)

  1. andywd7
    Member
    Posted 3 years ago #

    Hi,

    I am using Magic Fields to create a menu system for someone and have it working great so far. My problem is that I want to display, say 5, duplicated groups (dishes) in one column and then the other 5 in a 2nd column next to it!?

    I have code working to display everything fine one after another in a single column but don't know how to edit my loop to split it into 2 columns!? My code is below:


    <div class="menu">
    <?php query_posts('category_name=food&order=ASC'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php $myEvent = get_group('food section'); foreach($myEvent as $event){ ?>
    <div class="section">
    <h3><?php echo $event['name'][1]; ?></h3>
    <div class="price"><?php echo $event['price'][1]; ?></div>
    <div class="price"><?php echo $event['s-price'][1]; ?></div>
    <div class="description"><?php echo $event['description'][1]; ?></div>
    <div class="options"><?php echo $event['options'][1]; ?></div>
    <div class="price"><?php echo $event['o-price'][1]; ?></div>
    </div>
    <?php } ?>
    <?php endwhile; else: ?>
    <p>Error Message</p>
    <?php endif; ?>

    I would really appreciate some help please! I don't think I will be able to solve this on my own!?

    Thank you

  2. andywd7
    Member
    Posted 3 years ago #

    <div class="menu">
    	<?php query_posts('category_name=food&order=ASC'); ?>
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    	<?php $myEvent = get_group('food section'); foreach($myEvent as $event){ ?>
    	<div class="section">
    		<h3><?php echo $event['name'][1]; ?></h3>
    		<div class="price"><?php echo $event['price'][1]; ?></div>
    		<div class="price"><?php echo $event['s-price'][1]; ?></div>
    		<div class="description"><?php echo $event['description'][1]; ?></div>
    		<div class="options"><?php echo $event['options'][1]; ?></div>
    		<div class="price"><?php echo $event['o-price'][1]; ?></div>
    	</div>
    	<?php } ?>
    	<?php endwhile; else: ?>
    		<p>Error Message</p>
    	<?php endif; ?>
  3. hunk
    Member
    Posted 3 years ago #

    something like this

    foreach($myEvent as $k => $event){
      if($k <= 4){
       //code first column
      }else{
       //code second column
     }
    }
  4. andywd7
    Member
    Posted 3 years ago #

    Thank for your help hunk!

    Unfortunately that didn't work! But I've now realised that I'm going to have to do it slightly differently, for design reasons.

    I want to now display the first two posts (not groups) in the left column and the other, say 5, posts in the right column. Any ideas how to get it to do this!? I've tried reading about the loop in the codex but am unsure how it works with the loop and MF stuff I already have!?

    Thank you for your help and any future help! I really appreciate it!

Topic Closed

This topic has been closed to new replies.

About this Topic