I’ve gotten as far as creating custom post types, custom fields and linking those to templates on this first time WordPress project i’m working on, but i seem to have run into a problem i’m not easily able to solve (and i run into these types of problems all the time naturally:).
I have created a few different headers for different sections of my site and understand how to call on them from different templates. However i have this one header that will be used on 27 different neighborhood pages and the catch is that the background-color for each neighborhood needs to be customized.
Can this be accomplished with PHP? Or does anyone have any suggestions on how they might make this work? I realize i could go the jQuery route but i’m not sure how that would work on a site that’s already generating dynamic content and to have to figure out which neighborhood it’s on to be able to figure out which color to display.
I was thinking about actually creating 27 different header.php files but then thought that crazy when i couldn’t figure out how to tell the neighborhood page template how to call on the right header based on the neighborhood and to even contemplate having 27 page templates just to display 27 different background colors for the header sounded like crazy talk, but hey when you’re a noob those kinds of solutions start to sound pretty good when deadlines are around the corner.
Thanks.
UPDATED CODE 9/24/2013
<!--Updated Code 9/24-->
$args = array(
'post_type' => 'single_neighborhood'
);
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="container-hdr-neighborhood" style="background-color:<?php the_field( 'background_color' ); ?> ;">
<?php endwhile; else: ?>
<?php endif; ?>