2019-07-30 16:29

显示英文字符而不是阿拉伯语 - WordPress


I am posting Hadiths in my website and i post it in 3 translations: Arabic, Urdu, English. In Hadith's page, where Hadiths are showing one by one, It's showing Arabic excerpt text.
See my web, Here is my Website link: IF Islam

See this screenshot: enter image description here

I want here to show English Hadith excerpt text instead of Arabic and Urdu.
Which PHP code will do this?
Please help

Here is the content.php code:

<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>
       <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( '', ', ', '' ); ?>
       <div class="blog_excerpt_content black-text m-0 mt-2">
           <?php the_excerpt(); ?>
       <a href="<?php the_permalink(); ?>" class="btn btn-primary">Read More</a>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • doudong2149 doudong2149 2年前

    Try to replace

    <?php the_excerpt(); ?>


    $position = strpos(get_the_content(), 'Hadith in English Translation');
    $excerpt = strip_tags(substr(get_the_content(), $position));
    echo $excerpt;

    I think get_the_content() returns the post full contents in HTML. We constructed a new $excerpt starting from 'Hadith in English Translation' to the end of the post contents using the functions strpos and substr. We also stripped the excerpt from any HTML tags using strip_tags.

    Of course you need to use the code only for the Hadith category (inside the "category-hadith.php" you added?) since you only need the modification there.

    Check if it is working and note that the solution supposes that the post contents has always the string 'Hadith in English Translation' and the english translation comes in last position after the two others.

    点赞 评论 复制链接分享
  • dsq30861 dsq30861 2年前

    I think we need a little more information in order to answer your question correctly. For starters, could you show us your code that you use for showing the excerpts. Based on your question, i only can imagine that your literally typed Arabic text in the excerpt in your CMS.

    点赞 评论 复制链接分享