I've been able to figure out how to include the custom field i'm referencing within an inline style within a div that wraps my header.
The problem is that it's in my header and so when a particular Post is called, to display in the body, that has the custom field of color picker and a certain color (say #567263) has been entered from the admin for that post it won't appear because it has no reference to the permalink that was clicked to get to that page.
Here in lies a new lesson for me to learn in WP. And i'm not sure if it's conditions, functions, etc.
I can call a custom post type from within my header like i did here: (this is my custom header for neighborhood pages)
<?php $args = array( 'post_type' => 'neighborhood', 'posts_per_page' => 1, ); $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( 'bg_clr' ); ?>"><!--This is where i added the_field(); i'm referencing in the question--> <header class="col-hdr-internal"> <nav role="navigation"> <?php $args = array( 'menu' => 'main-menu' ); wp_nav_menu( $args ); ?> </nav>
But it only calls on the "bg_clr" custom field of the last post i created. So i have 27 neighborhoods i've created each with a custom color for their background but the_field(); only captures the hex/color value of the last neighborhood post created.
What could be a good solution to this? I thought about adding this div into the single-neighborhood.php file but it wraps the header so that wouldn't be possible.
I could also include the header php code itself within this particular template, that could be a solution but i want to keep my header separate and push myself to learn something new so i'd rather learn another approach.
Any takers? Thanks.