您好我有一個地理定位功能,用於基於WordPress的城市,我想使用基於Web訪問者的位置顯示位置相關的帖子。如果插件功能(geoDistanceFrom)存在,然後檢查是否有一定的標準底座(市,州)的職位如何:允許用戶爲功能選擇值
<form action="" method="POST" name="u_select_radius" id="u_select_radius">
<select>
<option value="5">5 Miles</option>
<option value="10">10 Miles</option>
<option value="20">20 Miles</option>
<option value="50">50 Miles</option>
<option value="100">100 Miles</option>
</select>
<input type="submit" value="Search" name="Search" class="blue" />
</form>
<?php //begin geoposty demo
$localCoupons = new WP_Query('post_type=post&posts_per_page=-1&orderby=meta_value&meta_key=City&order=ASC');
if ($localCoupons->have_posts()): while ($localCoupons->have_posts()): $localCoupons->the_post();
if (function_exists('geoDistanceFrom') && $city != '' && $state != '') {
///get user radius selection
if (isset($_POST['u_select_radius'])) {
$radius = intval($_POST['u_select_radius']);
} else {
$radius = 100;
}
if (geoDistanceFrom($city . ',' . $state) < $radius /* Mile radius */) {
echo '<h3>' . get_the_title() . '</h3>';
echo '<p>' . $city . ', ' . $state . '</p>';
// the_content();
}
}
endwhile; endif;
// end geoposty demo
?>
</div>
此功能檢查:
我的功能就是採用這種。如果它顯示「100」(英里半徑),我想讓用戶選擇他們想要的半徑(例如5,10,20,50,100等)
我想我需要創建一個具有預定義值(5,10,20,50等)的陣列可供選擇。我需要一些幫助。我如何讓用戶選擇此功能的值?
請讓我知道,如果有任何額外的解決方案需要。
非常感謝!
謝謝,但我想在同一頁面上處理表單(SELF)...我注意到什麼是沒有提交按鈕(我添加了),但是當我提交表單時,我需要基於域的域。出於某種原因,頁面加載但帖子無法加載。我用更多的代碼細節更新了這篇文章。有任何想法嗎? – gdinari 2011-05-06 19:52:15
我很確定,如果您將表單「操作」留空,它會自動提交。 否則請嘗試
<?php the_content(); ?>或<?php the_post(); ?>應該從我在Google中找到的內容中打印出來。這可能看起來像一個愚蠢的問題,但你確實意識到the_content();在你上面發佈的代碼中被註釋掉了...... – Sunny 2011-05-06 22:39:53