WordPress entegre ederken sık sık kullandığım parametreleri bu sayfada toplayacağım. WordPress'e tema entegre edenlere yardımcı olması amacıyla..
Temasal Bağlamlar :
Title Parametresi :
<?php global $page, $paged; // Add the blog name. bloginfo( 'name' ); wp_title( '»', true, 'left' ); // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) echo " » $site_description"; // Add a page number if necessary: if ( $paged -->= 2 || $page >= 2 ) echo ' » ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) ); ?>
Blog Adı :
<?php bloginfo('name'); ?>
Blog Adresi :
<?php bloginfo('url'); ?>
Css Dosyası :
<?php bloginfo('stylesheet_url'); ?>
Tema Yolu :
<?php bloginfo('template_url'); ?>
Header.php Çağırma :
<?php get_header(''); ?>
Sidebar.php Çağırma :
<?php get_sidebar(''); ?>
Footer.php Çağırma :
<?php get_footer(''); ?>
Tag Bitimleri
/* </head> önce */ <?php wp_head(); ?> /* </body> bitimine */ <?php wp_footer(); ?>
Sayfa Template :
<?php /* Template Name: Sayfa İsmi */ ?>
Tema Style Yazısı :
/* Theme Name: Theme URI: Description: Author: Author URI: Version: 1.0 */
Menü Bağlamları :
Sayfaları Listeler :
<?php wp_list_pages('title_li='); ?>
Belirli Sayfaları Menüden Çıkarma :
<?php wp_list_pages('exclude=id&title_li='); ?>
Sadece girilen ID’lere sahip Sayfaları Listeler :
<?php wp_list_pages('include=id,id&title_li='); ?>
Kategorileri Listele :
<?php wp_list_cats('title_li='); ?>
Kategori Listeleme (Özel Menü) :
<?php $category_ids = get_all_category_ids(); foreach($category_ids as $cat_id) { $cat_name = get_cat_name($cat_id); $category_url = get_category_link($cat_id); echo '<a href="'.$category_url.'"><li class="list-group-item">' . $cat_name . '</li></a>'; } ?>
İçerik Bağlamları :
While Döngüsü : :
<?php while(have_posts()) : the_post(); ?> //content <?php endwhile; ?>
Kategori Sayfasında Kategori Adı :
<?php printf( __( '%s', 'solopine' ), single_cat_title( '', false ) ); ?>
Kategori Sayfasında Kategori Açıklaması :
<?php echo category_description(); ?>
Yazıya Ait Görsel (Post Thumbnail’a Class Ekleme) :
<?php echo get_the_post_thumbnail( $post_id, 'thumbnail', array('class' => 'img-responsive img-circle post-image')); ?>
Kategoriye Ait Makaleleri Listeleme :
<?php if (have_posts()) : ?> <?php $emrebasaran = new WP_Query("cat=1&showposts=10"); while($emrebasaran->have_posts()) : $emrebasaran->the_post();?> //content <?php endwhile; ?> <?php endif; ?>
Son Yazılar :
<?php query_posts('showposts=10'); ?> <?php while (have_posts()) : the_post(); ?> // content <?php endwhile;?> <?php wp_reset_query(); ?>
Yazı Başlığı :
<?php the_title(''); ?>
Yazı Adresi :
<?php the_permalink('') ?>
Yazı Kategorisi :
<?php the_category(', ') ?>
Yazı Kategorisi – HTML :
<?php foreach((get_the_category()) as $category) { echo $category->cat_name . ', '; } ?>
Yazı İçeriği :
<?php the_content(''); ?>
Yazı İçeriği Limit :
<?php echo wp_trim_words( get_the_content(), 40, '...' );?>
Yazının Yayınlanma Saati :
<?php the_time('H:i:s'); ?>
Yazıya Yorum Sayısı :
<?php comments_popup_link(__('Yorum yapılmamış'), __('1 yorum yapılmış'), __('% yorum yapılmış'), '', __('Yorumlara kapalı')); ?>
Yazı Okunma Sayısı : (WP-PostViews eklentisi gerekir) :
<?php if(function_exists('the_views')) { the_views(); } ?>
Yazı İD’si :
<?php the_ID(); ?>
Yazı Düzenlenme Linki :
<?php edit_post_link(); ?>
Yorum Şablonu :
<?php comments_template(); ?>
Yazar Bağlamları :
Yazar Adı :
<?php the_author(''); ?>
Yazar Hakkında :
<?php the_author_description(''); ?>
Yazar İsmi :
<?php the_author_firstname(''); ?>
Yazar Soyismi :
<?php the_author_lastname(''); ?>
Yazarın Makale Sayısı :
<?php the_author_posts('');?>
Yazar Sayfası Linki :
<?php the_author_link('');?>
Yazarın Web Sitesi :
<?php the_author_url(''); ?>
Yazarın E-mail adresi :
<?php the_author_email('');?>
Ekstra Bağlamlar :
Titan Framework Ekleme / Fonksiyonu :
// Titan Framework include require get_template_directory().'/titan-framework-checker.php'; require get_template_directory().'/titan-options.php'; // Titan Framework - Değer çağırma fonksiyonu add_action('after_setup_theme', 'valueBack'); function valueBack($deger) { $titan = TitanFramework::getInstance('frameworkadiuzantisi'); $value = $titan->getOption($deger); return $value; }
Özel Menü :
// Functions add_action('init', 'theme_menus'); function theme_menus() { register_nav_menus( array( 'anamenu' => __('Ana Menü'), 'sagmenu' => __('Sağ Menü') ) ); } // Menü çağırma wp_nav_menu( array( 'container_id' => 'submenu', 'theme_location' => 'anamenu','menu_class'=>'sf-menu','fallback_cb'=> 'fallbackmenu' ) );
Özel Menünün Başına veya sonuna element ekleme :
// Menü elementlerinin başına Anasayfa linkini ekle function menu_ekleme($content) { $content = '<li class="current colordefault home_class"><a href="index.html"><i class="icon-home"></i></a></li>' . $content; return $content; } add_filter('wp_nav_menu_anamenu_items', 'menu_ekleme');
ID’e özel upload edilen fotoğrafı çağırma :
function valuePhoto($photoID){ $imageSrc = $photoID; if (is_numeric($photoID)) { $imageAttachment = wp_get_attachment_image_src($photoID,'full'); $imageSrc = $imageAttachment[0]; return $imageSrc; } }
WordPress Toolbarı kaldırma (functions.php):
/* Admin Bar özelliğini iptal et */ add_filter( 'show_admin_bar', '__return_false' ); /* Admin Bar seçeneklerini kullanıcı profilinden kaldır */ remove_action( 'personal_options', '_admin_bar_preferences' );
Özel Alan Etiketini Sayfaya Çağırma :
<?php echo get_post_meta($post->ID, "ozel_alan_etiketi", true); ?>
Sonraki Yazı :
<?php next_post_link('') ?>
Öndeki Yazı :
<?php previous_post_link('') ?>
Öne Çıkarılmış Görsel Kullanımı :
/* While döngüsü içerisinde */ <?php if ( has_post_thumbnail() ) {the_post_thumbnail();} else {}?> /* funtions.php’de eklenecek */ add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 125, 125 );
Alıntı Kısmı – The Expert Kullanımı :
/* While Döngüsü içerisinde */ <?php the_excerpt(''); ?> /* functions.php’de eklenecek */ function new_excerpt_length($length) { return 12; } add_filter('excerpt_length', 'new_excerpt_length');
Arama Formu :
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>"> <input class="searchbg" type="text" name="s" id="s" onfocus="if (this.value == 'Ara ...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Ara ...';}"> <input class="button" type="button" value=""> </form>
Sayfalama – (Pagenavi Eklentisi) :
<?php wp_pagenavi(); ?>
İletişim Formu Tasarımı (Contact Form Plugin) :
/* Css ekle */ .your-name input, .your-email input, .your-subject input, .wpcf7 textarea{ outline:none; border: 1px dashed #78bcf0; width:290px; height:18px; padding:5px; -moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; -moz-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1); box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1); -webkit-transition: box-shadow 1s; -moz-transition: box-shadow 1s; -o-transition: box-shadow 1s; transition: box-shadow 1s;} .wpcf7 textarea{ width:607px; height:100px;} .wpcf7-submit{ width:100px; height:30px; cursor:pointer; background: #414e6d; -moz-border-radius: 3px; border-radius: 3px; -webkit-box-shadow: 0px 1px 2px rgba(0,0,0,0.3); -moz-box-shadow: 0px 1px 2px rgba(0,0,0,0.3); box-shadow: 0px 1px 2px rgba(0,0,0,0.3); color: #eee; font-size: 15px; padding:5px; border:none; text-align:center; margin-bottom:2px; text-shadow: 0 -1px 0 rgba(0,0,0,0.3);} .wpcf7-submit:hover{ background: #1982d1; color: #bfddf3;} .your-name input:Focus, .your-email input:Focus, .your-subject input:Focus, .wpcf7 textarea:Focus{ -moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; -moz-box-shadow:0px 0px 15px rgba(0, 0, 0, 0.2); -webkit-box-shadow:0px 0px 15px rgba(0, 0, 0, 0.2); box-shadow:0px 0px 15px rgba(0, 0, 0, 0.2); -webkit-transition: box-shadow 1s; -moz-transition: box-shadow 1s; -o-transition: box-shadow 1s; transition: box-shadow 1s;}
Üyelik Girişi Sorgulatma :
/* Üye girişini sorgula, giriş yapmışsa yazdır */ <?php global $user_identity, $user_ID; if (is_user_logged_in()) { ?> /* Eğer yoksa yazdır */ <?php } else { ?> /* ve bitir */ <?php } ?>
Üyelik Girişi Formu :
<form method="post" action="<?php echo site_url('wp-login.php') ?>"> <div class="controls"> <label>Kullanıcı Adı : <span class="text-error">*</span></label> <input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" placeholder="[email protected]"> </div> <div class="controls"> <label>Parola : <span class="text-error">*</span></label> <input type="password" name="pwd" id="pwd"> </div> <div class="controls"> <button type="submit" name="submit" value="Login" class="btn btn-primary">Giriş</button> <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"> <a class="lost-pwd" href="<?php echo site_url('wp-login.php?action=lostpassword') ?>"> <?php _e('Parolamı Unuttum') ?></a> </div> </form>
Yorum Sayfası :
/* functions.php ekle*/ <?php // Yorum Listeleme Özelliği function sinyor_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?> <?php $PostAuthor = false; if($comment--->comment_author_email == get_the_author_email()) { $PostAuthor = true;} elseif($comment->comment_author_email == '[email protected]') { $PostAuthor = true;} ?> <li <?php="" if($postauthor)="" {echo="" "class="authorcomment" ";}="" ?=""> id="li-yorum-<?php comment_ID() ?>"> <div class="text-comments"> <div id="comment-<?php comment_ID(); ?>"> <div class="comment-author vcard"> <?php echo get_avatar($comment,$size='54'); ?> <div class="comment-meta commentmetadata"> <?php printf(__('<cite class="fn"-->%s'), get_comment_author_link()) ?> diyor ki: <p> <span class="comment-date"> Bu yorum <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(get_comment_date()); ?></a> tarihinde <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(get_comment_time()); ?></a> sularında yazılmıştır. </span> </p> </div> </div> <?php if ($comment--->comment_approved == '0') : ?> <em class="comment-awaiting-moderation">Yorumunuz onaylandıktan sonra görüntülenecektir.</em> <?php endif; ?> <div class="commentbody"><?php comment_text() ?></div> <div class="reply"> <?php comment_reply_link(array_merge( $args, array('depth' =--> $depth, 'max_depth' => $args['max_depth']))) ?> </div> </div> </div> <?php } ?> /* comments.php ekle */ <?php if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Lütfen bu sayfaya doğrudan yükleme yapmayınız, teşekkürler.'); if (post_password_required()) { ?> <p class="nocomments">Bu yazı parola korumalıdır, yorumları görebilmek için parolayı girin.</p> <?php return; } ?> <!-- Düzenlemeye buradan başlayabilirsiniz. --> <?php if ( have_comments() ) : ?> <h4 id="commentss">Bu yazıya <?php comments_number('yorum yapılmamış.', '1 yorum yapılmış.', '% yorum yapılmış.' );?></h4> <ol class="commentlist"> <?php wp_list_comments('type=all&callback=sinyor_comment'); ?> </ol> <?php else : ?> <?php if ( comments_open() ) : ?> <?php else : ?> <p class="nocomments">Bu yazı yorumlara kapatılmıştır.</p> <?php endif; ?> <?php endif; ?> <?php ?> <?php global $trackbacks; ?> <?php if ($trackbacks) : ?> <?php $comments = $trackbacks; ?> <div id="pingback-trackback"> <h3 id="trackbacks">Geri bildirimler: <?php echo sizeof($trackbacks); ?></h3> <ol class="pings"> <?php foreach ($comments as $comment) : ?> <!-- Geriizleme başlangıç --> <li <?php="" echo="" $oddcomment;="" ?="">id="comment-<?php comment_ID() ?>"> <cite><?php comment_author_link() ?></cite> <?php if ($comment--->comment_approved == '0') : ?> <em>Yorumunuz denetim için bekliyor.</em> <?php endif; ?> </li> <!-- Geriizleme bitiş --> <?php $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : ''; ?> <?php endforeach; ?> </ol> </div> <?php endif; ?> <?php ?> <?php if ( comments_open() ) : ?> <div id="respond"> <h4> <?php comment_form_title( 'Yazı hakkında görüşlerinizi belirtmek istermisiniz?', 'Şuanda %s adlı kişinin yorumuna cevap yazıyorsunuz.' ); ?> <span class="cancel-comment-reply"> <small><?php cancel_comment_reply_link(); ?></small> </span> </h4> <?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?> <p>Yorum yapabilmek için <a href="<?php echo wp_login_url( get_permalink() ); ?>">giriş</a> yapmalısınız.</p> <?php else : ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> <?php if ( is_user_logged_in() ) : ?> <p id="system-login">Sisteme <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a> olarak giriş yapılmış. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Çıkış yapın">Çıkış yap »</a></p> <?php else : ?> <div id="left-comments-box"> <script type="text/javascript"> //<![CDATA[ (function() { document.write('<label for="author"> </label><br/><input type="text" name="author" id="author" value="" placeholder="İsim & Soyisim" size="22" tabindex="1"/>'); document.write('<label for="email"> </label><br/><input type="text" name="email" id="email" value="" placeholder="E-Posta" size="22" tabindex="2" />'); document.write('<label for="url"> </label><br/><input type="text" name="url" id="url" value="" placeholder="Website" size="22" tabindex="3" />'); })(); //]]> </script><label for="author"> </label><br><input type="text" name="author" id="author" value="" placeholder="İsim & Soyisim" size="22" tabindex="1"><label for="email"> </label><br><input type="text" name="email" id="email" value="" placeholder="E-Posta" size="22" tabindex="2"><label for="url"> </label><br><input type="text" name="url" id="url" value="" placeholder="Website" size="22" tabindex="3"> </div> <?php endif; ?> <script type="text/javascript"> //<![CDATA[ (function() { document.write('<p><textarea name="comment" id="comment" cols="70" rows="7" placeholder="Mesajınızı yazabilirsiniz." tabindex="4"></textarea></p>'); })(); //]]> </script><p><textarea name="comment" id="comment" cols="70" rows="7" placeholder="Mesajınızı yazabilirsiniz." tabindex="4"></textarea></p> <p><input name="submit" type="submit" id="submit" tabindex="5" value="Gönder"><?php comment_id_fields(); ?></p> <?php do_action('comment_form', $post--->ID); ?> </form> <?php endif; ?> </div> <?php endif; ?> /* Css */ #comments{float:left;display:inline-block;width:105%;} #comments li{list-style:none;} #comments h4#commentss{border:1px solid #DDDDDD;margin:2px 0px 8px 0px;box-shadow:2px 2px 0 #BBBBBB;padding:4px 7px 4px 7px;width:610px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;} .text-comments{border:1px solid #DDDDDD;margin:0px 0px 10px -1px;box-shadow:2px 2px 0 #BBBBBB;padding:4px 7px 4px 7px;max-width:97.5% !important;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;} .text-comments p{margin:0px 0px 0px 0px;} a.comment-reply-link{margin:6px 0px -5px -8px;width:45px;height:18px;border-top:1px solid #DDD;border-right:1px solid #DDD;display:inline-block;padding:2px 8px 0px 15px;font-size:smaller;float:none;-webkit-border-radius:0px 5px 0px 0px;-moz-border-radius:0px 5px 0px 0px;border-radius:0px 5px 0px 0px;} ul.children{padding:0px 0px 0px 60px !important;} h3#comments{background:#EEEEEE;border-bottom:1px solid #DDDDDD;border-top:1px solid #DDDDDD;display:inline-block;padding:5px;width:558px;} cite.fn{font-style:normal;font-size:12px;font-weight:bold;margin:5px 0px 0px 0px;display:inline-block;} .avatar{float:left;margin:3px 7px 0px 1px;border:1px solid #dddddd;padding:2px;} .commentmetadata{font-size:11px;display:inline-block;margin:0px 0px -20px 0px;} .vcard{margin:0px 0px 0px 0px;} .commentbody{margin:0px 0px -11px 0px;} ol.commentlist{padding:0;width:626px;display:inline-block;margin:2px 0px 0px 1px;} ol.commentlist p{margin:0;} span.comment-date{color:#AAAAAA;margin:-8px 0px -1px 0px;display:inline-block;} .comment-date a{color:#666666;} em.comment-awaiting-moderation{color:#666666;font-size:11px;font-weight:bold;font-style:normal;margin:12px 0px -6px 0px;display:inline-block;} .authorcomment{} textarea#comment{width:610px;height:100px;margin:0px 0px 0px 0px;padding:5px 8px 5px 8px;border:1px solid #CCC;outline:none;background:#EEE;font-family:arial;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;} input#submit{background:url("images/sidebar-h3.png");margin:-2px 0px 0px 0px;border:none;padding:6px 10px 6px 10px;color:white;cursor:pointer;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;} input#author{padding:5px 6px 5px 6px;margin:0px 0px 8px 0px;border:1px solid #CCC;outline:none;background:#EEEEEE;font-family:arial;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;} input#email{padding:5px 6px 5px 6px;margin:0px 0px 8px 0px;border:1px solid #CCC;outline:none;background:#EEEEEE;font-family:arial;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;} input#url{padding:5px 6px 5px 6px;margin:0px 0px 8px 0px;border:1px solid #CCC;outline:none;background:#EEEEEE;font-family:arial;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;} #respond h4{border:1px solid #DDDDDD;margin:0px 0px 8px 0px;box-shadow:2px 2px 0 #BBBBBB;padding:4px 7px 3px 7px;width:610px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;} #respond h4 span.cancel-comment-reply{margin:3px 0px 1px 0px;} #respond{margin:0px 0px -9px 0px;} #respond p#system-login{margin:-4px 0px -7px 1px;} </li>
Kodların içinde bazı kaynakların alıntıları mevcuttur.Verdikleri bilgiler için teşekkür ederim.