0

I try to capitalize the first character of a custom post title on wordpress

I found this solution here:

uppercase issue for title in wordpress

here is the code :

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

it works well for normal content (post) on wordpress.

By cons, I can not use it on a costum post !

I tried also this :

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

but its not working :-(

Community
  • 1
  • 1

2 Answers2

0

You forgot to echo the output in the second example.

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

Update:

I just found in the wordpress codex that you should add a parameter to return the output. I have edited the code.

Jerodev
  • 32,252
  • 11
  • 87
  • 108
  • No error msg, title appears but first letter is not capitalized. remark I use this code on an archive page the display in a loop the title of all custom post posted – user3347894 Aug 05 '14 at 14:57
0

here is the code that i use :

 <?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();              
                      ?>