logo

$20
Remove URL from blogroll links

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!

Jon Phillips | 04/23/10 at 2:49pm | Edit


(3) Possible Answers Submitted...

  • avatar
    Last edited:
    04/23/10
    2:55pm
    Lew Ayotte says:

    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

    • 04/23/10 2:58pm

      Jon Phillips says:

      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...

  • avatar
    Last edited:
    04/23/10
    2:58pm
    Milan Petrovic says:

    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.

    Previous versions of this answer: 04/23/10 at 2:58pm

    • 04/23/10 2:59pm

      Jon Phillips says:

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

      Thanks!

  • avatar
    Last edited:
    04/23/10
    7:38pm
    Utkarsh Kukreti says:

    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.

    Previous versions of this answer: 04/23/10 at 3:05pm

    • 04/23/10 3:08pm

      Jon Phillips says:

      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

    • 04/23/10 3:18pm

      Utkarsh Kukreti says:

      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);
      }

This question has expired.





Current status of this question: Completed