• 08-10-2020, 20:40:52
    #1
    merhabalar, wordpress sitemde var olan bir sayfama sitede bulunan son yazıları otomatik göstermesini istiyorum. nasıl yapabilirim?
  • 08-10-2020, 20:49:19
    #2
    son yazılar eklentisi kullanabilirsin hocam
  • 08-10-2020, 22:18:50
    #3
    yedek alarak deneyin lütfen.

    functions.php'ye bunu ekleyin:

    function son_yazilar_shortcode($atts, $content = null) {
        
        global $post;
        
        extract(shortcode_atts(array(
          'num' => '5',
          'order' => 'DESC'
          'orderby' => 'date'
     ), $atts));
        
        $args = array(
            'posts_per_page' => $num,
            'order' => $order,
            'orderby' => $orderby,
        );
        
        $output = '';
        
        $posts = get_posts($args);
        foreach($posts as $post) {
            setup_postdata($post);
            
            $output .= '<li><a href="'. get_the_permalink() .'">'. get_the_title() .'</a></li>';
            
        }
        
        wp_reset_postdata();
        
        return '<ul>'. $output .'</ul>';
        
    }
    add_shortcode('recent_posts', 'son_yazilar_shortcode');
    [son_yazilar_shortcode] şeklinde sayfa içeriğine ekleyebilirsiniz.