ThemeShaper Forums » Thematic

[closed]

remove_filter not working (seemingly)

(3 posts)
  • Started 1 year ago by maxelcat
  • Latest reply from maxelcat
  • This topic is not resolved
  1. Hi

    I am learning how to use thematic to make a theme. I must say, so far its great! However, I have got a little stuck.

    I want to edit the list of args that is sent for the menu

    In header-extensions.php I find

    function thematic_page_menu_args() {
    	$args = array (
    		'sort_column' => 'menu_order',
                    etc...........
    		'link_after'  => ''
    	);
    	return $args;
            }
    
    	add_filter('wp_page_menu_args','thematic_page_menu_args');

    In my theme I have a functions.php. I want to avoid editing the thematic stuff if I can avoid it so I thought

    do something like this:

    function maxelcat_page_menu_args(){		
    
    		$args = array (
    			'sort_column' => 'menu_order',
    			'menu_class'  => 'menu',
    			...
    			'link_after'  => ''
    		);
    	return $args;
    }
    
    remove_filter('wp_page_menu_args','thematic_page_menu_args');
    add_filter ('wp_page_menu_args','maxelcat_page_menu_args');

    The plan being to remove the thematic version of the filter and add my own. However, this doesn't work.

    If I comment out the add_filter('wp_page_menu_args','thematic_page_menu_args'); then it does work, but as I said I don't want to mess with the thematic framework if I can avoid it.

    What am I doing wrong please

    Many thanks

    Posted 1 year ago #
  2. please put code between backtick marks thats the ` . on a US keyboard is shares the key with the ~ to the left of the 1. [code] doesn't do anything here.

    next, remove_filter works just fine but you haven't added it to a hook so it does nothing. put it on the init hook (heads up this is the same process for removing an action)

    function kia_remove_filter(){
    remove_filter('wp_page_menu_args','thematic_page_menu_args');
    }
    add_action('init','kia_remove_filter');

    although there really is no need to remove the filter. you could give your function a later priority so that it will do your function AFTER the thematic function.

    function maxelcat_page_menu_args(){
    
    $args = array (
    'sort_column' => 'menu_order',
    'menu_class' => 'menu',
    ...
    'link_after' => ''
    );
    return $args;
    }
    add_filter ('wp_page_menu_args','maxelcat_page_menu_args',99);

    or b/c thematic has a filter in the header-extensions.php function where it creates the page menu args, you could target the thematic filter instead of the WP one.

    function maxelcat_page_menu_args(){
    
    $args = array (
    'sort_column' => 'menu_order',
    'menu_class' => 'menu',
    ...
    'link_after' => ''
    );
    return $args;
    }
    add_filter ('thematic_page_menu_args','maxelcat_page_menu_args');

    any of those should work, no need for all of them.

    Posted 1 year ago #
  3. Sorry about the "look" of my post - did try back ticks and ...

    function codeLook(){
    echo '<p>yippe I think I have it now</p>';
    }

    Thanks also for the really helpful answer. I see where I was going wrong - will try to see if I can work my way through your answers!

    Thanks!

    Posted 1 year ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.