Which action to hook wp_enqueue_script to? wp_head or wp_enqueue_scripts? [duplicate]

I took a long time figure out the right way for this! Here’s what I follow now: Use case: In a plugin’s admin page Hook: admin_print_scripts-<page hook> OR <the php file name for your plugin> $hook = add_menu_page(…) / add_submenu_page(…); add_action(‘admin_print_scripts-‘.$hook, ‘my_callback’); Use case: On all admin pages Hook: admin_print_scripts add_action(‘admin_print_scripts’, ‘my_callback’); Use case: On … Read more

What does the raw value for the get_bloginfo’s filter argument exactly do?

We have the following filters added by default (source) add_filter( ‘bloginfo’, ‘wptexturize’ ); add_filter( ‘bloginfo’, ‘convert_chars’ ); add_filter( ‘bloginfo’, ‘esc_html’ ); The bloginfo filter (source) is applied on the get_bloginfo() output, in the display mode, except for the url that has it’s own bloginfo_url filter. The core isn’t using that url filter currently and there’s … Read more

Different number of posts in each category

As @StephenHarris pointed out there’s also the pre_get_posts filter. function hwl_home_pagesize( $query ) { if ( is_category( 9 ) ) { // If you want “posts per page” $query->query_vars[‘posts_per_page’] = 1; return; } if ( is_category( ‘movie’ ) ) { // If you want “showposts” $query->query_vars[‘showposts’] = 50; return; } } add_action( ‘pre_get_posts’, ‘hwl_home_pagesize’, 1 … Read more

Add Option if Not Exists

The logic on the IF THEN ELSE does seem a bit wonky. If I’m reading it correctly… The call to get_option( $option_name ) will return FALSE if the option does not exist or if it has no value. So the IF would be executed: when the option doesn’t exist and $new_value != FALSE the option … Read more

Issues enqueueing parent & child theme stylesheets with revised Codex method

QUESTION 1 Is it safe to include the assumption that parent themes properly enqueue the child theme styles, from the standpoint of child theme standards? General rule of thumb, yes. But, you should never assume. Most disasters and failures in live are due to assumptions or facts based on an assumption FACTS WITHOUT ASSUMPTIONS A … Read more

What does is_page_template() compare against?

Your condition should be written like this: if (is_page_template(‘path/file.php’)) { // Do stuff } I believe the confusion is a result of two things: The docs refer to “name” ambiguously. Specifying “file name” would make the documentation much more clear. The code behind is_page_template() shows the get_page_template_slug() function at its core. This function actually returns … Read more