Ejemplo n.º 1
0
/**
 * Determine the current page's theme and return the appropriate theme colour. 
 * @return string The (hash-prefixed) hexadecimal colour code. 
 */
function sb_theme_color()
{
    $theme_color = "#5832ab";
    if (is_single() && get_post_type() == "meet") {
        $meet_location = sb_meet_location(get_field("meet_location"));
        if (isset($meet_location["locality"]) && !empty($meet_location["locality"])) {
            switch (strtolower($meet_location["locality"])) {
                case "bristol":
                    $theme_color = "#f44336";
                    break;
                case "cardiff":
                    $theme_color = "#3f51b5";
                    break;
                case "weston-super-mare":
                    $theme_color = "#ffc107";
                    break;
                case "newport":
                    $theme_color = "#009688";
                    break;
            }
        }
    }
    return $theme_color;
}
<?php

if (get_post_type() == "meet") {
    $meet_location = sb_meet_location(get_field("meet_location"));
    $meet_theme = !empty($meet_location["locality"]) ? strtolower($meet_location["locality"]) : "severn";
    ?>
	<li class="search-results__item" data-theme="<?php 
    echo $meet_theme;
    ?>
">
		<a class="search-results__link" href="<?php 
    the_permalink();
    ?>
">
			<?php 
    if (has_post_thumbnail()) {
        ?>
				<img class="search-results__image" alt="" src="<?php 
        echo the_post_thumbnail_url('search-result');
        ?>
">
			<?php 
    }
    ?>
			<div class="search-results__body">
				<div class="search-results__type">
					Meet
				</div>
				<h2 class="search-results__title">
					<?php 
    echo sb_search_highlight(get_search_query(), get_the_title());