query_posts( array(
'post_type' => 'ts_result',
'meta_query' => array(
array(
'key' => '_ts_student_class',
'value' => $exam_reg,
'compare' => '='
),
array(
'key' => '_ts_school_term',
'value' => $exam_term,
),
array(
'key' => '_ts_school_year',
'value' => $exam_year,
)
),
'posts_per_page' => 100
)
);
?>
<table style="border:1px solid black" cellpadding="1.5" cellspacing="5">
<style type="text/css" media="print">
table{
border-collapse:collapse;
}
</style>
<tbody>
<tr>
<th><strong>NAME\SUBJECT</strong></th>
<th><strong>English Studies</strong></th>
<th align='center'><strong>Mathematics</strong></th>
<th align='center'><strong>CCA</strong></th>
<th align='center'><strong>Yoruba Language</strong></th>
<th align='center'><strong>French</strong></th>
<th align='center'><strong>Business Education</strong></th>
</tr>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php
$subject_english_studies_exam_total= get_post_meta(
get_the_ID(),'_ts_subject_english_studies_exam_total',true );
$subject_maths_exam_total= get_post_meta(
get_the_ID(),'_ts_subject_maths_exam_total',true );
$subject_creative_arts_exam_total= get_post_meta(
get_the_ID(),'_ts_subject_creative_arts_exam_total',true );
$subject_yoruba_lang_exam_total= get_post_meta(
get_the_ID(),'_ts_subject_yoruba_lang_exam_total',true );
$subject_french_exam_total= get_post_meta(
get_the_ID(),'_ts_subject_french_exam_total',true );
$subject_business_edu_exam_total= get_post_meta(
get_the_ID(),'_ts_subject_business_edu_exam_total',true );
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php echo $subject_english_studies_exam_total ;?></td>
<td><?php echo $subject_maths_exam_total ;?></td>
<td><?php echo $subject_creative_arts_exam_total ;?></td>
<td><?php echo $subject_yoruba_lang_exam_total ;?></td>
<td><?php echo $subject_french_exam_total ;?></td>
<td><?php echo $subject_business_edu_exam_total ;?></td>
</tr>
</tbody>
</table>
the above query in Wordpress returns the following:
What I seek to achieve is a table with one header and the other post content as rows. presently only the first post values is being formatted properly as table rows.
You have done small mistake by not closing the while loop before the </tbody>. Code will be like the following :
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<tr>
<td><?php the_title(); ?></td>
<td><?php echo $subject_english_studies_exam_total ;?></td>
<td><?php echo $subject_maths_exam_total ;?></td>
<td><?php echo $subject_creative_arts_exam_total ;?></td>
<td><?php echo $subject_yoruba_lang_exam_total ;?></td>
<td><?php echo $subject_french_exam_total ;?></td>
<td><?php echo $subject_business_edu_exam_total ;?></td>
</tr>
<?php endwhile;endif; ?>
Hope it helps you.
Related
I have created this from advanced custom fields and would like to display a restaurant menu in rows and column. The first three columns are displaying as intended but for unknown reason the last column does not display within the table. As shown on the attached image, the last column is showing above the table header and I am not sure what's wrong with the code.
[
`
<table>
<thead>
<tr>
<td class="photo">Photo</td>
<td class="menu_name">Menu Item</td>
<td class="descriptions">Descriptions</td>
<td class="price">Price</td>
</tr>
</thead>
<?php while ( have_rows( 'restaurant_menu_items' ) ) : the_row(); ?>
<tr>
<td><?php $photo = get_sub_field( 'photo' ); ?>
<?php $size = 'thumbnail'; ?>
<?php if ( $photo ) : ?>
<?php echo wp_get_attachment_image( $photo, $size ); ?>
<?php endif; ?> </td>
<td> <?php the_sub_field( 'menu_name' ); ?></td>
<td><?php the_sub_field( 'descriptions' ); ?></td>
</td><?php the_sub_field( 'price' ); ?></td>
<?php endwhile; ?>
</tr>
</table>
<?php else : ?>
<?php // no rows found ?>
<?php endif; ?>`
you have typo error on the opening tag of the last td
**</td>**<?php the_sub_field( 'price' ); ?></td>
should be < td > without /
Hope it works! :)
Also, the tr tag is opening in while loop. So it should close in the while loop. Please check below code:
<?php while ( have_rows( 'restaurant_menu_items' ) ) : the_row(); ?>
<tr>
<td><?php $photo = get_sub_field( 'photo' ); ?>
<?php $size = 'thumbnail'; ?>
<?php if ( $photo ) : ?>
<?php echo wp_get_attachment_image( $photo, $size ); ?>
<?php endif; ?> </td>
<td> <?php the_sub_field( 'menu_name' ); ?></td>
<td><?php the_sub_field( 'descriptions' ); ?></td>
<td><?php the_sub_field( 'price' ); ?></td>
</tr>
<?php endwhile; ?>
I’m trying to add a custom product meta to my woocommerce new order notification e-mails.
The custom product meta field is as follows:
woocommerce_wp_text_input(
array(
'id' => '_text_field',
'label' => __( 'OUDE DBV Artikelnummer', 'woocommerce' ),
'placeholder' => 'LET OP! Dit is het OUDE artikelnummer',
'desc_tip' => 'true',
'description' => __( 'LET OP! Dit is het OUDE Dordtse Bazar Verhuur artikelnummer.', 'woocommerce' )
)
);
I’ve copied the email-orders-details.php to my Child theme folder and the new column is showing perfectly fine in the email.
<tr>
<th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
<th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'DBV Art. Nr.', 'woocommerce' ); ?></th>
<th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>
<th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>
</tr>
Now I’m struggling to retrieve the values of this custom field. I’ve copied the email-order-items.php to my child theme folder. I’ve added this code here, but no values are shown in the email. What am I doing wrong here?
// allow other plugins to add additional product information here.
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
?>
</td>
<td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;">
<?php echo get_post_meta( $post->ID, '_text_field', true ); ?>
</td>
Hope you can help me out on this.
You need to pass $product->get_id().
// allow other plugins to add additional product information here.
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
?>
</td>
<td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;">
<?php echo get_post_meta( $product->get_id(), '_text_field', true ); ?>
</td>
This is my review-order.php table for woocommerce checkout
I cant seem to figure out why the last section with subtotal/shipping/total Displays Twice
I assume it must be something wrong with the code in second table?
Can i also add a column to first table to display product thumbnail? I have a snippet in my functions.php to add thumbnail here but i would prefer it was in a column of its own to the left of all the product info
<?php
defined( 'ABSPATH' ) || exit;
?>
<table class="shop_table woocommerce-checkout-review-order-table">
<tbody>
<?php
do_action( 'woocommerce_review_order_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
?>
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
<td class="product-name">
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<br>
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php
}
}
do_action( 'woocommerce_review_order_after_cart_contents' );
?>
</tbody>
</table>
<table>
<tfoot>
<tr class="cart-subtotal">
<th><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
<?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
<?php wc_cart_totals_shipping_html(); ?>
<?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
<?php endif; ?>
<?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
<tr class="fee">
<th><?php echo esc_html( $fee->name ); ?></th>
<td><?php wc_cart_totals_fee_html( $fee ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited ?>
<tr class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php echo esc_html( $tax->label ); ?></th>
<td><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr class="tax-total">
<th><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></th>
<td><?php wc_cart_totals_taxes_total_html(); ?></td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
<tr class="order-total">
<th><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_order_total_html(); ?></td>
</tr>
<?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
</tfoot>
</table>
Not sure if this is it but i noticed there are two table tags, one with tbody and the next with tfoot... wondering if upadting to a single table does anything:
<?php
defined( 'ABSPATH' ) || exit;
?>
<table class="shop_table woocommerce-checkout-review-order-table">
<tbody>
<?php
do_action( 'woocommerce_review_order_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
?>
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
<td class="product-name">
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<br>
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php
}
}
do_action( 'woocommerce_review_order_after_cart_contents' );
?>
</tbody>
<tfoot>
<tr class="cart-subtotal">
<th><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
<?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
<?php wc_cart_totals_shipping_html(); ?>
<?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
<?php endif; ?>
<?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
<tr class="fee">
<th><?php echo esc_html( $fee->name ); ?></th>
<td><?php wc_cart_totals_fee_html( $fee ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited ?>
<tr class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php echo esc_html( $tax->label ); ?></th>
<td><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr class="tax-total">
<th><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></th>
<td><?php wc_cart_totals_taxes_total_html(); ?></td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
<tr class="order-total">
<th><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_order_total_html(); ?></td>
</tr>
<?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
</tfoot>
</table>
My thought is there may be some js code somewhere adding the second one since there are two tables. Im still "debugging" to see if anything else jumps out at me.
On Woocommerce, I have changed $show_image variable to true in email order details php template file, but I am still unable to get the image displayed in email notifications:
<div style="margin-bottom: 40px;">
<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
<thead>
<tr>
<th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
<th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>
<th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>
</tr>
</thead>
<tbody>
<?php
echo wc_get_email_order_items( $order, array( // WPCS: XSS ok.
'show_sku' => $sent_to_admin,
'show_image' => true,
'image_size' => array( 100, 100 ),
'plain_text' => $plain_text,
'sent_to_admin' => $sent_to_admin,
) );
?>
</tbody>
<tfoot>
<?php
$totals = $order->get_order_item_totals();
if ( $totals ) {
$i = 0;
foreach ( $totals as $total ) {
$i++;
?>
<tr>
<th class="td" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['label'] ); ?></th>
<td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['value'] ); ?></td>
</tr>
<?php
}
}
if ( $order->get_customer_note() ) {
?>
<tr>
<th class="td" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Personal Message:', 'woocommerce' ); ?></th>
<td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( wptexturize( $order->get_customer_note() ) ); ?></td>
</tr>
<?php
}
?>
</tfoot>
</table>
I need to add link as well to the product image.Once the user click on the image it should redirect to the particular page.
Changed the message from false to true still the image is not displayed in the site.
To display the image in Email notifications, revert back your changes to original template and use instead:
add_filter( 'woocommerce_email_order_items_args', 'custom_email_order_items_args', 10, 1 );
function custom_email_order_items_args( $args ) {
$args['show_image'] = true;
return $args;
}
To add the product link to the image and to the item name (optionally) you will use:
add_filter( 'woocommerce_order_item_thumbnail', 'add_email_order_item_permalink', 10, 2 ); // Product image
add_filter( 'woocommerce_order_item_name', 'add_email_order_item_permalink', 10, 2 ); // Product name
function add_email_order_item_permalink( $output_html, $item, $bool = false ) {
// Only email notifications
if( is_wc_endpoint_url() )
return $output_html;
$product = $item->get_product();
return '' . $output_html . '';
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Thumbnail size change:
You can also manipulate the thumbnail size in this hook which is by default 32 x 32 pixels using under $args['show_image'] = true; adding this line:
$args['image_size'] = array( 48, 48 );
Tested and works too.
I have a plugin that I've created within my site, which just shows one page where I'm calling all users and then some specific information about those users.
Would it be possible to allow users to search for other existing users from the front end of the site?
This is the kind of thing I've got going on at the moment, I haven't been able to find any kind of search of this sort of thing, so if anyone could point me in the right direction it's be very much appreciated,
I haven't included any code as it's not that relevant really, but I can include it if needs be,
Thanks in advance!
http://focusedlearning.hcrlaw.com/courses-admin/
<?php $total_users = count_users();
$total_users = $total_users['total_users'];
$paged = get_query_var('paged');
$number = 20;?>
<?php
$args = array(
'order' => 'ASC',
'orderby' => 'display_name',
'count_total' => 'true',
'role' => 'subscriber',
'offset' => $paged ? ($paged) * $number : 0,
'number' => $number,
);?>
<?php
$blogusers = get_users($args);?>
<?php // Array of WP_User objects.
foreach ( $blogusers as $user ) {?>
<?php $userId = $user->ID;?>
<?php echo '<input type="text" value="' . esc_html( $user->display_name ) . '">';?>
<div id="content">
<h2>Completed Courses</h2>
<!-- COMPLIANCE-->
<?php
$post_args = array(
'post_type' => 'tribe_events',
'eventDisplay'=>'custom',
'start_date' => date( 'Y-m-d H:i:s', strtotime( '-365 days' ) ),
'tax_query' => array(
array(
'taxonomy' => 'tribe_events_cat',
'field' => 'slug',
'terms' => 'compliance',
),
),
'meta_query' => array(
array(
'key' => 'associated_people',
'value' => '"' . $userid . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
); ?>
<!-- MEMBERSHIP A -->
<?php if( rcp_is_active() && 2 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP A -->
<!-- MEMBERSHIP B -->
<?php if( rcp_is_active() && 3 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP B -->
<!-- MEMBERSHIP C -->
<?php if( rcp_is_active() && 4 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP C -->
<!-- MEMBERSHIP D -->
<?php if( rcp_is_active() && 5 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP D -->
<!-- MEMBERSHIP E -->
<?php if( rcp_is_active() && 6 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP E -->
<!-- END OF COMPLIANCE-->