Featured Yazı İçin 2. İçin Yazı Adeti ve Offset Ayarı

2 Mesajlar 423 Okunma
smmexpress

Yusuf18 Yusuf18 $86 18.01.2019 Kullanıcı
  • Üyelik 15.01.2016
  • Yaş/Cinsiyet 38 / E
  • Meslek Asker
  • Konum Diğer
  • Ad Soyad Y** M**
  • Mesajlar 939
  • Beğeniler 167 / 171
  • Ticaret 1, (%100)
Arkadaşlar Merhaba

tema kodlarken 2. blok offset ile birlikte yazı sayısı bi ayarlayamadım

widget olarak eklenti haline getirdim ama adet miktarı 5 oldumu 2 blokta 5 oluyor bunu 2-3 olarak bölebilirmiyim ve bu 3. deki offset olarak 1. den sonra 2. olarak başlamasını

ilk hata düzelttiğimde bu kez offset hatası alıyorum

Başka kod olursa eklerim

public function widget($args,$instance){
$post_types=$this->get_all_post_types();

if ( ! isset( $args['widget_id'] ) ) {
$args['widget_id'] = $this->id;
}

$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Son Yazılar 1', 'abydos_looplist1_widgets' ) : $instance['title'], $instance, $this->id_base );

$posttype = ! empty( $instance['posttype'] ) ? $instance['posttype'] : 'post';

if ( empty( $instance['number_of_post'] ) || ! $number = absint( $instance['number_of_post'] ) ) {
$number = 2;
}
$yazitarih = isset( $instance['yazitarih'] ) ? $instance['yazitarih'] : false;
$yazaralan = isset( $instance['yazaralan'] ) ? $instance['yazaralan'] : false;
$viewsalan = isset( $instance['viewsalan'] ) ? $instance['viewsalan'] : false;
$yorumalan = isset( $instance['yorumalan'] ) ? $instance['yorumalan'] : false;
$readmealan = isset( $instance['readmealan'] ) ? $instance['readmealan'] : false;

$icon = apply_filters( 'widget_title', $instance[ 'icon' ] );

$category=isset( $instance['category'] ) ? $instance['category']: '';
$orderby=isset( $instance['orderby'] ) ? $instance['orderby']: 'date';
$order=isset( $instance['order'] ) ? $instance['order']: 'desc';

if ( array_key_exists( $posttype, (array) $post_types ) ) {
$post_args=array(
'post_type' => $posttype,
'posts_per_page' => $number,
'no_found_rows' => true,
'post_status' => 'publish',
'ignore_sticky_posts' => true,
'orderby' => $orderby,
'order' => $order,

);

if(!empty($category) && $category!="all"){
$category_part=explode(':', $category);
$post_args['tax_query']=array(
array(
'taxonomy' => $category_part['0'],
'field' => 'id',
'terms' => $category_part[1]
)
);
}

$r = new WP_Query( apply_filters( 'widget_posts_args', $post_args ) );

if ( $r->have_posts() ) :
 

 

👑 Duolingo Öğretmen Hesabı
wmaraci
reklam

wpuzman wpuzman WordPress Developer Kullanıcı
  • Üyelik 13.01.2017
  • Yaş/Cinsiyet 32 / E
  • Meslek Yazılım
  • Konum Trabzon
  • Ad Soyad B** M**
  • Mesajlar 2773
  • Beğeniler 293 / 949
  • Ticaret 33, (%100)
Sorunuzdan hiçbir şey anlaşılmıyor. Düzgün bir şekilde derdinizi anlatırsanız yardımcı olabilirim.
 

 

wmaraci
Konuyu toplam 1 kişi okuyor. (0 kullanıcı ve 1 misafir)
Site Ayarları
  • Tema Seçeneği
  • Site Sesleri
  • Bildirimler
  • Özel Mesaj Al