Use external link in the add sub menu

Last argument of function add_submenu_page is the name of the function to call when display the content of the page. As described here: http://codex.wordpress.org/Function_Reference/add_submenu_page The right use is: add_submenu_page( ‘antify’, ‘Plugins’, ‘Plugins’, ‘manage_options’, ‘plugins’, ‘my_function’ ); function my_function(){ echo ‘hello’; } If you want a separate file you can do this add_submenu_page( ‘antify’, ‘Plugins’, ‘Plugins’, … Read more

How to Remove a Filter from the Admin List Table?

I can see that it’s implemented inside the class WC_Admin_List_Table_Orders which extends WC_Admin_List_Table. Yes, that’s correct. And the orders list table is setup via WC_Admin_Post_Types::setup_screen() where the method is called via these hooks: (see WC_Admin_Post_Types::__construct()) // Load correct list table classes for current screen. add_action( ‘current_screen’, array( $this, ‘setup_screen’ ) ); add_action( ‘check_ajax_referer’, array( $this, … Read more

Use wc_enqueue_js only on specific pages – nested add_action

No idea why, but for the second snippet, changing the priority of the nested add_action from the default (10) to 20, causing the parent and child add_action to have a different priority solved the problem and now everything works perfectly: add_action( ‘template_redirect’, function() use ( $args ) { acau_enqueue_script ( $args ); }, 20); The … Read more

action init hook and get_post_types

Because you calling get_post_types() in functions.php that is excuted before ‘init’ action. Look this picture http://www.rarst.net/images/wordpress_core_load.png if you add an echo inside function test function test(){ $args = array( ‘public’ => true, ‘publicly_queryable’ => true, ‘show_ui’ => true, ‘query_var’ => true, ‘exclude_from_search’ => true, ‘hierarchical’ => false, ‘has_archive’ => false, ); register_post_type( ‘test’, $args ); … Read more

prevent post submission

See the Codex, on save_post. In answer to Question 1, it is fired whenever WordPress auto_saves a revision (i.e. hence when a post is edited). In particular, when creating a new post, wp-admin/post-new.php is loaded. WordPress then creates an auto draft even if you haven’t saved a draft or published to post. This is intended … Read more

I don’t understand why I need a lower priority to remove an action with a higher priority to make it work

You’re misunderstanding how priority works here somewhat. The priority determines the order that the functions run for a given hook, eg. genesis_entry_header. Priority is not global. When removing an action from a hook you need to use the same priority that the action was originally hooked with. Which you’re doing. You’re adding the action at … Read more

How to remove an action added by a child theme of Genesis

Thanks to Dan that commented with a useful post I found on Google but didn’t read with the required attention, the solution is this: function my_remove() { remove_action( ‘genesis_entry_header’, ‘shq_genestrap_post_meta_categories’, 9 ); } add_action(‘genesis_entry_header’, ‘my_remove’, 8); Using priority 9 in add_action() doesn’t work: I had to set a priority lower than the one used to … Read more

Display different number of posts from one category on the different pages

You can check for the existence of a variable, so you don’t overwrite it: add_action( ‘pre_get_posts’, ‘wpse7262_pre_get_posts’ ); function wpse7262_pre_get_posts( &$wp_query ) { if ( $wp_query->is_category() ) { if ( ! array_key_exists( ‘post_type’, $wp_query->query_vars ) ) { $wp_query->set( ‘post_type’, ‘game’ ); } if ( ! array_key_exists( ‘posts_per_page’, $wp_query->query_vars ) ) { $wp_query->set( ‘posts_per_page’, 9 ); … Read more

Prevent function from triggering again when post in specific category gets another category?

We can utilize the add_term_relationship action to check if the current post is already assigned as popular. add_term_relationship fires before a term is inserted. I also think that you are using the wrong hook here to send your mail on. added_term_relationship fires quite early before any error checking. You can still encounter a failure after … Read more