Tag Info

New answers tagged

1

have a look this plugin Simply Show Hooks which will show you where all the action and filter hooks are, inline, in order, on the page you're looking at, and all the actions or filter functions that have been hooked to them. You can see in the screenshot how it does it. It does just what you've asked.


3

First thing to mention is that you don't need to use wp_register_style if enqueuing within the same function. You can replace it with wp_enqueue_style and remove the duplicate. As for why your stylesheet isn't loading, start by checking the file path. Try this instead: wp_enqueue_style('cl-chanimal-styles', plugin_dir_url( __FILE__ ) . ...


0

Okay, for anyone looking to include the WooCommerce review tab not on an actual single-product page here's the secret sauce: In your template file, you need: global $withcomments; $withcomments = true; Then add a filter for the comments template: //add filter to use our custom review template add_filter('comments_template','{{YOUR_HELPER_FUNCTION}}'); ...


0

You don't echo content from a filter, you return it. You should have: function addOptions($post_id){ $post = get_post($post_id); return $post_id; } add_filter('mbdb_book_grid_after_link','addOptions'); See: http://wordpress.stackexchange.com/a/113760/21376


1

As I said in the question post, I finally solved it by looking into the $_POST global. There's a $_POST['sticky'] field (valued as 'sticky') that is there just when a Post is sticky or is being made sticky, and it's not when a post is not sticky or is being unsticked.


0

You cannot pass absolute URLs in WordPress. Use ajax_for_frontend.ajaxurl in place of absolute URL. Try using this (untested) - jQuery(document).ready(function() { var numberOfPromos = 4; jQuery.ajax({ url: ajax_for_frontend.ajaxurl, type: 'post', data: { action: 'get_number_of_promos', }, ...


4

This wordpress plugin Simply Show Hooks will show you where all the action and filter hooks are, inline, in order, on the page you're looking at. You can see in the screenshot how it does it. One click to switch it on/off so you can quickly find the action of filter hook you're looking for.


0

init runs before admin_init There's different ways to verify this using code or a plugin.


0

Generally after_setup_theme is the first action hook available to themes, triggered immediately after the active theme's functions.php file is loaded. At this stage, the current user is not yet authenticated.


0

You can use the the_permalink filter to modify permalinks. Take a look at the function reference for the same. Code sample from the docs: Append the query string for the current page to permalink URLs function append_query_string($url) { return add_query_arg($_GET, $url); } add_filter('the_permalink', 'append_query_string'); More information ...


0

woocommerce_before_main_content is not a filter hook, it's an action hook, so don't expect it to return something, because nothing cares about what an action hook callback function returns, whereas for filters hooks, you will always see something waiting for the returned result: // Action hook do_action('foo_action'); // Filter hook $bar = ...


0

Well, when exactly do you consider the page to be "starting to load"? get_header() is typically the first function to fire as the html of a theme is starting to generated. It fires the get_header action. Numerous hooks fire prior to that, at different points, the very earliest being muplugins_loaded I believe. wp_loaded, by the way, is not when the page ...


6

There is no special hook to author change. But you can achieve it by using post_updated hook. Example: add_action('post_updated', 'prefix_on_update_author', 10, 3); function prefix_on_update_author($post_ID, $post_after, $post_before) { if ($post_after->post_author != $post_before->post_author) { // author has been changed // ...


0

Yes, it is quite simple, you just need to work in PHP. Consider you have 36 posts in a loop. $div_html_1 = ''; $div_html_2 = ''; $div_html_3 = ''; $div_html_4 = ''; $div_html_5 = ''; $div_html_6 = ''; if ( have_posts() ) { while ( have_posts() ) { if( category of post == division 1 ) { $div_html_1 .= "Your HTML ...


0

In a WordPress footer hooks are different for back-end(dashboard) and front-end. In Dashboard use "admin_footer" hook. In Front-end use "wp_footer" hook.


0

With such a general function name like method() a collision could be happening. Try something a little more unique than that. Also, if you have access to the server you could also print it to the error log so you don't have to worry when the page is being rendered.


6

You could hook into the action switch_blog. You get the new blog ID as the first argument here. But loading the complete translation files here is expensive, you also have to restore the old files after that. WordPress does not use native gettext functions, but some custom code that is much slower. See #17268. The performance penalty for that would be huge. ...


0

The Correct syntax for writing a add_filter // Define the woocommerce_short_description callback function filter_woocommerce_short_description( $post_excerpt ) { // make filter magic happen here... return $post_excerpt; }; // add the filter add_filter( 'woocommerce_short_description',filter_woocommerce_short_description',10, 1 ); Your code ...


1

This one is actually surprisingly simple; add this to your wp-config.php file and all automatic updates will be blocked when outside of the specified hours: // Suspend updates when outside of business hours, 9:00 AM to 5:30 PM $updates_suspended = (date('Hi') < 0900 || date('Hi') > 1730); define( 'AUTOMATIC_UPDATER_DISABLED', $updates_suspended ); ...


1

If you are using the save_post action hook; then you can prevent the code from executing during an autosave with the following conditional: function do_not_autosave( $post ) { // Check to see if we are autosaving if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; // Rest of the code here } add_action( 'save_post', ...


0

You will need to know WordPress hooks and their uses. for list of hooks please find Where can I find a list of WordPress hooks?


0

You hadn't included how had you arrived at this concept, but the whole "presets" branch of logic is pretty strange. Post-filtering vs pre-filtering WordPress filters are de-facto centered on filtering results. Your my_plugin_get_options filter follows that model — the results are produced and offered for modification. Sometimes that is undesirable, what ...


-1

You should wrap your function in parent theme like this, not in child theme function.php if (!function_exists('TaskerDev_get_first_post_image_fnc') ){ function TaskerDev_get_first_post_image_fnc($pid, $w = 100, $h = 100) { //Parent theme code here } }


0

If you're not in The Loop, you should pass an ID to is_sticky(): static function addOrUpdate($post){ $type = self::_index(true)->getType($post->post_type); $data = self::_build_document($post); //filling $data with extra fields I'd like to index $data['is_sticky'] = is_sticky( $post->ID ); //now the document is added to ...


0

As @passatgt stated there are at least 4 actions to hook. Btw the most useful is "delete_$taxonomy" action. The action accepts 3 parameters. To use all of them you have to explicit declare how many parameters you want to receive in the callback function. You can do this by specifing it as 3rd parameter of add_action ...


0

You need to run this code before any headers are sent to the client. Try segregating the login code. This question is almost a year old, so please let us know what, if anything worked.



Top 50 recent answers are included