Skip to content

Instantly share code, notes, and snippets.

@mertkahyaoglu
Created July 4, 2017 07:13
Show Gist options
  • Save mertkahyaoglu/ee26e9c23b89792655796039684937ad to your computer and use it in GitHub Desktop.
Save mertkahyaoglu/ee26e9c23b89792655796039684937ad to your computer and use it in GitHub Desktop.
<?php
// tüm postları array olarak döndürür, diğer argumentler için https://developer.wordpress.org/reference/functions/get_posts/
// listeleme sayfasında foreach ile postları listeyebilirsiniz.
function getPosts() {
$args = array(
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'DESC',
'post_type' => 'post', // default post type, detay sayfası single.php
'post_status' => 'publish'
);
return get_posts( $args );
}
$posts = getPosts();
foreach ($posts as $post) { ?>
<div class="">
</div>
<? }
get_header(); // header.php'yi include eder. php include fonksiyonu ile aynı
get_footer();
// page.php : tüm sayfaların render edildiği dosya
// aşağıdaki değişkenlerle sayfanın title ve content'ini yazdırabilirsiniz.
// $slug değişkenine bakarak sayfaya özel işlem yapabilirsiniz. Mesela iletişim sayfasında form göstermek gibi
global $post;
$slug = $post->post_name;
$title = $post->post_title;
$content = apply_filters('the_content', $post->post_content);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment