Tag Info

Hot answers tagged

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


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


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


1

Where are you calling add_action()? If it's in a place where you're already outputting HTML, it's too late, and that's probably a place that wont even be looked at during an AJAX request. You should include that code in your theme's functions.php file, or as early as possible in a plugin.


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


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


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



Only top voted, non community-wiki answers of a minimum length are eligible