Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've been browsing around Google for quite some time now, but I have yet to find a close answer.

Anyway, is there a way to limit a user to just one link (preferably outbound) per post?

share|improve this question

1 Answer 1

Take it as a starting point (not tested):

/**
 * Limit links inside the content.
 * 
 * @param (string) $content
 * @return (string) $content
 */
function wpse30754_limit_content_links( $content )
{
    // delete all <a> tags in the post
    $content = preg_replace( "/<a[^>]*><\\/a[^>]*>/", '', $content );

    return $content;
}
add_filter( 'the_content', 'wpse30754_limit_content_links' );

What's not yet implemented is preserving the first link. You'll need that on yourself.

share|improve this answer
    
Downvoting is ok, as long, as I get some feedback.... –  kaiser Jul 18 '12 at 0:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.