Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Remove URL from blogroll links WordPress

  • SOLVED

Hi,

I have a blogroll with a list of links. I would like to 'unlink' some of them and just display plain text but WP won't let you do that as it 'needs' to have at least a # sign in the 'Web Address' field. I would like to have some links pointing to real URLs and other bookmarks to not be linked to any URL at all.

Is there a way to remove this requirement and have WP turn the bookmarks that have a URL into actual links and bookmarks that don't have a URL in plain text?

Thanks!

Answers (3)

2010-04-23

Utkarsh Kukreti answers:

Open wp-admin/includes/bookmark-template.php
Find
$output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>';
Replace with
$output .= $the_link == '#' ? $title : ('<a href="' . $the_link . '"' . $rel . $title . $target . '>');

Now if you add a link with href = #, it'll be printed as plain text.

I couldn't think of any solution without modifying the core yet. Will try.


Jon Phillips comments:

That worked fine ;)

Though if it's possible to turn this into a function in order to keep the core file intact that'd be sweet.

Thanks a lot


Utkarsh Kukreti comments:

If the title, rel, and target are empty, and the url is = '#', try this function


add_filter('wp_list_bookmarks', 'my_custom_bookmarks');
function my_custom_bookmarks($output)
{
return preg_replace('/<a href="#">(.*?)</a>/', '$1', $output);
}

2010-04-23

Lew Ayotte answers:

It might be easier to just use the Text widget and supply your own links for the ones that need them and not for those that don't...

Lew


Jon Phillips comments:

That would work, though this site is for a client and it would be much easier for them if they could use the bookmark feature to handle all this instead of having to manually enter the li, a href, etc...

2010-04-23

Milan Petrovic answers:

If you want to use WordPress blogroll display (widget), you can't do that, not without writing functions that are creating links. I checked them out (wp_list_bookmarks is used and _walk_bookmarks), and the A tag is always display for each link. There is no filters or actions in these functions to hook into them and changes this, and only thing that can be done is to replace _walk_bookmarks function with another one that will make the distinction you need for displaying linked and not linked bookmarks.


Jon Phillips comments:

Oh ok thanks! And would you (or someone on wpquestions) be able to supply that custom function to replace the _walk_bookmarks function?

Thanks!