Wordpress Titles: If Longer Than 50 Characters, Show Ellipsis

前端 未结 9 1420
谎友^
谎友^ 2021-02-01 19:06

I have a wordpress site with titles, and if the title has more than 50 characters I need to add an ellipsis (...) at the end of the title and stop the title at 50 characters. Be

9条回答
  •  情深已故
    2021-02-01 19:33

    You're checking the length of the string "the_title()". Remove the quotes, and it will probably work (I'm not 100% sure of the difference between the_title() and get_the_title(), as I haven't used Wordpress in a while -- you might have to switch that around too):

     50) { ?>
                    
                
                    ...
                   
    

    or maybe

     50) { ?>
                    
                
                    ...
                   
    

提交回复
热议问题