Skip to content

Instantly share code, notes, and snippets.

@yeriepiscesa
Last active January 18, 2024 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yeriepiscesa/2a59ea2d0aa01b71461555ca58bf3ebd to your computer and use it in GitHub Desktop.
Save yeriepiscesa/2a59ea2d0aa01b71461555ca58bf3ebd to your computer and use it in GitHub Desktop.
API Wilayah Indonesia WordPress
<!-- Contoh Penggunaan pada contact form 7 (tab Formulir) -->
<label> Nama Anda
[text* your-name autocomplete:name] </label>
<!-- class "fieldgroup--wilayah" digunakan untuk mengelompokan pemilihan provinsi sampai kelurahan -->
<div class="fieldgroup--wilayah">
<!-- untuk mengakses data provinsi, tambahkan class "field--wilayah-provinsi" -->
<!-- class "field--wilayah-provinsi-title" agar ketika provinsi dipilih, informasi nama provinsi diset ke field dengan class -title -->
<label>Provinsi
[select provinsi class:field--wilayah-provinsi]
</label>[hidden provinsi-title class:field--wilayah-provinsi-title]
<label>Kabupten / Kota
[select kabkota class:field--wilayah-kabkota]
</label>[hidden kabkota-title class:field--wilayah-kabkota-title]
<label>Kecamatan
[select kecamatan class:field--wilayah-kecamatan]
</label>[hidden kecamatan-title class:field--wilayah-kecamatan-title]
<label>Kelurahan
[select kelurahan class:field--wilayah-kelurahan]
</label>[hidden kelurahan-title class:field--wilayah-kelurahan-title]
</div>
<h4>Tujuan</h4>
<div class="fieldgroup--wilayah">
<label>Provinsi
[select dest_provinsi class:field--wilayah-provinsi]
</label>[hidden dest_provinsi-title class:field--wilayah-provinsi-title]
<label>Kabupten / Kota
[select dest_kabkota class:field--wilayah-kabkota]
</label>[hidden dest_kabkota-title class:field--wilayah-kabkota-title]
<label>Kecamatan
[select dest_kecamatan class:field--wilayah-kecamatan]
</label>[hidden dest_kecamatan-title class:field--wilayah-kecamatan-title]
<label>Kelurahan
[select dest_kelurahan class:field--wilayah-kelurahan]
</label>[hidden dest_kelurahan-title class:field--wilayah-kelurahan-title]
</div>
<label> E-mail anda
[email* your-email autocomplete:email] </label>
<label> Subjek
[text* your-subject] </label>
<label> Pesan Anda (opsional)
[textarea your-message] </label>
[submit "Kirim"]
<!-- Contoh Penggunaan pada contact form 7 (tab Surat/Mail, bagian Isi Pesan) -->
Dari: [your-name] [your-email]
Subjek: [your-subject]
Lokasi :
[provinsi] - [provinsi-title]
[kabkota] - [kabkota-title]
[kecamatan] - [kecamatan-title]
[kelurahan] - [kelurahan-title]
Tujuan :
[dest_provinsi] - [dest_provinsi-title]
[dest_kabkota] - [dest_kabkota-title]
[dest_kecamatan] - [dest_kecamatan-title]
[dest_kelurahan] - [dest_kelurahan-title]
Isi Pesan:
[your-message]
GET https://your-domain.com/wp-json/wilayah/v1/provinsi
GET https://your-domain.com/wp-json/wilayah/v1/kabkota/<id_propinsi>
GET https://your-domain.com/wp-json/wilayah/v1/kecamatan/<id_kabkota>
GET https://your-domain.com/wp-json/wilayah/v1/kelurahan/<id_kecamatan>
# Pagination
GET https://your-domain.com/wp-json/wilayah/v1/provinsi?per_page=10&page=1
GET https://your-domain.com/wp-json/wilayah/v1/kabkota/<id_propinsi>?per_page=10&page=1
GET https://your-domain.com/wp-json/wilayah/v1/kecamatan/<id_kabkota>?per_page=10&page=1
GET https://your-domain.com/wp-json/wilayah/v1/kelurahan/<id_kecamatan>?per_page=10&page=1
# Search
GET https://your-domain.com/wp-json/wilayah/v1/provinsi?term=whatToSearch
GET https://your-domain.com/wp-json/wilayah/v1/kabkota/<id_propinsi>?term=whatToSearch
GET https://your-domain.com/wp-json/wilayah/v1/kecamatan/<id_kabkota>?term=whatToSearch
GET https://your-domain.com/wp-json/wilayah/v1/kelurahan/<id_kecamatan>?term=whatToSearch
@yeriepiscesa
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment