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

Why is the use of @uses tag in docblocks discouraged?

I’m not 100% sure but I guess it’s because usage of @uses can be covered with @see From phpDocumentor docs @uses is very similar to @see, see the documentation for @see for details on format and structure. The @uses tag differs from @see in two ways. @see is a one-way link, meaning the documentation containing … 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

Is the codex no longer actively maintained?

(hmm this is somewhat off-topic, but will let others decide on it) Better answer Although it is hard to track official announcement, as @darmb pointed out in the comments there are indications that the official documentation effort is drifting away from the codex in favor of the developer site, and the “make” blogs/sites. So in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)