我为我的WordPress网站http://arun.dealsinall.com/find-code制作了一个列出自定义页面的目录,当我们自动选择州/城市/城镇网址更新时,请告诉我如何将这些所有网址添加到网站地图,
e.g。 http://arun.dealsinall.com/find-code/haryana
http://arun.dealsinall.com/find-code/haryana/kernal
表示每个网址都会自动添加到网站地图。
答案 0 :(得分:0)
$current_state_slug = get_query_var('state'); //get state
$current_city_slug = get_query_var('city'); //get city
$current_town_slug = get_query_var('town'); //get town
$get_states = $wpdb->get_results("select * from state");
if(empty($current_state_slug)){
echo '<select id="selectbox">';
echo '<option>Select State</option>';
foreach($get_states as $states){
echo '<option value="'.$states->state_name.'">'.$states->state_name.'</option>';
}
echo "</select>";
}
else{
$chk_state = $wpdb->get_results("select * from state where state_name='$current_state_slug'");
if(empty($chk_state)){
echo '<br><span style="color:red;">sorry No data found for <span style="color:black">'.$current_state_slug.'</span></span><br/>';
echo '<select id="selectbox">';
echo '<option>Select State</option>';
foreach($get_states as $states){
echo '<option value="'.$states->state_name.'">'.$states->state_name.'</option>';
}
echo "</select>";
}
else{
echo '<a href="'. home_url().'/find-code"><i class="fa fa-refresh" aria-hidden="true"></i></a> : ';
echo '<select id="selectbox">';
foreach( $chk_state as $vfy_state){
echo '<option value="'.$vfy_state->state_name.'">'.$vfy_state->state_name.'</option>';
}
echo '</select><br>';
if(empty($current_city_slug)){
$city = $ak->get_current_state_city($vfy_state->state_id);
echo '<select id="selectbox_city"><option>Select City</option>';
foreach ($city as $city_list ){
echo '<option value="'.$city_list->city_name.'">'.$city_list->city_name.'</option>';
}
echo '</select><br>';
}}
}
我在页面中使用rewrite_rules并使用get_query_var获取var并使用java脚本代码将下拉值添加到url,您可以在网站http://arun.dealsinall.com/find-code上看到功能,
所以告诉我当我选择第一个下拉值命名状态,状态值添加到url,并且我想将此url添加到sitemap以用于seo目的,并且在每个下拉列表选择之后,每个url都必须添加到sitemap中。