0

次のスクリプトは、広告主フィールド「cp_street」、「cp_city」、および「cp_state」をコンパイルして、Webサイトのサイドバーマップを呼び出すアドレスを作成します。ユーザーが代わりに完全なアドレスを入力できる「cp_address」という新しいフィールドを作成しました。両方が機能するように、以下のスクリプトを変更するにはどうすればよいですか?

   <?php
// check to see if ad is legacy or not and then assemble the map address
if ( get_post_meta($post->ID, 'location', true) )
    $make_address = get_post_meta($post->ID, 'location', true);
else
    $make_address = get_post_meta($post->ID, 'cp_street', true) . '&nbsp;' . get_post_meta($post->ID, 'cp_city', true) . '&nbsp;' . get_post_meta($post->ID, 'cp_state', true) . '&nbsp;' . get_post_meta($post->ID, 'cp_zipcode', true);

    $coordinates = cp_get_geocode( $post->ID );
?>

<script type="text/javascript">var address = "<?php echo esc_js($make_address); ?>";</script>

    <?php cp_google_maps_js($coordinates); ?>
4

1 に答える 1

0
<?php
// check to see if ad is legacy or not and then assemble the map address
$make_address = get_post_meta($post->ID, 'cp_address', true);
if ( !$make_address || empty($make_address) )
    $make_address = get_post_meta($post->ID, 'cp_street', true) . '&nbsp;' . get_post_meta($post->ID, 'cp_city', true) . '&nbsp;' . get_post_meta($post->ID, 'cp_state', true) . '&nbsp;' . get_post_meta($post->ID, 'cp_zipcode', true);

    $coordinates = cp_get_geocode( $post->ID );
?>

<script type="text/javascript">
var address = "<?php echo esc_js($make_address); ?>";
</script>

<?php cp_google_maps_js($coordinates); ?>
于 2012-08-01T13:45:48.027 に答える