* * A best practice is to set up your variables at the top of this file, and then * use them sparingly - WITH ESCAPING - in the markup * */ // Fetch the post ID for the currently set up post - we're in the loop $post_id = get_the_ID(); // Some custom fields $location = get_post_meta(absint($post_id), 'location', true); $department = get_post_meta(absint($post_id), 'department', true); $programlink = get_post_meta(absint($post_id), 'programlink', true); $applylink = get_post_meta(absint($post_id), 'applylink', true); // How to get the post thumbnail $post_thumbnail = wp_get_attachment_url(get_post_thumbnail_id(absint($post_id))); // Replacement for [plain_tags_slug] $plain_tags_slug = \UBC\Helpers::get_plain_tags(absint($post_id), 'slug', ' '); // Replacement for [plain_term_slug] $plain_term_slug = \UBC\Helpers::get_plain_terms(absint($post_id), 'slug', ' '); // Replacement for [odd-even] but *really* this should be done in CSS. global $usage_id; $usage_id++; $odd_even = 0 === $usage_id % 2 ? 'even' : 'odd'; ?> <div id="<?php echo absint($post_id); ?> " class="<?php echo esc_attr($plain_tags_slug); ?> ">
$permalink = get_permalink(absint($post_id)); // Some custom fields $coursecodeundergrad = get_post_meta($post_id, 'CourseCodeUndergrad', true); $coursecodegrad = get_post_meta($post_id, 'CourseCodeGrad', true); $vanityurl = get_post_meta($post_id, 'VanityUrl', true); $credit = get_post_meta($post_id, 'Credit', true); $promophoto = get_post_meta($post_id, 'PromoPhoto', true); $subtitle = get_post_meta($post_id, 'Subtitle', true); $dates = get_post_meta($post_id, 'Dates', true); $location = get_post_meta($post_id, 'Location', true); $deliverymode = get_post_meta($post_id, 'DeliveryMode', true); $programtype = get_post_meta($post_id, 'ProgramType', true); // How to get the post thumbnail $post_thumbnail = wp_get_attachment_url(get_post_thumbnail_id($post_id)); // Replacement for [plain_tags_slug] $plain_tags_slug = \UBC\Helpers::get_plain_tags($post_id, 'slug', ' '); // Replacement for [plain_term_slug] $plain_term_slug = \UBC\Helpers::get_plain_terms($post_id, 'slug', ' '); // Replacement for [odd-even] but *really* this should be done in CSS. global $usage_id; $usage_id++; $odd_even = 0 === $usage_id % 2 ? 'even' : 'odd'; //change the icon based on the delivery mode $icon = ""; switch ($deliverymode) { case "Face-to-Face": $icon = 'icon-group'; break; case "Online": $icon = 'icon-laptop'; break;