簡體   English   中英

在wordpress上自定義帖子標題的第一個字符

[英]majuscle to the first character of the custom post title on wordpress

我嘗試在wordpress上大寫自定義帖子標題的第一個字符

我在這里找到了這個解決方案:

Wordpress中標題的大寫問題

這是代碼:

<a href="<?php the_permalink(); ?>"><?php echo ucfirst(get_the_title());?></a>

它適用於wordpress上的常規內容(發布)。

通過缺點,我不能在costum帖子上使用它!

我也嘗試過這個:

<a href="<?php the_permalink(); ?>"><?php ucfirst(the_title());?></a>

但它不起作用:-(

您忘記了在第二個示例中回顯輸出。

<a href="<?php the_permalink(); ?>"><?php echo ucfirst(the_title('', '', false));?></a>

更新:

我只是在wordpress抄本中發現您應該添加一個參數以返回輸出。 我已經編輯了代碼。

這是我使用的代碼:

 <?php 
                      // The Query
                      query_posts( array ( 'post_type' => 'question', 'posts_per_page' => 10 ) );
                      // The Loop
                     while ( have_posts() ) : the_post(); ?>
                        <li>
                            <h2><a href="<?php the_permalink(); ?>"><?php echo ucfirst(the_title('', '', false));?></a></h2>
                            <p class="questionexcerpt"> <?php the_excerpt(); ?> </p>

                        </li>

                      <?php endwhile; // Reset Query 
                      wp_reset_query();              
                      ?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM