我在我的網站上發布圣訓,并以 3 種翻譯發布:阿拉伯語、烏爾都語、英語。在圣訓的頁面中,圣訓一一顯示,它顯示的是阿拉伯語摘錄文本。查看我的網站,這是我的網站鏈接:IF Islam看這個截圖:我想在這里顯示英語圣訓摘錄文本而不是阿拉伯語和烏爾都語。哪個 PHP 代碼會這樣做?請幫忙這是content.php代碼:<div class="col-lg-8 col-md-6"> <div class="card-body"> <a href="<?php the_permalink(); ?>" class=""> <h2 class="single_post_title h3-responsive text-primary mb-1"><?php the_title(); ?></h2> </a> <div class="blog_meta"> <time class="blog_meta_posted_on grey-text"><?php the_time('F j, Y g:i a'); ?></time> <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>" class="blog_meta_author grey-text"><?php the_author(); ?></a> <a href="<?php the_permalink(); ?>#responses" class="blog_meta_count_comments grey-text"><?php echo get_comments_number(); ?> Comments</a> <label class="blog_meta_tags_list"> <?php echo get_the_tag_list( '', ', ', '' ); ?> </label> </div> <div class="blog_excerpt_content black-text m-0 mt-2"> <?php the_excerpt(); ?> </div> <a href="<?php the_permalink(); ?>" class="btn btn-primary">Read More</a> </div></div>
2 回答

POPMUISE
TA貢獻1765條經驗 獲得超5個贊
嘗試更換
<?php the_excerpt(); ?>
和
<?php
$position = strpos(get_the_content(), 'Hadith in English Translation');
$excerpt = strip_tags(substr(get_the_content(), $position));
echo $excerpt;
?>
我認為get_the_content()以 HTML 形式返回帖子的完整內容。我們使用函數strpos和substr構建了一個$excerpt從'Hadith in English Translation'帖子內容開始到結束的新內容。我們還使用strip_tags從任何 HTML 標簽中剝離了摘錄。
當然,您只需要將代碼用于 Hadith 類別(在您添加的“category-hadith.php”中?),因為您只需要在那里進行修改。
檢查它是否有效并注意該解決方案假設帖子內容始終包含字符串'Hadith in English Translation',并且英文翻譯在其他兩個之后排在最后一個位置。

慕后森
TA貢獻1802條經驗 獲得超5個贊
我認為我們需要更多信息才能正確回答您的問題。首先,您能否向我們展示您用于顯示摘錄的代碼。根據您的問題,我只能想象您在 CMS 的摘錄中按字面鍵入了阿拉伯語文本。
- 2 回答
- 0 關注
- 213 瀏覽
添加回答
舉報
0/150
提交
取消