Add_action to wp_head via functions.php

The reason the code posted is not working is that $post is not referencing the global $post variable, which is the goal here. Using get_the_ID() is a good way of accessing the ID associated with the current post. That’s how I’d suggest doing it, but there are other ways too: add_action ( ‘wp_head’, ‘hook_inHeader’ ); … Read more

Earliest hook to reliably get $post/$posts

For all admin pages and front end pages except individual post edit screens (wp-admin/post.php), ‘wp’ is the most reliable hook for getting the global values. http://phpxref.ftwr.co.uk/wordpress/nav.html?wp-includes/class-wp.php.source.html#l486 You can see there that it fires immediately after WP::main() fires WP::register_globals(). The problem with using things like post_results and get_posts is that it will run every time you … Read more

Filter specific shortcode output?

There is no filter that I know of that is meant to target individual shortcodes like you want. You can filter attributes with shortcode_atts_{$shortcode} though. You can hijack another shortcode by creating your own callback and registering it with the original shortcode slug. I think that is what you are probably going to need to … Read more

Add a new tab to WordPress Plugin install Listing

There is the filter: “views_plugin-install” (see here). You can find it in /wp-admin/includes/class-wp-plugin-install-list-table.php (currently) at line 226: $views = apply_filters( “views_{$this->screen->id}”, $views ); Use it like: add_filter( ‘views_plugin-install’, ‘my_filter’, 10, 1 ); function my_filter( $views ){ //Do your stuff return $views; }

How many filter/action hooks are healthy?

As long as hooks don’t have anything hooked to them they are no-ops, that is do nearly nothing and have no considerable effect on runtime. It gets quite different when things are hooked and there are a lot of calls. Since you talk about customizing strings the good example would be gettext hook in core. … Read more

Please explain how these hooks work

It is possible for action hooks to be provided without being used, which is what’s happening here. woocommerce_before_checkout_process and woocommerce_checkout_process are hooks provided by WooCommerce, but WooCommerce does not itself attach callback functions to either of these hooks. They are provided to allow plugins and themes to run code at the time that the respective … Read more

Count & Display Database Queries

You can paste this block of code in your currently active WordPress theme functions.php file: function wpse_footer_db_queries(){ echo ‘<!– ‘.get_num_queries().’ queries in ‘.timer_stop(0).’ seconds. –>’.PHP_EOL; } add_action(‘wp_footer’, ‘wpse_footer_db_queries’); The above block of code, will render an HTML comment in the footer of your theme (before </body> and </html>, containing the number of database queries and … Read more

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