Tekrar merhaba ; bu yazımda ise şu andada websitemde kullanmış olduğum wordpress sisteminin bildiğiniz veya bilmediğiniz çoğu kodunu paylaşacağım. Nerelerde lazım olur diyecek olursanız , tema yapan arkadaşlarımız için ; temanızı düzenlerken vb. diğer wordpress işlemlerinizde işinize yarayabilir diye umuyorum. Siz bu kodlarla temanızı güzelleştirin ve tema yapın bizde paylaşalım değilmi ? Şimdiden herkese iyi çalışmalar.

1- Tema Url Kodu
<?php bloginfo('template_url'); ?>
2- Site Url Kodu
<?php bloginfo('siteurl');?>
3- Header.php Sayfa çağırma kodu
<?php get_header(); ?>
4- Sidebar.php Sayfa çağırma kodu
<?php get_sidebar(); ?>
5- Footer.php Sayfa çağırma kodu
<?php get_footer(); ?>
6- Herhangi bir sayfayı çağırma kodu
<?php include (TEMPLATEPATH . '/sidebar2.php'); ?>
7- Belirlediğimiz sayıda içerik Listeleme Kodu. Not: Bu kod ile sayfalama çalışmaz.
<?php query_posts('showposts=8&cat=1');?>
<?php while (have_posts()) : the_post(); ?>
Çağıralacak kod
<?php endwhile; ?>
8- İçerik linki kodu
<?php the_permalink() ?>
9- içerik başlığı kodu
<?php the_title(); ?>
10- Wp-post views eklentisi izleme sayısı kodu
<?php if(function_exists('the_views')) { the_views(); } ?>
11- İçerik kategori adı gösterme kodu
<?php the_category(', '); ?>
12- Etiket Kodu
<?php the_tags(' ', ', ', ''); ?>
13- Özel alan gösterim kodu
<?php if( get_post_meta($post->ID, "resim", true) ): ?>
<?php echo get_post_meta($post->ID, "resim", true); ?>
<?php else: ?>
<?php endif; ?>
14- Belli kelimede içerik yazısı gösterme kodu
<?php the_content_rss('', TRUE, '', 10); ?>
15- Belirlediğimiz sayıda içerikleri listeleme kodu Not: Sayfalama çalışır kullanabilirsiniz.
<?php
$my_query = new WP_Query('orderby=rand&showposts=15');
while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;
?>
Çağırılacak kod
<?php endwhile; ?>
16- Sayfalama eklentisi wp-pagenavi dahil,içerik sayısının admin paneli okuma kısmında ayarlandığı içerik listeleme kodu
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
Çağırılacak kod
<?php endwhile; ?>
<div class='sayfalama'><?php wp_pagenavi() ?></div>
<?php else : ?>
<div class="alignleft"><?php next_posts_link(__('« Older Entries')) ?></div>
<div class="alignright"><?php previous_posts_link(__('Newer Entries »')) ?></div>
<div class="clear"></div>
<?php endif; ?>
17 – single.php ve page.php içine içerik yani eklediğimiz yazının tamamını gösterme kodu
<?php
if (have_posts()) : while (have_posts()) : the_post();
$do_not_duplicate = $post->ID;
?>
içerik kodu
<?php the_content(''); ?>
<?php endwhile; else : endif; ?>
18- single.php içerik yazısının kodu 17. kodda mevcut.
<?php the_content(''); ?>
19- Yorum için comments.php çağırma kodu
<?php comments_template(); ?>
20- Kategorileri veya alt kategorileri listeleme kodu.
<li <?php if(is_home()) { echo ' class="current-cat" '; } ?>><a href="<?php bloginfo('url'); ?>">Anasayfa</a></li>
<?php wp_list_categories('depth=3&child_of=1&hide_empty=0&orderby=name&show_count=0&use_desc_for_title=1&title_li='); ?>
21- Yorumları gösterme kodu
<?php
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,30) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 10";
$comments = $wpdb->get_results($sql);
$output = $pre_HTML;
$output .= "\n<ul>";
foreach ($comments as $comment) {
$output .= "\n<li>".strip_tags($comment->comment_author) .":" . "<a href=\"" . get_permalink($comment->ID)."#comment-" . $comment->comment_ID . "\" title=\"on ".$comment->post_title . "\">" . strip_tags($comment->com_excerpt)."</a></li>";
}
$output .= "\n</ul>";
$output .= $post_HTML;
echo $output;
?>
22- İstemediğimiz kategoriyi kategoriyi göstermemek için kullandığımız içerik listeleme kodu .(cat=-416 dikkat ediniz, Bu kategori yazıları gözükmeyecek)
<?php
$wp_query = new WP_Query();
$wp_query->query('showposts=5&cat=-416&paged='.$paged);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
içerik gelicek
<?php endwhile; ?>
23- Part sistemi için içerik içinde bölümlere ayırma kodu nextpage kodunu içeriğe yazarak
<?php wp_link_pages('before=&after=
&pagelink=%.Bölüm'); ?>
24- Tarih gösterme kodu
<?php the_time('l, F jS, Y') ?>
25- Yazar İsmi kodu
<?php the_author(', '); ?>
26- Kategori adı kodu
<?php the_category(', '); ?>
27- İlgili içerik yerleştirildiğinde o içerikten önceki ve sonraki konuların linkini verir.
<?php previous_post_link('%link') ?> Önceki Link
<?php next_post_link('%link') ?> Sonraki link
28- Toplam içerik sayısı :
<?php echo $published;?>
<?php
$args=array(
‘orderby’ => ‘name’,
‘order’ => ‘ASC’
);
$categories=get_categories($args);
$cat_count = 0;
foreach($categories as $c) {
$cat_count++;
}
$count_posts = wp_count_posts();
$published = $count_posts->publish;
?>
29- Pagenavi eklentisi sayfalama kodu
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
30- header.php için title başlık kodu
<title> <?php wp_title(''); ?>
<?php if(wp_title('', false)) { echo ' :'; } ?>
<?php bloginfo('name'); ?></title>
31- İlgili içeriğin yorum sayısı kodu
<?php comments_number('0 Yorum','1 Yorum','% Yorum'); ?>
Çift tıklayarak tüm kodu seçebilirsiniz. Herkese iyi kullanımlar , sorun olursa yorum olarak belirtebilirsiniz.
indirbig Tek Tıkla İndir