2
私は高度なカスタムフィールドを使用して状態に応じた店舗の場所のリストを追加しています。私は、その状態に属する各ストアを、その状態のdivの下に置くようにします。私はまた、ユーザーが新しい状態divを追加するためにACFを使用しています。私は店舗の場所にコードを取得するように見えることはできません。誰もこれで助けることができますか?詳細なカスタムフィールドは、正しい状態のdivの下にある店舗の場所を表示します
`` `
<?php
$args = array(
'post_type' => 'state',
'meta_key' => 'state_name',
'orderby' => 'meta_value',
'order' => 'ASC'
);
$the_query = new WP_Query($args);
?>
<?php if (have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
<div class="state-name-header">
<h2 id="<?php the_field('state_name'); ?>"><?php the_field('state_name'); ?></h2>
<?php
$state = get_field('state_name');
$state_array = $state[0];
$state_ID = $state_array->ID;
$stores = get_posts(array(
'post_type' => 'stores',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'state_name',
'value' => '"' . $state_ID . '"',
'compare' => 'LIKE'
)
)
));
?>
<?php if ($stores): ?>
<div class="locations-container">
<?php foreach($stores as $store): ?>
<?php
$store_name = get_field('store_name' , $store->ID);
$store_address = get_field('street_address' , $store->ID);
$store_city = get_field('city' , $store->ID);
$store_state_abbr = get_field('state_abbreviation' , $store->ID);
$store_zip = get_field('zip_code' , $store->ID);
$store_phone = get_field('phone' , $store->ID);
$store_url = get_field('website' , $store->ID);
?>
<div class="store-location">
<h4 class="location-name"><?php echo $store_name; ?></h4>
<p><?php echo $store_address ?></p>
<p><?php echo $store_city ?></p>
<p><?php echo $store_state_abbr ?>, <?php echo $store_zip ?></p>
<p><?php echo $store_phone ?></p>
<a href="<?php echo $store_url ?>">website</a>
</div>
<?php endforeach; ?>
</div><!-- end locations-conatiner-->
<?php endif; ?>
</div><!-- end state-name-header -->
<?php endwhile; endif; ?>
</div><!-- end state-listings-container -->```
私はあなたの問題に関しては混乱しています。クエリの結果がありません。または、データが正しく表示されていませんか? – Blake
私は全くの結果を表示していません。 –
あなたが 'var_dump($ stores);'の値は何ですか? – Blake