Merhaba,
Kısaca açıklayacak olursak, single.php dosyanız var ve örnek olarak twenty_twelve temasını incelediğinizde: get_template_part( 'template-parts/content', get_post_format() ); şeklinde wordpress in sunduğu alıntı, link, .. yazı formatlarından hangisi seçili ise ona göre single php içinde contentinizi çekebiliyoruz. İş custom post type a geldiğinde biraz ellerimizi çalıştırmamız gerekiyor. Bu yüzden aşağıdaki kodu eklediğimizde post type 'post' değilse bizim oluşturduğumuz post_type ı kolaylıkla çağırabiliriz.
-
WordPress Custom Post Type Single Çağırma
<?php get_header(); while ( have_posts() ) : the_post(); if ( !('post' == get_post_type() ) ) { get_template_part( 'template-parts/content', get_post_type() ); } else { get_template_part( 'template-parts/content', get_post_format() ); } endwhile; // End of the loop. get_footer(); ?>
-
Bonus: Script & Style Dosyalarını Özel Olarak Dahil Etmek İçin;
if ( is_single() && 'custom_post_type' == get_post_type() ) { // }
Etiket: single.php for custom post type
Kat: Labs, WP Tricks Tarih: 12 Ağustos 2020 Okunma:34
Paylaş:
Kat: Labs, WP Tricks Tarih: 12 Ağustos 2020 Okunma:34
Paylaş:
Henüz yorum eklenmemiş.