I need help inserting a wordpress function

Hi

I need a bit of help adapting a Wordpress function.
I want to automatically truncate post titles on the index page and I’m using the following bit of code which works fine:
[php]function custom_trim_my_title( $title ) {
if ( strlen( $title ) >= 23 && ! is_singular() ) {
$title = substr( $title, 0, 23 ) . ‘…’;
return $title;
}
return $title;
}
add_filter( ‘the_title’, ‘custom_trim_my_title’ );[/php]

but now I want to restrict that to pages using index.php only.
I think I want to use this:
[php]if (is_page_template(‘tmp_home_page.php’)[/php]

but I’m not sure how to insert it into the above code.
Can anyone help me out?
Thanks in advance
Vik

One way to do this is to create a custom template for that particular page with your code in the page template. Probably a better solution than a global function.

Sponsor our Newsletter | Privacy Policy | Terms of Service