• 28-12-2015, 00:07:07
    #1
    Arkadaşlar sitemdeki sliderda en son eklenen 6 tane yazı görüntüleniyor. Bunun yanı sıra ana sayfada bulunan "Son Yazılar" bölümünde de son yazılan 6 tane yazı yine listeleniyor. Yani sliderda ve "Son Yazılar" bölümünde gözüken 6 yazı aynı oluyor.

    Benim istediğim ise "Son Yazılar" bölümünün, en son yazılan 6 sayıyı slider gösterdiği için göstermemesi. Bu son 6 yazıdan sonra geri kalan yazıları göstermesi için ne yapabilirim?

    Kullandığım "Son Yazılar" bileşeninin kodları
    <?php
    /*
     * Plugin Name: Sol Konu Yazılar
     * Version: 1.0
     */
     
    add_action( 'widgets_init', 'kategori_yazi' );
     
    function kategori_yazi() {
     register_widget( 'kategori_yazi' );
    }
     
    class kategori_yazi extends WP_Widget {
     
    function kategori_yazi() {
    
     $widget_ops = array( 'classname' => 'widget_sosyal', 'description' => __('Sol kısım için uygundur.', 'bi3') );
    
     $this->WP_Widget( 'kategori_yazi', __('Sol Kısım Kategori Yazı Seçimi', 'bi3'), $widget_ops );
     }
     
    function widget( $args, $instance ) {
     
     ?>
     <?php
    extract( $args );
    
    $baslik = apply_filters('widget_title', $instance['baslik'] );
    $categories = $instance['categories'];
    $goster = $instance['goster'];
    		
    echo $before_widget; 
    if ( $baslik )
    ?>
    	<div class="main-baslik">
    	<?php $kategori = get_category_link( $categories); ?> 
    				<span class="left"><i class="fa fa-newspaper-o"></i><?php echo $baslik;?></span>
    				<span class="right"><a href="<?php echo esc_url( $kategori ); ?>"><i class="fa fa-plus"></i>TÜMÜNÜ GÖR</a></span>
    	</div>	
    				<ul class="news">
    					<?php $popu = new WP_Query(array('showposts' => $goster , 'cat' => $categories )); while($popu->have_posts()) : $popu->the_post();?>
    					<li>
    						<div class="newspic">
    				
    							<a href="<?php the_permalink(); ?>">
    							<?php the_post_thumbnail(  array(390,350), array( 'alt' => get_the_title()) );  ?>
    						
    							<div class="sbg"><i class="fa fa-search"></i></div>
    							</a>
    						</a>	
    						</div>
    						<div class="newsmore">
    							<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    
    							<p>
    <?php if(strlen(get_post_meta(get_the_ID(), 'aciklama', true)) > 1){echo mb_substr(get_post_meta(get_the_ID(), 'aciklama', true),0,167).''; }else{ get_post_meta(get_the_ID(), 'aciklama', true); } ?></p>
    							<div class="bilgi">
    								<label><i class="fa fa-clock-o"></i> <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) ; ?>  Önce Eklendi.</label>
    								<label><i class="fa fa-list-ul"></i> <?php $category = get_the_category(); ?> <?php  echo $category[0]->cat_name;?></label>
    							</div>
    						</div>
    					</li>
    					<?php endwhile; ?>	
    				</ul>
    			
    				
     <?php
     echo $after_widget;
     }
     
    function update( $new_instance, $old_instance ) {
     		$instance = $old_instance;
    		$instance['baslik'] = (strip_tags( $new_instance['baslik'] ));
    		$instance['categories'] = $new_instance['categories'];
    		$instance['goster'] = strip_tags( $new_instance['goster']);
    		
    		return $instance;
    	}
    function form( $instance ) {
      $defaults = array( 'goster' => 4);
     $instance = wp_parse_args( (array) $instance, $defaults ); ?>
     
            
            
         
       
            <p>
    			<label for="<?php echo $this->get_field_id( 'baslik' ); ?>">Başlık:</label>
    			<input id="<?php echo $this->get_field_id( 'baslik' ); ?>" name="<?php echo $this->get_field_name( 'baslik' ); ?>" value="<?php echo $instance['baslik']; ?>" style="width:100%;" />
    		</p>
            <p>
    			<label for="<?php echo $this->get_field_id( 'goster' ); ?>">Kaç Kere Gösterilsin:</label>
    			<input id="<?php echo $this->get_field_id( 'goster' ); ?>" name="<?php echo $this->get_field_name( 'goster' ); ?>" value="<?php echo $instance['goster']; ?>" style="width:100%;" />
    		</p>
    
            
            
    
    <!-- Kategori -->
    		<p>
    			<label for="<?php echo $this->get_field_id('categories'); ?>">Kategori:</label>
    			<select id="<?php echo $this->get_field_id('categories'); ?>" name="<?php echo $this->get_field_name('categories'); ?>" style="width:100%;">
    				<option value='all' <?php if ('all' == $instance['categories']) echo 'selected="selected"'; ?>>Tüm Kategoriler</option>
    				<?php $categories = get_categories('hide_empty=0&depth=1&type=post'); ?>
    				<?php foreach($categories as $category) { ?>
    				<option value='<?php echo $category->term_id; ?>' <?php if ($category->term_id == $instance['categories']) echo 'selected="selected"'; ?>><?php echo $category->cat_name; ?></option>
    				<?php } ?>
    			</select>
    		</p>  
           
            
             
        
    
    	<?php
    	}
     
     }
    
     
    ?>
  • 28-12-2015, 00:18:41
    #2
    <?php
    /*
     * Plugin Name: Sol Konu Yazılar
     * Version: 1.0
     */
     
    add_action( 'widgets_init', 'kategori_yazi' );
     
    function kategori_yazi() {
     register_widget( 'kategori_yazi' );
    }
     
    class kategori_yazi extends WP_Widget {
     
    function kategori_yazi() {
    
     $widget_ops = array( 'classname' => 'widget_sosyal', 'description' => __('Sol kısım için uygundur.', 'bi3') );
    
     $this->WP_Widget( 'kategori_yazi', __('Sol Kısım Kategori Yazı Seçimi', 'bi3'), $widget_ops );
     }
     
    function widget( $args, $instance ) {
     
     ?>
     <?php
    extract( $args );
    
    $baslik = apply_filters('widget_title', $instance['baslik'] );
    $categories = $instance['categories'];
    $goster = $instance['goster'];
    		
    echo $before_widget; 
    if ( $baslik )
    ?>
    	<div class="main-baslik">
    	<?php $kategori = get_category_link( $categories); ?> 
    				<span class="left"><i class="fa fa-newspaper-o"></i><?php echo $baslik;?></span>
    				<span class="right"><a href="<?php echo esc_url( $kategori ); ?>"><i class="fa fa-plus"></i>TÜMÜNÜ GÖR</a></span>
    	</div>	
    				<ul class="news">
    					<?php $popu = new WP_Query(array('showposts' => $goster , 'offset' => 6, 'cat' => $categories )); while($popu->have_posts()) : $popu->the_post();?>
    					<li>
    						<div class="newspic">
    				
    							<a href="<?php the_permalink(); ?>">
    							<?php the_post_thumbnail(  array(390,350), array( 'alt' => get_the_title()) );  ?>
    						
    							<div class="sbg"><i class="fa fa-search"></i></div>
    							</a>
    						</a>	
    						</div>
    						<div class="newsmore">
    							<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    
    							<p>
    <?php if(strlen(get_post_meta(get_the_ID(), 'aciklama', true)) > 1){echo mb_substr(get_post_meta(get_the_ID(), 'aciklama', true),0,167).''; }else{ get_post_meta(get_the_ID(), 'aciklama', true); } ?></p>
    							<div class="bilgi">
    								<label><i class="fa fa-clock-o"></i> <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) ; ?>  Önce Eklendi.</label>
    								<label><i class="fa fa-list-ul"></i> <?php $category = get_the_category(); ?> <?php  echo $category[0]->cat_name;?></label>
    							</div>
    						</div>
    					</li>
    					<?php endwhile; ?>	
    				</ul>
    			
    				
     <?php
     echo $after_widget;
     }
     
    function update( $new_instance, $old_instance ) {
     		$instance = $old_instance;
    		$instance['baslik'] = (strip_tags( $new_instance['baslik'] ));
    		$instance['categories'] = $new_instance['categories'];
    		$instance['goster'] = strip_tags( $new_instance['goster']);
    		
    		return $instance;
    	}
    function form( $instance ) {
      $defaults = array( 'goster' => 4);
     $instance = wp_parse_args( (array) $instance, $defaults ); ?>
     
            
            
         
       
            <p>
    			<label for="<?php echo $this->get_field_id( 'baslik' ); ?>">Başlık:</label>
    			<input id="<?php echo $this->get_field_id( 'baslik' ); ?>" name="<?php echo $this->get_field_name( 'baslik' ); ?>" value="<?php echo $instance['baslik']; ?>" style="width:100%;" />
    		</p>
            <p>
    			<label for="<?php echo $this->get_field_id( 'goster' ); ?>">Kaç Kere Gösterilsin:</label>
    			<input id="<?php echo $this->get_field_id( 'goster' ); ?>" name="<?php echo $this->get_field_name( 'goster' ); ?>" value="<?php echo $instance['goster']; ?>" style="width:100%;" />
    		</p>
    
            
            
    
    <!-- Kategori -->
    		<p>
    			<label for="<?php echo $this->get_field_id('categories'); ?>">Kategori:</label>
    			<select id="<?php echo $this->get_field_id('categories'); ?>" name="<?php echo $this->get_field_name('categories'); ?>" style="width:100%;">
    				<option value='all' <?php if ('all' == $instance['categories']) echo 'selected="selected"'; ?>>Tüm Kategoriler</option>
    				<?php $categories = get_categories('hide_empty=0&depth=1&type=post'); ?>
    				<?php foreach($categories as $category) { ?>
    				<option value='<?php echo $category->term_id; ?>' <?php if ($category->term_id == $instance['categories']) echo 'selected="selected"'; ?>><?php echo $category->cat_name; ?></option>
    				<?php } ?>
    			</select>
    		</p>  
           
            
             
        
    
    	<?php
    	}
     
     }
    
     
    ?>

    Bu şekilde bir deneyin.
  • 28-12-2015, 01:10:21
    #3
    FSahin adlı üyeden alıntı: mesajı görüntüle
    <?php
    /*
     * Plugin Name: Sol Konu Yazılar
     * Version: 1.0
     */
     
    add_action( 'widgets_init', 'kategori_yazi' );
     
    function kategori_yazi() {
     register_widget( 'kategori_yazi' );
    }
     
    class kategori_yazi extends WP_Widget {
     
    function kategori_yazi() {
    
     $widget_ops = array( 'classname' => 'widget_sosyal', 'description' => __('Sol kısım için uygundur.', 'bi3') );
    
     $this->WP_Widget( 'kategori_yazi', __('Sol Kısım Kategori Yazı Seçimi', 'bi3'), $widget_ops );
     }
     
    function widget( $args, $instance ) {
     
     ?>
     <?php
    extract( $args );
    
    $baslik = apply_filters('widget_title', $instance['baslik'] );
    $categories = $instance['categories'];
    $goster = $instance['goster'];
    		
    echo $before_widget; 
    if ( $baslik )
    ?>
    	<div class="main-baslik">
    	<?php $kategori = get_category_link( $categories); ?> 
    				<span class="left"><i class="fa fa-newspaper-o"></i><?php echo $baslik;?></span>
    				<span class="right"><a href="<?php echo esc_url( $kategori ); ?>"><i class="fa fa-plus"></i>TÜMÜNÜ GÖR</a></span>
    	</div>	
    				<ul class="news">
    					<?php $popu = new WP_Query(array('showposts' => $goster , 'offset' => 6, 'cat' => $categories )); while($popu->have_posts()) : $popu->the_post();?>
    					<li>
    						<div class="newspic">
    				
    							<a href="<?php the_permalink(); ?>">
    							<?php the_post_thumbnail(  array(390,350), array( 'alt' => get_the_title()) );  ?>
    						
    							<div class="sbg"><i class="fa fa-search"></i></div>
    							</a>
    						</a>	
    						</div>
    						<div class="newsmore">
    							<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    
    							<p>
    <?php if(strlen(get_post_meta(get_the_ID(), 'aciklama', true)) > 1){echo mb_substr(get_post_meta(get_the_ID(), 'aciklama', true),0,167).''; }else{ get_post_meta(get_the_ID(), 'aciklama', true); } ?></p>
    							<div class="bilgi">
    								<label><i class="fa fa-clock-o"></i> <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) ; ?>  Önce Eklendi.</label>
    								<label><i class="fa fa-list-ul"></i> <?php $category = get_the_category(); ?> <?php  echo $category[0]->cat_name;?></label>
    							</div>
    						</div>
    					</li>
    					<?php endwhile; ?>	
    				</ul>
    			
    				
     <?php
     echo $after_widget;
     }
     
    function update( $new_instance, $old_instance ) {
     		$instance = $old_instance;
    		$instance['baslik'] = (strip_tags( $new_instance['baslik'] ));
    		$instance['categories'] = $new_instance['categories'];
    		$instance['goster'] = strip_tags( $new_instance['goster']);
    		
    		return $instance;
    	}
    function form( $instance ) {
      $defaults = array( 'goster' => 4);
     $instance = wp_parse_args( (array) $instance, $defaults ); ?>
     
            
            
         
       
            <p>
    			<label for="<?php echo $this->get_field_id( 'baslik' ); ?>">Başlık:</label>
    			<input id="<?php echo $this->get_field_id( 'baslik' ); ?>" name="<?php echo $this->get_field_name( 'baslik' ); ?>" value="<?php echo $instance['baslik']; ?>" style="width:100%;" />
    		</p>
            <p>
    			<label for="<?php echo $this->get_field_id( 'goster' ); ?>">Kaç Kere Gösterilsin:</label>
    			<input id="<?php echo $this->get_field_id( 'goster' ); ?>" name="<?php echo $this->get_field_name( 'goster' ); ?>" value="<?php echo $instance['goster']; ?>" style="width:100%;" />
    		</p>
    
            
            
    
    <!-- Kategori -->
    		<p>
    			<label for="<?php echo $this->get_field_id('categories'); ?>">Kategori:</label>
    			<select id="<?php echo $this->get_field_id('categories'); ?>" name="<?php echo $this->get_field_name('categories'); ?>" style="width:100%;">
    				<option value='all' <?php if ('all' == $instance['categories']) echo 'selected="selected"'; ?>>Tüm Kategoriler</option>
    				<?php $categories = get_categories('hide_empty=0&depth=1&type=post'); ?>
    				<?php foreach($categories as $category) { ?>
    				<option value='<?php echo $category->term_id; ?>' <?php if ($category->term_id == $instance['categories']) echo 'selected="selected"'; ?>><?php echo $category->cat_name; ?></option>
    				<?php } ?>
    			</select>
    		</p>  
           
            
             
        
    
    	<?php
    	}
     
     }
    
     
    ?>

    Bu şekilde bir deneyin.
    Çok teşekkürler. İşe yaradı