<?php
################################################################
# meta box ekleme
################################################################
add_action( 'add_meta_boxes', 'cd_add_quote_meta' );
function cd_add_quote_meta()
{
add_meta_box( 'quote-meta', 'Haber resim', 'cd_quote_meta_cb', 'post', 'normal', 'high' );
}
if ( !function_exists( 'optionsframework_init' ) ) {
define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/' );
require_once dirname( __FILE__ ) . '/inc/options-framework.php';
}
function cd_quote_meta_cb( $post )
{
$resim = get_post_meta( $post->ID, 'resim', true );
wp_nonce_field( 'save_quote_meta', 'kutucuk' );
?>
<p>
<label for="resim">Haber resmi</label>
<input type="text"name="resim" style="width:500px;" value="<?php echo $resim; ?>" /> Öne çıkarılmış görseli de kullanabilirsiniz.
</p>
<?php
}
add_action( 'save_post', 'cd_quote_meta_save' );
function cd_quote_meta_save( $id )
{
if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
if( !isset( $_POST['kutucuk'] ) || !wp_verify_nonce( $_POST['kutucuk'], 'save_quote_meta' ) ) return;
if( !current_user_can( 'edit_post' ) ) return;
$allowed = array(
'p' => array()
);
if( isset( $_POST['resim'] ) )
update_post_meta( $id, 'resim', esc_attr( strip_tags( $_POST['resim'] ) ) );
}
?>
################################################################
# tarihi turkcelestiren fn
################################################################
<?php
function turkce_tarih($tarih = ""){
if ($tarih=="")
$tarih = date("Y-m-d H:i:s");
$tarihDizi["gunler"] = array("Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi");
$tarihDizi["aylar"] = array ("01" => "Ocak", "02" => "Şubat", "03" => "Mart", "04" => "Nisan", "05" => "Mayıs", "06" => "Haziran",
"07" => "Temmuz", "08" => "Ağustos", "09" => "Eylül", "10" => "Ekim", "11" => "Kasım", "12" => "Aralık");
$zamanExp = explode (" ",$tarih);
$tarihExp = explode ("-",$zamanExp[0]);
$haftaninGunu=strftime("%w",strtotime($tarih));
$tarihFormat["ay"] = $tarihDizi["aylar"][$tarihExp[1]];
$tarihFormat["haftanin_gunu"] = $tarihDizi["gunler"][$haftaninGunu];
$tarihFormat["saat"] = $zamanExp[1];
$tarihFormat["format1"] = $tarihExp[2]." ".$tarihFormat["ay"]." ".$tarihExp[0];
$tarihFormat["format2"] = $tarihFormat["format1"]." ".$tarihFormat["saat"];
$tarihFormat["format3"] = $tarihExp[2]." ".$tarihFormat["ay"]." ".$tarihExp[0];
$tarihFormat["format4"] = $tarihFormat["format3"]." ".$tarihFormat["haftanin_gunu"];
return $tarihFormat;
}
################################################################
# human time fn
################################################################
function tarih_yazilma($tarih) {
$fark_tarih = time() - $tarih;
$kontrol_tarih_saniye = $fark_tarih;
$kontrol_tarih_dakika = round( $fark_tarih / 60 );
$kontrol_tarih_saat = round( $fark_tarih / 3600 );
if($kontrol_tarih_saniye < 60 ) {
echo $kontrol_tarih_saniye .' saniye önce'; }
elseif ($kontrol_tarih_dakika < 60 ) {
echo $kontrol_tarih_dakika .' dakika önce'; }
elseif ($kontrol_tarih_saat < 24 ) {
echo $kontrol_tarih_saat .' saat önce';
} else {
$formatliTarih = turkce_tarih(get_post_time('Y-m-d'));
echo $formatliTarih["format4"];
}
}
?>
################################################################
# sayfalama
################################################################
<?php
function yazisayfalama($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 4, $always_show = false) {
global $request, $posts_per_page, $wpdb, $paged;
if(empty($prelabel)) { $prelabel = 'Önceki';
} if(empty($nxtlabel)) {
$nxtlabel = 'Sonraki';
} $half_pages_to_show = round($pages_to_show/2);
if (!is_single()) {
if(!is_category()) {
preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches); } else {
preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); }
$fromwhere = $matches[1];
$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
$max_page = ceil($numposts /$posts_per_page);
if(empty($paged)) {
$paged = 1;
}
if($max_page > 1 || $always_show) {
echo "$after $before";
previous_posts_link($prelabel);
if ($paged >= ($pages_to_show)) {
echo '<a href="'.get_pagenum_link().'">1</a>'; }
for($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) { if ($i >= 1 && $i <= $max_page) { if($i == $paged) {
echo '<a class="aktif" title="Sayfa '.$i.'" >'.$i.'</a>';
} else {
echo ' <a class="sayfa" href="'.get_pagenum_link($i).'" title="Sayfa '.$i.'">'.$i.'</a> '; }
}
}
if (($paged+$half_pages_to_show) < ($max_page)) {
echo '<a class="sayfa" href="'.get_pagenum_link($max_page).'">'.$max_page.'</a>'; }
next_posts_link($nxtlabel, $max_page);
}
}
}
################################################################
# sidebar dinamik
################################################################
if ( function_exists('register_sidebar') )
register_sidebar(array('name'=>'Yan Menu',
'before_widget' => '<div class="bilesen">',
'after_widget' => '</div></div>',
'before_title' => '<h2 class="baslik">',
'after_title' => '</h2><div class="bilesen-ic">',
));
################################################################
# anasayfa haber blokları
################################################################
function anasayfaHaberBlok($kat_id = "",$renk) { ?>
<div class="haber-blok <?php echo $renk; ?>-haber-blok">
<div class="baslik">
<?php if($kat_id) { ?>
<h2><a href="<?php echo get_category_link($kat_id); ?>"><?php echo get_cat_name($kat_id); ?></a></h2>
<span class="icon-angle-right" data-href="<?php echo get_category_link($kat_id); ?>"></span>
<?php } else { ?>
<h2><a>Son Haberler</a></h2>
<?php } ?>
</div>
<div class="ic t">
<?php
query_posts('cat='.$kat_id.'&showposts=5');
while ( have_posts() ) : the_post();
$haber_say++;
?>
<?php if($haber_say == 1) { ?>
<div class="haber-buyuk">
<div class="sol">
<a href="<?php the_permalink(); ?>"><?php resim(280,170); ?></a>
</div>
<div class="sag">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<span class="ozet">
<?php the_excerpt(); ?>
</span>
<div class="detay">
<time class="tarih"><?php tarih_yazilma(get_the_time("U")); ?></time>
</div>
</div>
</div><!--/haber-buyuk-->
<div class="tem"></div>
<?php } else { ?>
<div class="haber-kucuk">
<a class="resim" href="<?php the_permalink(); ?>"><?php resim(175,100); ?></a>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
</div>
<?php } ?>
<?php endwhile;wp_reset_query(); ?>
</div>
</div><!--/haber-blok-->
<?php
}
################################################################
# üst menu altı 5li haber
################################################################
function besli_haber() {
$besli_kat = of_get_option(besli_kat);
?>
<div class="besli" id="besli">
<ul class="t">
<?php
query_posts('cat='.$besli_kat.'&showposts=5');
while ( have_posts() ) : the_post();
?>
<li>
<span class="icon-link" data-link="<?php the_permalink(); ?>"></span>
<a href="<?php the_permalink(); ?>">
<?php resim(175,100); ?>
</a>
<a class="baslik" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile;wp_reset_query(); ?>
</ul>
</div><!--/besli-->
<?php
}
################################################################
# kategori ? yazının kategori
################################################################
function kategori_esit_mi_yazininkine($yazi_id) {
$foto_kat = of_get_option(foto_kat);
$video_kat = of_get_option(video_kat);
foreach((get_the_category($yazi_id)) as $kat) {
if($kat->cat_ID == $foto_kat) {
echo '<span class="icon-camera"></span>';
} elseif($kat->cat_ID == $video_kat) {
echo '<span class="icon-facetime-video"></span>';
}
}
}
################################################################
# ek include (silme)
################################################################
include("lib/sablon/ek.php");
################################################################
# v2 versiyon kodları aşağıdadır.
# güncelenme tarihi : 28.04.2013
################################################################
################################################################
# register nav menu
################################################################
register_nav_menu( 'en_ust_menu', 'En üst menü');
################################################################
# resim adres
################################################################
function resim_adres() {
global $post;
if (get_post_meta($post->ID, 'resim', true) != '') {
$resim = get_post_meta($post->ID, 'resim', true); ?>
<?php echo $resim ?>
<?php } elseif(has_post_thumbnail()) { ?>
<?php
$hpt = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail_size' );
echo $hpt[0];
?>
<?php } else { ?>
<?php echo bloginfo('template_url'); ?>/resimyok.png
<?php }
} PHP Yardım Bi konuda bir yerde takıldım
15
●977
- 08-09-2013, 22:26:20Üyeliği durduruldu
- 08-09-2013, 22:34:59Abstract adlı üyeden alıntı: mesajı görüntüle
hocam yine olmadı sonuna dediğiniz gibi ?> soradan ekleme yapıp yine denedim olmadı - 09-09-2013, 16:42:43arkadaşlar sorunumu halen çözemedim yardımcı olursanız sevinirim...
- 09-09-2013, 17:35:53wp-includes/general-template.php dosyasını aç aşağıdaki kodları ekle
function nekadargecti( $d = 'd/m/Y H:i' ) { $a = apply_filters('the_time', get_the_time( $d ), $d); $b = strtotime($a); $simdikizaman = time(); $fark = $simdikizaman - $b; $sn = $fark; $dk = round($fark/60); $saat = round($fark/(60*60)); $gun = round($fark/(60*60*24)); $hafta = round($fark/(60*60*24*7)); $ay = round($fark/(60*60*24*7*4)); $yil = round($fark/(60*60*24*7*4*12)); if($sn < 60) $n = $sn.' saniye önce yazıldı.'; elseif($dk < 60) $n = $dk.' dakika önce yazıldı.'; elseif($saat < 24) $n = $saat.' saat önce yazıldı.'; elseif($gun < 7) $n = $gun.' gün önce yazıldı.'; elseif($hafta < 4) $n = $hafta.' hafta önce yazıldı.'; elseif ($ay < 12)$n = $ay.' ay önce yazıldı.'; else $n = $yil.' yıl önce yazıldı.'; echo $n; }kullanmak istediğin yerlere de aşağıdaki gibi kullan
nekadargecti()
umarım yanlış anlamamışımdır ve umarım işiniz hal olur - 10-09-2013, 10:42:08hocam dediğinizide yaptım olmadı malsef zaten function.php dosyasında kodlar generel template ile değil hocam.Sable adlı üyeden alıntı: mesajı görüntüle
- 13-09-2013, 21:43:43arkadaşlar bu konuda yardımcı olursanız çok memnun olurum halen çözemedim sorunumu