• Resolved TruthMerchant

    (@truthmerchant)


    I activate my plugin and it seems to work all except for the

    ‘add_filter( ‘wp_nav_menu_items’, ‘add_loginout_link’, 10, 2 );’

    http://pastebin.com/hxq5Gm4T

    The register shortcode works fine and so too all the others. But the filter routine never gets called. I am doing something really stupid and looking at it for another bunch of hours won’t fix it.

    I tried changing themes but that didn’t help either.

    http://tacomatest.org/v2

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I don’t see anything wrong with your code, it must be that wp_nav_menu() is not called by the theme or no menu items are defined so the function exits prematurely.

    To be thorough, you can verify your filter was properly registered by doing a var_dump() of global $wp_filter, or put a couple test die() statements in wp_nav_menu() to confirm it’s not being called.

    Thread Starter TruthMerchant

    (@truthmerchant)

    I have come to the conclusion that messing with menus is simply not a plugin thing to do. The theme people and the wordpress core people seem to do things in such a way as to prevent isolation of ones code in a valid plugin. That may well have to do with an idealized view wherein “functionality” is to remain separated from “presentation”. The intersection of these two worlds happens at “menu”.

    If I administer the theme properly, and name and select the menu “bar” appropriately then the plugin code can be made to work as I want. I think that is messy, but I will have to abide it.

    I appreciate your taking an interest and I did what you said. The code that links up to the filter I was using is not executed because of the way the theme is done. That will be a problem (I think) with all themes. My reaction is to figure out a way to make my stuff work regardless of the theme. But that is probably not the best way to go. I need to “fit in” with the way the theme people do things. It means that I will have to provide good documentation on how to do the menus using the “appearance->menus” manual stuff….. Oh well….

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add_filter('wp_nav_menu_items', 'my stuff') not working?’ is closed to new replies.