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 am looking for, like the title of this question indicates, a custom menu in wordpress where the menu title itself is a link. It seems like a very simple thing, but after a lot of searching I've come up with nothing.

More explanation:

Here is what I have:

My Custom Menu
  Link 1 (goes to page 1)
  Link 2 (goes to page 2)
  Link 3 (goes to page 3)

Here is what I want:

My Custom Menu (goes to w/e page I choose to link it to)
  Link 1 (goes to page 1)
  Link 2 (goes to page 2)
  Link 3 (goes to page 3)

Simple, right? So, is there a plugin for this, or do I need to write on?

share|improve this question
    
Any progress? Was my answer helpful? Do you still miss something? –  toscho Oct 6 '12 at 22:28

1 Answer 1

You can filter the title of most widgets and change the markup. The name of the filter is 'widget_title' and the third parameter tells you the type of the filtered widget.

Sample code, not tested:

add_filter( 'widget_title', 'wpse_52108_nav_widget_title_link', 30, 3 );

/**
 * Changes the title for the nav menu widget.
 *
 * @param string $title
 * @param string $instance
 * @param string $id_base
 * @return string
 */
function wpse_52108_nav_widget_title_link( $title, $instance = NULL, $id_base = '' )
{
    return 'nav_menu' === $id_base ? "<a href='http://example.com'>$title</a>" : $title;
}

The $id_base is the first parameter in parent::__construct() in the widget class. For the nav menu widget it is:

parent::__construct( 'nav_menu', __('Custom Menu'), $widget_ops );
share|improve this answer

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.