// // // if ($groups_user->can('My Consumables')) { ?> <div class="page-title"> <h1>Hello <?php echo $current_user->first_name; ?> ,</h1> <?php $my_products = array(); $my_groups = array(); query_posts(array('post_type' => 'product', 'posts_per_page' => '-1')); while (have_posts()) { the_post(); get_page_group_machines(); foreach ($page_machines as $machine) { $my_products[] = $machine; } foreach ($page_groups as $group) { $my_groups[] = $group; } } $my_products = array_unique($my_products); $my_groups = array_unique($my_groups); ?> <h5>Here are some products compatible with your <?php $count = 1; $all = count($my_products); if ($all < 4) { foreach ($my_products as $product) {
function the_page_groups($split, $split_last) { global $page_groups; get_page_group_machines(); // for each $page_machine in array, display name $count = 1; $length = count($page_groups); foreach ($page_groups as $groups) { if ($count == 1) { echo $groups; $count = $count + 1; } elseif ($count == $length) { echo $split_last; echo $groups; } else { echo $split; echo $groups; $count = $count + 1; } } }