简体   繁体   中英

how to add custom url to sitemap in wordpress

I made a directory listing custom page for my WordPress website, http://arun.dealsinall.com/find-code , when we select state/city/town url update automatically, please tell me how can I add these all url to sitemap,

eg http://arun.dealsinall.com/find-code/haryana

http://arun.dealsinall.com/find-code/haryana/kernal

Means every url automatically add to sitemap.

$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>';
            }}
        }

i'm using rewrite_rules for my page and getting var using get_query_var and use java script code for adding dropdown values to url ,you can see functionality on website http://arun.dealsinall.com/find-code ,

so tell me when i select first dropdown value named state, state value added to url, and i want to add this url to sitemap for seo purpose , and after every dropdown select , every url must me add in sitemap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM