Neler yeni

Hoşgeldin Ziyaretçi

Kayıt olarak forumumuzdan dosya indirebilir,bilgi sahibi olabilir,daha iyi bir şekilde yararlanabilirsin.

Şimdi kayıt ol

yazılara olabildigince kod koymaa WordPress Sitesinde Hangi Sayfalar Olmalı?

wpforum

Member
Yönetici
153
22 Ocak 2025
İşte profesyonel bir WordPress sitesinde mutlaka bulunması gereken sayfalar ve bunların nasıl oluşturulacağına dair kod örnekleri:
📌 1. Ana Sayfa (Homepage)
  • Önemli: Statik bir sayfa olarak ayarlayın (genellikle en güncel içerikler veya ürünler burada gösterilir).
  • Kod Örneği (Özel Şablon):
    php

    Copy

    Download
    /* Template Name: Özel Ana Sayfa */
    get_header();
    echo '<div class="hero-section">Öne Çıkan İçerik</div>';
    dynamic_sidebar('homepage-widgets');
    get_footer();
📌 2. Hakkımızda (About Us)
  • İçermeli: Şirket vizyonu, misyonu, ekibin tanıtımı.
  • Kod Örneği (Takım Üyeleri için Özel Loop):
    php

    Copy

    Download
    $team_args = array(
    'post_type' => 'team',
    'posts_per_page' => 4
    );
    $team_query = new WP_Query($team_args);
    while ($team_query->have_posts()) : $team_query->the_post();
    echo '<div class="team-member">' . get_the_post_thumbnail() . '<h3>' . get_the_title() . '</h3></div>';
    endwhile;
    wp_reset_postdata();
📌 3. İletişim Sayfası
  • Zorunlu Bölümler: Form, harita, adres bilgileri.
  • Contact Form 7 Kısa Kodu:
    html

    Copy

    Download


    Run
    [contact-form-7 id="123" title="İletişim Formu"]
  • Google Maps Entegrasyonu (API ile):
    html

    Copy

    Download


    Run
    <div id="map" style="height:400px;"></div>
    <script>
    function initMap() {
    var location = {lat: 41.0082, lng: 28.9784};
    var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 15,
    center: location
    });
    var marker = new google.maps.Marker({position: location, map: map});
    }
    </script>
    <script async defer src="https://maps.googleapis.com/maps/api/js?key=API_KEY&callback=initMap"></script>
📌 4. Blog Sayfası
  • Önemli: Kategoriler, etiket bulutu, arama çubuğu.
  • Özel Sorgu (Son 5 Yazı):
    php

    Copy

    Download
    $recent_posts = wp_get_recent_posts(array(
    'numberposts' => 5,
    'post_status' => 'publish'
    ));
    foreach($recent_posts as $post) {
    echo '<a href="' . get_permalink($post['ID']) . '">' . $post['post_title'] . '</a>';
    }
📌 5. Ürün/Hizmet Sayfaları (WooCommerce için)
  • WC Kısa Kodları:
    html

    Copy

    Download


    Run
    [products limit="4" columns="4" category="elektronik"]
  • Özel Ürün Sorgusu:
    php

    Copy

    Download
    $args = array(
    'post_type' => 'product',
    'tax_query' => array(
    array(
    'taxonomy' => 'product_cat',
    'field' => 'slug',
    'terms' => 'indirim'
    )
    )
    );
    $query = new WP_Query($args);
📌 6. SSS (Frequently Asked Questions)
  • Özel Post Type Kodu (functions.php):
    php

    Copy

    Download
    function create_faq_post_type() {
    register_post_type('faq',
    array(
    'labels' => array('name' => __('SSS')),
    'public' => true,
    'has_archive' => true,
    )
    );
    }
    add_action('init', 'create_faq_post_type');
📌 7. Gizlilik Politikası (GDPR Uyumlu)
  • Otomatik Sayfa Oluşturma Kodu:
    php

    Copy

    Download
    if (!get_page_by_title('Gizlilik Politikası')) {
    wp_insert_post(array(
    'post_title' => 'Gizlilik Politikası',
    'post_content' => 'Buraya içerik gelecek...',
    'post_status' => 'publish',
    'post_type' => 'page'
    ));
    }
📌 8. 404 Sayfası (Özelleştirilmiş)
  • 404.php Dosyası Örneği:
    php

    Copy

    Download
    get_header();
    echo '<h1>Sayfa Bulunamadı!</h1>';
    echo '<p>Aradığınız içerik kaldırılmış olabilir.</p>';
    get_search_form(); // Arama kutusu göster
    get_footer();
📌 9. Üyelik Sistemi Sayfaları
  • Giriş/Kayıt Form Kodu:
    php

    Copy

    Download
    if (!is_user_logged_in()) {
    wp_login_form(array('redirect' => home_url()));
    wp_register('', ''); // Kayıt bağlantısı
    }
📌 10. Site Haritası (HTML)
  • Tüm Sayfaları Listeleme:
    php

    Copy

    Download
    $pages = get_pages();
    echo '<ul class="sitemap">';
    foreach ($pages as $page) {
    echo '<li><a href="' . get_page_link($page->ID) . '">' . $page->post_title . '</a></li>';
    }
    echo '</ul>';
🛠 Bonus: Sayfa Kontrol Kodu
Tüm gerekli sayfaların kurulu olup olmadığını kontrol eden fonksiyon:
php

Copy

Download
function check_required_pages() {
$required_pages = array('Anasayfa', 'Hakkımızda', 'İletişim');
foreach ($required_pages as $page_title) {
if (!get_page_by_title($page_title)) {
wp_insert_post(array(
'post_title' => $page_title,
'post_status' => 'publish',
'post_type' => 'page'
));
}
}
}
add_action('admin_init', 'check_required_pages');
🔍 Özet: Temel Sayfa Yapısı
Sayfa TürüEklenti GereksinimiSEO Önemi
Ana SayfaHayır★★★★★
Blog/İçerikHayır★★★★★
Ürün/HizmetWooCommerce★★★★★
SSSCustom Post Type★★★☆☆
Gizlilik PolitikasıHayır★★★★☆
Pro Tip: Tüm bu sayfaları oluşturduktan sonra sitemap.xml oluşturmayı unutmayın (Yoast SEO veya Rank Math otomatik yapar).
Kodları functions.php veya özel tema dosyalarına ekleyerek tam kontrol sağlayabilirsiniz! 🚀
 
Üst