Confusing title but using the Types toolset I added the two letter state code (CA, TX, FL, etc...) to each of my 'Store' custom post type. The following query will order all my stores by state code, in desc/asc order:
$state_code = types_render_field("state-code", array()); $args = array( 'post_type' => 'store', 'posts_per_page' => 100, 'orderby' => array( 'ASC' => 'DESC', 'meta_value' => 'ASC' ), 'meta_key' => 'wpcf-state-code', );
My question: if I have 10 stores in California, is there a way that, before the first store, I print out a heading (in this case, California)? So if i have states in CA, TX, and FL, before my block of stores in CA it'll say 'Califoarnia', before my block of stores in FL it'll say 'Florida', etc...?
And if so, is there a way to add a dynamic class to each heading? Something like
<h2 class="<?php echo $state_code; ?>-state">California</h2> which would output
ca-state as the class?