How to limit character on $post_title?

Status
Not open for further replies.

Divvy

Active Member
806
2009
18
0
Hello guys,

Can someone please help me?
I need to limit character on title using the variable $post_title, how can I do it?

This is my code:

PHP:
<a target="_blank" href="<?php echo get_post_meta($ID,'mr_freeGalleryUrl',true); ?>" rel="nofollow"><?php echo $post_title; ?></a>

Waiting for your precious help, thanks :)

Kind regards
 
3 comments
Thank you my friend! :)

But I dont want to use plugins for this... I need to change my code.
Do you have any idea how to do it?

Thanks once again

Btw, I tried that plugin and is only to limit number of characters in title field, I need to appears something like:

Original line:
Code:
this is only an example of what I need

With limit of 25 characters:
Code:
this is only an example of...

__________________
Added after 14 Hours 27 minutes:

Resolved :)
 
Last edited:
You need to use char limit.

Look at php char limit code and use it in your wordpress file.

I no longer remember how to do this but I find this from stackoverflow site.

PHP:
function echo_200($str){
    echo substr($row['style-info'], 0, 200);
}

echo_200($str);


Put function code to your wordpress function.php and use echo code in any file where you want to put limitation.
 
Status
Not open for further replies.
Back
Top