Tag Info

New answers tagged

0

You have some errors in your code. For example, you unset a not defined variable. Some lines bellow you try to use again a not defined variable....maybe this is what is causing the problems. Can you try this? (Edited, I think is better get_posts than new WP_Query in this case) function wpse_update_postmeta($post_id) { if (defined('DOING_AUTOSAVE') ...


0

wp_trash_post is literal, not dynamic. It doesn't change and always ends in _post regardless of actual post type. See wp_trash_post(): do_action( 'wp_trash_post', $post_id ); You also should retrieve post and check its type from $post_id, do not use globals in that fashion because they might refer to entirely different post. Your second theory refers to ...


-1

also try "load-post-new.php" for new pages


0

Personally I would use wp_get_current_user(), no globals: function plugin_admin_init() { $user = wp_get_current_user(); }


1

Maybe you use the hook deleted_post and create a rewrite. The hook runs just after a post or page is deleted. Action function arguments is post- or page-ID.


1

The problem is that you can't distinguish form an anonymous function and another, so yes, it is possible to remove a closure (i.e. anonymous function) but if more than one closure act on same filter at same priority you have to make a choice, remove them all, ore remove only one (without knowing exactly which). I'll show how to remove them all using a ...


2

Scripts and stylesheets should always be loaded in the head or in the footer via the wp_enqueue_scripts action hook. wp_enqueue_scripts is the proper hook to use when enqueuing items that are meant to appear on the front end The init hook executes before wp_head which is to early for script to load in the header. The wp_enqueue_scripts action hook is ...


2

You should first load your scripts with a hook on wp_enqueue_scripts like this for example : add_action( 'wp_enqueue_scripts', 'load_my_scripts' ); function load_my_scripts() { wp_enqueue_script( 'jquery' ); } What I like to do is, register my script with a hook on init and then enqueue them with a hook on wp_enqueue_scripts: // Register Scripts ...


1

setup_theme run on init theme, before after_setup_theme. The follow order on frontend, was fired in my test: load_textdomain plugins_loaded auth_cookie_valid set_current_user sanitize_comment_cookies setup_theme after_setup_theme init


3

'the_posts' is an action fired everytime WP_Query get posts, for main query and for other secondary queries, so when you do something like: $foo = new WP_Query($args); in a widget or elsewhere (shortcode, related posts...) 'the_posts' is triggered again. However there is only one main query, so you can use a conditional and do what you do only if the ...


0

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


1

In your code, you are executing get_post_types() before the post type is registered. Try, for example, this: function test(){ $args = array( 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'exclude_from_search' => true, ...


1

What if you add your filter, with the priority 11, so it goes after? That's ugly, but might work in your case. add_filter( 'manage_edit-comments_columns', function( $default ) { unset( $default['smr_comment_rate'] ); return $default; }, 11, 1 );



Top 50 recent answers are included