Questions tagged [hook-wordpress]
54 questions
19
votes
6 answers
How to get post author name in WordPress?
In WordPress I need to fetch name of author who created post using author_id.
How can I find author_name ?

Rakhi Prajapati
- 880
- 1
- 12
- 24
9
votes
2 answers
Adding "Sale" product category to products that are on sale in Woocommerce
As part of a WooCommerce site I want to have a sale page that lists sale items (with pagination and filtering). I think the best way to do this is to have a 'Sale' category that is added automatically to any posts that are part of the sale (as…

AndrewIanHalloway
- 106
- 1
- 5
6
votes
3 answers
Check if cart is NOT empty in Woocommerce 3
I can' figure this out, how to check if cart is empty. What am I doing wrong?
My code:
add_action( 'wp_footer', 'redirecionar' );
function redirecionar(){
global $woocommerce;
if ( is_page('carrinho-de-compras') and…
user5483053
5
votes
1 answer
Run a function on custom button click in woocommerce admin order page
Based on "Add a button on top of admin orders list in woocommerce" answer code, I was able to add a custom button on woocommerce admin orders list.
Here is that code (lightly customized):
add_action( 'manage_posts_extra_tablenav',…

Vincenzo Di Gaetano
- 3,892
- 3
- 13
- 32
3
votes
2 answers
How to add a script at the beginning of the tag before all other scripts in WordPress
I've been looking for a few days in the stack overflow here but I can't find the answer to my problem. I'm trying to add the Cookie Yes script, to insert the cookie banner on my WordPress site. The script must be loaded at the beginning of the tag…

Carlo Alberto
- 41
- 5
3
votes
1 answer
How to Set Notification Email in WordPress for Fatal Error Handler (WSoD)
WordPress 5.2 integrated WSoD protection which by default it will send an email notification to admin when the site encounters some fatal error. I had built my client a site which I would like to monitor such error in case it happens, but I dont…

HW Siew
- 973
- 8
- 16
3
votes
3 answers
WooCommerce - My Account - logout and redirect to Homepage
Once a user is in their My Account page on WooCommerce I'd like them to hit logout and be redirected to my Homepage rather than end up on the login page.

Rich72
- 63
- 1
- 1
- 4
3
votes
1 answer
Exclude multiple custom taxonomies terms from Wordpress search
I am excluding from Wordpress search results any posts or custom posts with custom taxonomies set to specific terms. I want to be able to add more taxonomies and terms simply (like in an array) without having the duplicate the function, and ensure…

Asher Black
- 77
- 6
3
votes
2 answers
Adding a hook to "Place order" button in woocommerce
When the user gets to the checkout, there is a button , the "Place order" button at the bottom of the form. I have been trying to add a hook to this button in woocommerce, but I don't seem to find the correct one, I have tried…

MariaZ
- 1,677
- 9
- 25
- 41
2
votes
1 answer
Generate WooCommerce coupon when comment review is approved
I'm trying to generate a coupon code for customer once his review comment in woocommerce product is approved. I have the whole code ready but once comment is approved nothing happen.
My code only works with comment_post hook but not with the…

Lubo Masura
- 1,034
- 6
- 20
2
votes
1 answer
Set a default value for "number of items per page" in WooCommerce admin product list
WordPress allows each user to set his own value for "Number of items per page" in the Admin Products Page /wp-admin/edit.php?post_type=product.
I'm looking for a code to set the same value for "Number of items per page" for all users regardless of…

JPashs
- 13,044
- 10
- 42
- 65
2
votes
0 answers
How to call Woocommerce Class function from functions.php?
Woocommerce has a built in class (WC_Structured_Data) to genrate strucured data into product pages. This class or function is tied to woocommerce_single_product_summary action but it is missing from my temaplte file for some reason.
I am trying to…

nattila
- 31
- 3
2
votes
1 answer
When exactly woocommerce/wordpress hooks are called?
I know there are hundreds of action hooks available in Wordpress and in Woocommerce plugin, but what is most confusing to me is: when exactly they are invoked?
For some of the hooks there are some information available in the internet, but for many…

user2679476
- 365
- 3
- 12
2
votes
1 answer
Which available hook after products bulk save is completed in Woocommerce
I have customized the bulk edit functionality using
add_action('woocommerce_product_bulk_edit_start', function () {
// ...
}, 10, 0);
add_action('woocommerce_product_bulk_edit_save', function ($product) {
// ...
}, 10, 1);
I would like to…

mike.bronner
- 1,203
- 1
- 20
- 39
2
votes
1 answer
Hooks and their hooked functions execution queue in Wordpress and Woocommerce
I am new to Wordpress/WooCommerce and PHP, although I have experience in other web platforms and languages. I have searched, but have not found the answer to my question which is...
Are hooks that are created by the "add_action" "added" to the list…

Eric B
- 91
- 2
- 9