Wsparcie » Wtyczki » Wtyczka "Auto numbering post" – zlicza posty od 0. Co zrobić, by zliczała od 1?

  • Rozwiązano Kurdupel

    (@kurdupel)


    Pobrałem ostatnio wtyczkę auto numbering post. Dodaje ona do tytułu numer postu. Problem w tym, że zaczyna się od zera (0). Wiecie co zrobić, by licznik wystartował od 1?

    Tak wygląda cały kod:

    add_action( 'the_title', 'dk_auto_numbering' );
    
    function dk_auto_numbering($title) {
     $post_ID = get_the_ID();
     $the_post = get_post($post_ID);
     $date = $the_post->post_date;
     $maintitle = $the_post->post_title;
    
     if ($the_post->post_status == 'publish' AND $the_post->post_type == 'post' AND in_the_loop()) {
         global $wpdb;
         $count = $wpdb->get_var("SELECT count(*) FROM $wpdb->posts  WHERE post_status='publish' AND post_type='post' AND post_date<'{$date}'");
        if ($maintitle==$title) {
         $count = $count.'....';
        } else {
         $count ='.';
        }
     } 
    
     return $count.$title;
    
    }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • Temat ‘Wtyczka "Auto numbering post" – zlicza posty od 0. Co zrobić, by zliczała od 1?’ jest zamknięty na nowe odpowiedzi.