![]() |
Wordpress Help - truncating blog titles on listing page
This should be pretty simple but I seem to be having some issue with Wordpress. I would just like any title longer than 50 characters to be cut off and end with "..." Here is the code I currently have: Nothing is happening, the page works but it' doesn't truncate the post title string.
PHP Code:
|
Looks like you are just forgetting to reassign the title back to the original object.
PHP Code:
Edit: Also I don't know which title you are trying to post.. You have two "post_title"'s from two different classes |
Quote:
It is a blog index page, so it loops and posts the most recent 5 stories, not one particular title. So that code is in a look and I just want to check for any title over 50 characters long. I don't think that part should make a difference though, there just seems to be something wrong with the way it's grabbing the "post_title" variable. |
You misunderstood me
You have two "post_title" variables. PHP Code:
Also, I see no code printing any post titles? only the page content and '...' |
Sorry, I am editing this for someone else and just realize it was totally in the wrong section.
Here is the actual code printing the Title's PHP Code:
PHP Code:
|
It depends on whether the function "the_title()" is returning or echoing the title.
If it is returning the title then yes, you can apply the substr function. If it is echoing the title then no, you can not apply the substr function. You need to look for and find that function. (I have a feeling it is echoing the title) |
You are correct! It was echoing... I found the function in the post_template file and wrote a new one to handle truncating the titles! Thanks for your guidance, it helped me solve this!
|
Anytime :), glad to help
|
| All times are GMT +1. The time now is 12:34 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.