在 WordPress 中创建 AZ 列表索引时出现重音问题
我为WordPress词典网站创建了一个AZ索引。 当一些字母上使用重音时,我有一个问题。
我用消毒来避免这种情况,但是现在每个用e开始的单词都像另一个字母,而不是被分组。我如何将每个单词从e开始,无论是否有口音?
这是指向我页面的链接: http://preprod2.atelier-labotte.fr/dictionnaire/dictionnaire/
这是我用于创建索引的代码:
<?php
$letter = '';
while($dictionnaire->have_posts())
{
$dictionnaire->the_post();
// Check the current letter is the same that the first of the title
if($letter != strtoupper(get_the_title()[0]))
{
echo ($letter != '') ? '</div></section>' : '';
$letter = strtoupper(substr(sanitize_title( get_the_title() ),0,1));
echo '<section id="'. $letter .'" class="wp-block-group letter-section"><div class="big-letter"><p>'.strtoupper(substr(sanitize_title( get_the_title() ),0,1)).'</p></div><div class="wp-block-group__inner-container d-grid columns-3">';
}
?>
感谢您的帮助!
PS:我是非英语的母语者,请原谅我的误解!
I created an A-Z index for my wordpress dictionary website.
I've got an issue when accents are used on some letters.
I used sanitize to avoid this but now every word beggining with an E is like another letter instead of being grouped. How can I group every word begining with an E regardless of is there an accent or not ?
Here's the link to my page : http://preprod2.atelier-labotte.fr/dictionnaire/
Here's the code I used for creating the index :
<?php
$letter = '';
while($dictionnaire->have_posts())
{
$dictionnaire->the_post();
// Check the current letter is the same that the first of the title
if($letter != strtoupper(get_the_title()[0]))
{
echo ($letter != '') ? '</div></section>' : '';
$letter = strtoupper(substr(sanitize_title( get_the_title() ),0,1));
echo '<section id="'. $letter .'" class="wp-block-group letter-section"><div class="big-letter"><p>'.strtoupper(substr(sanitize_title( get_the_title() ),0,1)).'</p></div><div class="wp-block-group__inner-container d-grid columns-3">';
}
?>
Thanks for your help !
PS : I'm non-english native speaker, please forgive my mistkakes !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢您的帮助 !
我找到了达到所需物品的方法,因此我共享解决方案。
我希望这是实现这一目标的最简单方法,但这是我使用的:
Thanks for your help !
I find a way to reach what I needed so I share the solution.
I hope this is the simplest way to achieve this but here's what I used :