Truncating Permalinks That Are Displayed for RSS Feed Generated WordPress Posts

I am setting up an aggregator WordPress site that automatically generates syndicated posts from the content of selected RSS feeds.

My problem lies with the WordPress permalinks for these syndicated posts -- which point to the original content source pulled from the RSS feed.  In almost all instances, these permalink strings are very lengthy. For example:

http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNFaVkQwfdbun9VrpA09iD38219-jg&url=http://www.cbsnews.com/8301-501708_162-57354545/fsjkalaksniwnrognmsldm7wglv-televised-debate/

My WordPress theme uses the following code to display the permalink string (as plain text):

<cite><?php the_permalink() ?> - </cite>

Open in new window


I would like to set a character limit on the length of the Permalink string that is displayed, so the displayed string is truncated, with "..." affixed at the end.  So the Permalink example listed above would be transformed into something like this:

http://news.google.com/news/url?sa=t&fd=R&...

Any assistance would be greatly appreciated.
JorhalAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
http://www.laprbass.com/RAY_temp_jorhal.php outputs
http://news.google.com/news/url?sa=t&fd=R&...
<?php // RAY_temp_jorhal.php
error_reporting(E_ALL);

// SHOW WHERE &fd=R& OCCURS AT POSITION 42       |
//                                               V
//      1...5...10...15...20...25...30...35...40...45...
$url = 'http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNFaVkQwfdbun9VrpA09iD38219-jg&url=http://www.cbsnews.com/8301-501708_162-57354545/fsjkalaksniwnrognmsldm7wglv-televised-debate/';

// MAKE THE DISPLAY PORTION OF THE URL
$txt = substr($url,0,42) . '...';

// CREATE THE LINK
$lnk
= '<a '
. 'class="off" '
. 'target="_blank" '
. 'href="'
. $url
. '">'
. $txt
. '</a>'
;

// WRITE THE LINK
echo $lnk;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.