WordPress.org

Ready to get started?Download WordPress

Forums

All in One SEO Pack
[resolved] make page titles shorter for posts (3 posts)

  1. joswellmaxeph
    Member
    Posted 1 year ago #

    This might be impossible, but I would like to automatically shorten the page titles of posts by adding "..." when the post titles are too long. I can't shorten the post titles themselves, so I can't just do it like that. Any help would be greatly appreciated.

    Thanks,
    Joe

    http://wordpress.org/extend/plugins/all-in-one-seo-pack/

  2. Peter Baylies
    Member
    Plugin Author

    Posted 1 year ago #

    Joe,

    This is possible by filtering the title; try adding the following code into a plugin or in the functions.php of your theme:

    add_filter( 'aioseop_title', 'joe_aioseop_shorter_title' );
    
    function joe_aioseop_shorter_title( $title ) {
        global $aiosp;
        if ( !empty( $aiosp ) ) {
            $title_length = 50;
            if ( strlen( $title ) > $title_length ) $title = $aiosp->trim_excerpt_without_filters( $title, $title_length ) . '...';
        }
        return $title;
    }
  3. joswellmaxeph
    Member
    Posted 1 year ago #

    Thanks! This worked great :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic