Skip to content

Instantly share code, notes, and snippets.

@akinayturan
akinayturan / etikete.php
Last active August 29, 2015 14:15
WP ~ Eklentisiz Benzer Yazıları Gösterme
<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'showposts'=>5, // Gösterilecek etikete göre benzer yazı sayısı
@akinayturan
akinayturan / functions.php
Last active August 29, 2015 14:15
WP ~ Eklentisiz Yazıdaki İlk Resmi Alma & Gösterme
<?php
// Yazıdaki ilk resmi alma ve gösterme //datarar.com
function resimgoster() {
error_reporting(0);
global $post, $posts;
$resimbir = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$resimbir = $matches [1] [0];
@akinayturan
akinayturan / functions.php
Created February 10, 2015 16:01
WP ~ Eklentisiz Yazı Okunma Sayısı & Popüler Yazıları Gösterme
<?php
//WP ~ Eklentisiz Yazı Okunma Sayısı Ve Popüler Yazıları Gösterme //epfarki.com
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 okunma";
}
@akinayturan
akinayturan / functions.php
Last active August 29, 2015 14:15
WP ~ Eklentisiz Rastgele 10 Yazı Gösterme
<?php
//WP ~ Rastgele yazı gösterme //epfarki.com
function rastgele_yazi($yazi_sayisi="10") {
global $wpdb;
$sorgu = "SELECT ID, post_title, post_status FROM $wpdb->posts where post_status='publish' ORDER BY RAND() LIMIT 0, $yazi_sayisi";
$sonuclar = $wpdb->get_results($sorgu);
foreach ($sonuclar as $sonuc) {
$cikti .= "<li><a href="" . get_permalink($sonuc->ID) . "" title="". $sonuc->post_title ."">" . $sonuc->post_title ."</a></li>";
}
echo $cikti;
@akinayturan
akinayturan / functions.php
Created February 10, 2015 16:04
WP ~ Yazı Uzunluğunu Otomatik Sınırlama
<?php
//WP ~ Yazı Uzunluğunu Sınırlama //epfarki.com
add_filter('excerpt_length', 'my_excerpt_length');
function my_excerpt_length($len) { return 60; }
?>
@akinayturan
akinayturan / functions.php
Created February 10, 2015 16:06
WP ~ Yazı Başlığı Uzunluğunu Sınırlama
<?php
//WP ~ Yazı Başlığı Uzunluğunu Sınırlama //epfarki.com
function kisa_baslik($char) {
$title = get_the_title($post->ID);
$title = substr($title,0,$char);
echo $title;
}
?>
@akinayturan
akinayturan / show.css
Created February 10, 2015 16:09
CSS ~ Kısaltmalara Açıklama Satırı Ekleme
k {cursor:help;border-bottom:1px dotted #111}
@akinayturan
akinayturan / functions.php
Created February 10, 2015 20:26
WP ~ Giriş ve Kayıt Ekranı Logosunu Değiştirme
<?php
function custom_loginlogo() {
echo '<style type="text/css">
h1 a {background-image: url(resim_adresi) !important; }
</style>';
}
add_action('login_head', 'custom_loginlogo');
?>
@akinayturan
akinayturan / functions.php
Created February 10, 2015 20:29
WP ~ Eklentilerin Gereksiz Kodlarını Kaldırma
<?php
//epfarki.com //Gereksiz .css ve .js dosyalarını kaldırma
function stil_sil() {
if(!is_page('İletişim')){
wp_deregister_style( 'contact-form-7' );
}
wp_deregister_style( 'cptchStylesheet' );
wp_deregister_style( 'codecolorer' );
wp_deregister_script( 'wp-recentcomments-jquery' );
}