function spotlight_post($blogID = 1, $args = array()) { min_switch_to_blog($blogID); $id = get_the_ID(); exclude_this_post($blogID, $id); $defaults = array('center' => false); // merge arguments with defaults && set keys as variables $args = array_merge($defaults, $args); foreach ($args as $key => $val) { ${$key} = $val; } $new_title = get_post_meta($id, 'db_featured_title', true); $subtitle = get_post_meta($id, 'db_subtitle', true); $title = get_the_title(); if (!empty($new_title)) { $title = $new_title; } $w = 450; $h = 450; $styles = ''; if ($center) { $styles = ' main-spotlight'; $w = 800; $h = 800; } $external = ''; if ($blogID > 1) { $external = 'external-link'; } ?> <article class="spotlight-post<?php echo $styles; ?> "> <a href="<?php the_permalink(); ?> "> <div class="featured-image" data-src="<?php echo get_thumb_url($w, $h); ?> "><?php /*<div class="spotlight-bg"></div><?php */ ?> </div> </a> <div class="caption"> <?php if ($blogID > 1) { ?> <h4>via <?php echo blog_svg($blogID); ?> </h4> <?php } ?> <h1 class="<?php echo $external; ?> "><?php echo $title; ?> </h1> <?php if (isset($subtitle) && $center == 1) { ?> <h2><?php echo $subtitle; ?> </h2> <?php } ?> </div> </article> <?php }
function get_artist_fields($id, $oldBlogID = 1) { $blogID = get_blog_by_name('artists'); min_switch_to_blog($blogID); // create array to return $artist_vars = array(); $artist = get_post($id); $artist_vars['thumb_url'] = wp_get_attachment_image_src(get_post_thumbnail_id($id), array(300, 300))[0]; $post_meta = get_post_custom($id); // assign all columns to variable $artist_columns = artist_columns(); // in case value isn't set in database, set required variables to '' foreach ($artist_columns as $column) { $artist_vars[$column] = ''; } // assign all fields foreach ($post_meta as $key => $meta) { if (array_key_exists($key, array_flip($artist_columns))) { // if we want this key if (isset($key) && !empty($key)) { $artist_vars[$key] = trim($meta[0]); } else { $artist_vars[$key] = ''; } } } min_switch_to_blog($oldBlogID); return $artist_vars; }