douyao7390 2019-07-30 16:29
浏览 94
已采纳

显示英文字符而不是阿拉伯语 - 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>
       </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条回答 默认 最新

  • doudong2149 2019-07-31 18:28
    关注

    Try to replace

    <?php the_excerpt(); ?>
    

    With

    <?php
    $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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 删除虚拟显示器驱动 删除所有 Xorg 配置文件 删除显示器缓存文件 重启系统 可是依旧无法退出虚拟显示器
  • ¥15 vscode程序一直报同样的错,如何解决?
  • ¥15 关于使用unity中遇到的问题
  • ¥15 开放世界如何写线性关卡的用例(类似原神)
  • ¥15 关于并联谐振电磁感应加热
  • ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
  • ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
  • ¥66 如何制作支付宝扫码跳转到发红包界面
  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题