{"id":391,"date":"2026-07-20T13:28:51","date_gmt":"2026-07-20T13:28:51","guid":{"rendered":"https:\/\/tools.dwiyanti.com\/blog\/?p=391"},"modified":"2026-07-20T13:28:52","modified_gmt":"2026-07-20T13:28:52","slug":"pemalang-code","status":"publish","type":"post","link":"https:\/\/tools.dwiyanti.com\/blog\/pemalang-code","title":{"rendered":"Pemalang Code"},"content":{"rendered":"<pre style=\"white-space:pre-wrap;\">\nfunction properti_meta_boxes() {\n    add_meta_box(\n        'properti_details',\n        'Detail Properti',\n        'properti_meta_box_callback',\n        'page',\n        'normal',\n        'high'\n    );\n}\nadd_action('add_meta_boxes', 'properti_meta_boxes');\n\nfunction properti_meta_box_callback($post) {\n    wp_nonce_field('properti_meta_box', 'properti_meta_box_nonce');\n\n    $harga = get_post_meta($post->ID, 'harga_properti', true);\n    $luas_tanah = get_post_meta($post->ID, 'luas_tanah', true);\n    $luas_bangunan = get_post_meta($post->ID, 'luas_bangunan', true);\n    $kamar_tidur = get_post_meta($post->ID, 'kamar_tidur', true);\n    $kamar_mandi = get_post_meta($post->ID, 'kamar_mandi', true);\n    $sertifikat = get_post_meta($post->ID, 'sertifikat', true);\n    $listrik = get_post_meta($post->ID, 'listrik', true);\n    $sumber_air = get_post_meta($post->ID, 'sumber_air', true);\n    $alamat_lengkap = get_post_meta($post->ID, 'alamat_lengkap', true);\n    $koordinat_maps = get_post_meta($post->ID, 'koordinat_maps', true);\n    ?>\n\n    <style>\n        .properti-field-group {\n            margin-bottom: 20px;\n            padding: 15px;\n            background: #f9f9f9;\n            border-radius: 5px;\n        }\n        .properti-field-group label {\n            display: block;\n            font-weight: 600;\n            margin-bottom: 8px;\n            color: #333;\n        }\n        .properti-field-group input,\n        .properti-field-group select,\n        .properti-field-group textarea {\n            width: 100%;\n            padding: 8px 12px;\n            border: 1px solid #ddd;\n            border-radius: 4px;\n            font-size: 14px;\n        }\n        .properti-field-group small {\n            display: block;\n            margin-top: 5px;\n            color: #666;\n            font-style: italic;\n        }\n        .properti-row {\n            display: grid;\n            grid-template-columns: 1fr 1fr;\n            gap: 20px;\n        }\n        .properti-section-title {\n            font-size: 16px;\n            font-weight: 700;\n            margin: 25px 0 15px;\n            padding-bottom: 10px;\n            border-bottom: 2px solid #0073aa;\n            color: #0073aa;\n        }\n    <\/style>\n\n    <div class=\"properti-meta-container\">\n\n        <h3 class=\"properti-section-title\">\ud83d\udcb0 Harga & Ukuran<\/h3>\n        <div class=\"properti-row\">\n            <div class=\"properti-field-group\">\n                <label for=\"harga_properti\">Harga (Rp)<\/label>\n                <input type=\"number\" id=\"harga_properti\" name=\"harga_properti\" value=\"<?php echo esc_attr($harga); ?>\" placeholder=\"500000000\">\n                <small>Contoh: 500000000 (tanpa titik atau koma)<\/small>\n            <\/div>\n\n            <div class=\"properti-field-group\">\n                <label for=\"luas_tanah\">Luas Tanah (m\u00b2)<\/label>\n                <input type=\"number\" id=\"luas_tanah\" name=\"luas_tanah\" value=\"<?php echo esc_attr($luas_tanah); ?>\" placeholder=\"318\">\n            <\/div>\n        <\/div>\n\n        <div class=\"properti-row\">\n            <div class=\"properti-field-group\">\n                <label for=\"luas_bangunan\">Luas Bangunan (m\u00b2)<\/label>\n                <input type=\"number\" id=\"luas_bangunan\" name=\"luas_bangunan\" value=\"<?php echo esc_attr($luas_bangunan); ?>\" placeholder=\"150\">\n            <\/div>\n\n            <div class=\"properti-field-group\">\n                <label for=\"sertifikat\">Sertifikat<\/label>\n                <select id=\"sertifikat\" name=\"sertifikat\">\n                    <option value=\"\">-- Pilih --<\/option>\n                    <option value=\"SHM\" <?php selected($sertifikat, 'SHM'); ?>>SHM (Sertifikat Hak Milik)<\/option>\n                    <option value=\"SHGB\" <?php selected($sertifikat, 'SHGB'); ?>>SHGB (Hak Guna Bangunan)<\/option>\n                    <option value=\"AJB\" <?php selected($sertifikat, 'AJB'); ?>>AJB (Akta Jual Beli)<\/option>\n                    <option value=\"Girik\" <?php selected($sertifikat, 'Girik'); ?>>Girik<\/option>\n                <\/select>\n            <\/div>\n        <\/div>\n\n        <h3 class=\"properti-section-title\">\ud83c\udfe0 Detail Ruangan<\/h3>\n        <div class=\"properti-row\">\n            <div class=\"properti-field-group\">\n                <label for=\"kamar_tidur\">Jumlah Kamar Tidur<\/label>\n                <input type=\"number\" id=\"kamar_tidur\" name=\"kamar_tidur\" value=\"<?php echo esc_attr($kamar_tidur); ?>\" placeholder=\"3\" min=\"1\">\n            <\/div>\n\n            <div class=\"properti-field-group\">\n                <label for=\"kamar_mandi\">Jumlah Kamar Mandi<\/label>\n                <input type=\"number\" id=\"kamar_mandi\" name=\"kamar_mandi\" value=\"<?php echo esc_attr($kamar_mandi); ?>\" placeholder=\"2\" min=\"1\">\n            <\/div>\n        <\/div>\n\n        <h3 class=\"properti-section-title\">\u26a1 Fasilitas<\/h3>\n        <div class=\"properti-row\">\n            <div class=\"properti-field-group\">\n                <label for=\"listrik\">Daya Listrik (Watt)<\/label>\n                <select id=\"listrik\" name=\"listrik\">\n                    <option value=\"\">-- Pilih --<\/option>\n                    <option value=\"900\" <?php selected($listrik, '900'); ?>>900 Watt<\/option>\n                    <option value=\"1300\" <?php selected($listrik, '1300'); ?>>1300 Watt<\/option>\n                    <option value=\"2200\" <?php selected($listrik, '2200'); ?>>2200 Watt<\/option>\n                    <option value=\"3500\" <?php selected($listrik, '3500'); ?>>3500 Watt<\/option>\n                    <option value=\"5500\" <?php selected($listrik, '5500'); ?>>5500 Watt<\/option>\n                <\/select>\n            <\/div>\n\n            <div class=\"properti-field-group\">\n                <label for=\"sumber_air\">Sumber Air<\/label>\n                <select id=\"sumber_air\" name=\"sumber_air\">\n                    <option value=\"\">-- Pilih --<\/option>\n                    <option value=\"PDAM\" <?php selected($sumber_air, 'PDAM'); ?>>PDAM<\/option>\n                    <option value=\"Sumur Bor\" <?php selected($sumber_air, 'Sumur Bor'); ?>>Sumur Bor<\/option>\n                    <option value=\"Sumur Gali\" <?php selected($sumber_air, 'Sumur Gali'); ?>>Sumur Gali<\/option>\n                <\/select>\n            <\/div>\n        <\/div>\n\n        <h3 class=\"properti-section-title\">\ud83d\udccd Lokasi<\/h3>\n        <div class=\"properti-field-group\">\n            <label for=\"alamat_lengkap\">Alamat Lengkap<\/label>\n            <textarea id=\"alamat_lengkap\" name=\"alamat_lengkap\" rows=\"3\" placeholder=\"Contoh: Jl. Raya Pemalang No. 123, Kec. Pemalang, Kab. Pemalang, Jawa Tengah\"><?php echo esc_textarea($alamat_lengkap); ?><\/textarea>\n        <\/div>\n\n        <div class=\"properti-field-group\">\n            <label for=\"koordinat_maps\">Google Maps Embed URL<\/label>\n            <textarea id=\"koordinat_maps\" name=\"koordinat_maps\" rows=\"3\" placeholder=\"Paste embed URL dari Google Maps (Share > Embed a map)\"><?php echo esc_textarea($koordinat_maps); ?><\/textarea>\n            <small>\n                \ud83d\udccc Cara mendapatkan:\n                <br>1. Buka Google Maps\n                <br>2. Cari lokasi properti\n                <br>3. Klik \"Share\" \u2192 \"Embed a map\"\n                <br>4. Copy URL yang ada di dalam src=\"...\" (contoh: https:\/\/www.google.com\/maps\/embed?pb=...)\n            <\/small>\n        <\/div>\n\n    <\/div>\n    <?php\n}\n\nfunction save_properti_meta_box($post_id) {\n    if (!isset($_POST['properti_meta_box_nonce'])) {\n        return;\n    }\n\n    if (!wp_verify_nonce($_POST['properti_meta_box_nonce'], 'properti_meta_box')) {\n        return;\n    }\n\n    if (defined('DOING_AUTOSAVE') &#038;&#038; DOING_AUTOSAVE) {\n        return;\n    }\n\n    if (!current_user_can('edit_post', $post_id)) {\n        return;\n    }\n\n    $fields = array(\n        'harga_properti',\n        'luas_tanah',\n        'luas_bangunan',\n        'kamar_tidur',\n        'kamar_mandi',\n        'sertifikat',\n        'listrik',\n        'sumber_air',\n        'alamat_lengkap',\n        'koordinat_maps'\n    );\n\n    foreach ($fields as $field) {\n        if (isset($_POST[$field])) {\n            update_post_meta($post_id, $field, sanitize_text_field($_POST[$field]));\n        }\n    }\n}\nadd_action('save_post', 'save_properti_meta_box');\n\n\/\/ SCHEMA MARKUP UNTUK PROPERTI Rumah Comal\nfunction add_property_schema() {\n    if (!is_page()) return;\n\n    $template = get_page_template_slug();\n\n    \/\/ Hanya untuk halaman dengan template properti detail\n    if ($template !== 'page-property-detail.php') return;\n\n    global $post;\n\n    $harga = get_post_meta($post->ID, 'harga_properti', true);\n    $luas_tanah = get_post_meta($post->ID, 'luas_tanah', true);\n    $luas_bangunan = get_post_meta($post->ID, 'luas_bangunan', true);\n    $kamar_tidur = get_post_meta($post->ID, 'kamar_tidur', true);\n    $kamar_mandi = get_post_meta($post->ID, 'kamar_mandi', true);\n    $alamat = get_post_meta($post->ID, 'alamat_lengkap', true);\n\n    $image = has_post_thumbnail() ? get_the_post_thumbnail_url($post->ID, 'full') : '';\n\n    $schema = array(\n        '@context' => 'https:\/\/schema.org',\n        '@type' => 'SingleFamilyResidence',\n        'name' => get_the_title(),\n        'description' => get_the_excerpt() ?: wp_trim_words(get_the_content(), 30),\n        'url' => get_permalink(),\n        'image' => $image,\n        'address' => array(\n            '@type' => 'PostalAddress',\n            'addressLocality' => 'Pemalang',\n            'addressRegion' => 'Jawa Tengah',\n            'addressCountry' => 'ID',\n            'streetAddress' => $alamat\n        )\n    );\n\n    if ($harga) {\n        $schema['offers'] = array(\n            '@type' => 'Offer',\n            'price' => $harga,\n            'priceCurrency' => 'IDR',\n            'availability' => 'https:\/\/schema.org\/InStock',\n            'url' => get_permalink()\n        );\n    }\n\n    if ($luas_tanah) {\n        $schema['floorSize'] = array(\n            '@type' => 'QuantitativeValue',\n            'value' => $luas_tanah,\n            'unitCode' => 'MTK'\n        );\n    }\n\n    if ($kamar_tidur) {\n        $schema['numberOfRooms'] = $kamar_tidur;\n    }\n\n    echo '<script type=\"application\/ld+json\">' . json_encode($schema, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . '<\/script>';\n}\nadd_action('wp_head', 'add_property_schema');\n\n\/\/ SITEMAP CUSTOM UNTUK PROPERTI\nfunction add_property_to_sitemap() {\n    if (isset($_GET['properti-sitemap']) && $_GET['properti-sitemap'] === 'xml') {\n        header('Content-Type: application\/xml; charset=utf-8');\n\n        $pages = get_pages(array(\n            'post_type' => 'page',\n            'post_status' => 'publish'\n        ));\n\n        echo '<?xml version=\"1.0\" encoding=\"UTF-8\"?>';\n        echo '<urlset xmlns=\"http:\/\/www.sitemaps.org\/schemas\/sitemap\/0.9\">';\n\n        foreach ($pages as $page) {\n            $template = get_page_template_slug($page->ID);\n\n            \/\/ Prioritas lebih tinggi untuk halaman properti\n            $priority = '0.5';\n            if ($template === 'page-pemalang.php') {\n                $priority = '0.9';\n            } elseif ($template === 'page-property-detail.php') {\n                $priority = '0.8';\n            }\n\n            echo '<url>';\n            echo '<loc>' . get_permalink($page->ID) . '<\/loc>';\n            echo '<lastmod>' . get_the_modified_date('c', $page->ID) . '<\/lastmod>';\n            echo '<changefreq>weekly<\/changefreq>';\n            echo '<priority>' . $priority . '<\/priority>';\n            echo '<\/url>';\n        }\n\n        echo '<\/urlset>';\n        exit;\n    }\n}\nadd_action('init', 'add_property_to_sitemap');\n<\/pre>","protected":false},"excerpt":{"rendered":"function properti_meta_boxes() { add_meta_box( &#8216;properti_details&#8217;, &#8216;Detail Properti&#8217;, &#8216;properti_meta_box_callback&#8217;, &#8216;page&#8217;, &#8216;normal&#8217;, &#8216;high&#8217; ); } add_action(&#8216;add_meta_boxes&#8217;, &#8216;properti_meta_boxes&#8217;); function properti_meta_box_callback($post) { wp_nonce_field(&#8216;properti_meta_box&#8217;, &#8216;properti_meta_box_nonce&#8217;); $harga = get_post_meta($post->ID, &#8216;harga_properti&#8217;, true); $luas_tanah = get_post_meta($post->ID, &#8216;luas_tanah&#8217;, true); $luas_bangunan = get_post_meta($post->ID, &#8216;luas_bangunan&#8217;, true); $kamar_tidur = get_post_meta($post->ID, &#8216;kamar_tidur&#8217;, true); $kamar_mandi = get_post_meta($post->ID, &#8216;kamar_mandi&#8217;, true); $sertifikat = get_post_meta($post->ID, &#8216;sertifikat&#8217;, true); $listrik = get_post_meta($post->ID, &#8216;listrik&#8217;, true); [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-391","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/tools.dwiyanti.com\/blog\/wp-json\/wp\/v2\/posts\/391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tools.dwiyanti.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tools.dwiyanti.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tools.dwiyanti.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tools.dwiyanti.com\/blog\/wp-json\/wp\/v2\/comments?post=391"}],"version-history":[{"count":1,"href":"https:\/\/tools.dwiyanti.com\/blog\/wp-json\/wp\/v2\/posts\/391\/revisions"}],"predecessor-version":[{"id":392,"href":"https:\/\/tools.dwiyanti.com\/blog\/wp-json\/wp\/v2\/posts\/391\/revisions\/392"}],"wp:attachment":[{"href":"https:\/\/tools.dwiyanti.com\/blog\/wp-json\/wp\/v2\/media?parent=391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tools.dwiyanti.com\/blog\/wp-json\/wp\/v2\/categories?post=391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tools.dwiyanti.com\/blog\/wp-json\/wp\/v2\/tags?post=391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}