add_filter( 'the_content', 'custom_reading_time_and_numbers', 20 ); function custom_reading_time_and_numbers( $content ) { if ( is_single() ) { // 1. محاسبه زمان مطالعه $post_content = get_post_field( 'post_content', get_the_ID() ); $clean_content = strip_tags( $post_content ); $word_count = str_word_count( $clean_content, 0, '۰۱۲۳۴۵۶۷۸۹' ); // احتساب کلمات فارسی $reading_time = ceil( $word_count / 200 ); // 200 کلمه در دقیقه $reading_text = "⏱ زمان مطالعه: " . $reading_time . " دقیقه"; // 2. تابع تبدیل اعداد انگلیسی به فارسی function convert_to_persian_numbers( $string ) { $persian_numbers = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'); $english_numbers = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); return str_replace( $english_numbers, $persian_numbers, $string ); } // 3. اعمال تبدیل روی زمان مطالعه $reading_text = convert_to_persian_numbers( $reading_text ); // 4. ساخت تگ HTML برای نمایش بالای مطلب (افزودن به ابتدای محتوا) $reading_html = '