Questions tagged [add-action]
29 questions
0
votes
0 answers
why does add_action or add_shortcode not create an instance of a class
I wanted to create an instance of a class when my program start add_shortcode(), but I find it not worked.
Does anyone can help me solve this problem?
The following is my code:
class Test{
private $infos;
function get_info() {
…

Ming
- 15
- 3
0
votes
1 answer
Add custom User role for woocommerce to Only Edit ORDERS
I wrote this code to create a custom user called "payment manager", this user should only edit/ view woo-commerce orders, Im have looked everywhere and didn't found any answer, see code:
function sitelab_simple_role() {
add_role(
…

Site Lab
- 35
- 5
0
votes
1 answer
wp_after_insert_post not triggering
I am trying to send an email after a new post has been created. It needs to be sent after the creation of the post, because I want to include the post category in the email. wp_after_insert_post does not seem to work, as no email is sent. I have…

JoelEng
- 51
- 1
- 4
0
votes
0 answers
add_action run for the specific page
Hi I have faced a problem on my code. I wanted to run add_action for the certain page. add_action is working individually when I Put this on the functions.php but when I tried to run this in wp_head action then its not working.
add_action(…

Kane
- 605
- 2
- 8
- 22
0
votes
1 answer
How to call a function in Woocommerce when order processing email is sent?
I would like to know if there is any way to call a function when a Woocommerce order is successfully placed and the processing order email is sent.
Thank you for your help!
0
votes
0 answers
Trigger event after change of variation WooCommerce
I have a price block for every single product page in the WooCommerce project. Like Cash Price, COD Price, PayPal, Stripe, etc.
Here what I want is to change this pricing based on the selected variation.
Ex: I have capacities like 32GB, 64GB,…

WP Learner
- 788
- 1
- 13
- 34
0
votes
1 answer
Wordpress: saving a taxonomy based on the value of a different taxonomy
We're building a clothing store. The products that will be uploaded could have label sizes from various countries, and as such we have two size taxonomies: product_size and product_size_uk.
I'm trying to set the uk size based upon the…

Austen Osborne
- 139
- 1
- 9
0
votes
2 answers
Wordpress : set a custom field in archive based on ACF date
I created a custom field ACF named "date_dexpiration" with format : d/m/Y H:i
When I create a new post with no expiration date, the field "date_dexpiration" is not fullfilled and stays empty.
I want in an archive (created with elementor posts…

Bruno Bros
- 87
- 1
- 9
0
votes
0 answers
creating child theme, some scripts and css file not loaded
I'm creating a child theme for an active template. have this code in functions.php file at child folder.

Somy J
- 173
- 1
- 3
- 22
0
votes
1 answer
Hooked function "is not defined"
For debug purposes in further development, I am trying to add a simple function to a WordPress site and execute it in the Firefox console.
As in https://developer.wordpress.org/reference/functions/add_action/, I put into functions.php of my OceanWP…

OpenUser
- 1
- 1
0
votes
0 answers
Wordpress filter locale and add_action->switch_to_locale
Changing locale via add_action->switch_to_locale works while add_filter doesn't.
add_filter
function change_locale( $locale ) {
if (is_singular()) {
global $post;
if(($post->ID=='1839') || ($post->ID=='577') || ($post->ID=='1346')){
…

Jadeye
- 3,551
- 4
- 47
- 63
0
votes
0 answers
Setting data for non existing pages (overriding 404's) in Wordpress
I have the following problem:
I have a couple of non-existing pages, for instance when there's 'detail' in the URL followed by an ID, as in mydomain.com/detail/12345/
In this case I am overriding the 404 with do_action, and including a template, as…

user3004118
- 125
- 3
- 13
0
votes
1 answer
Python: add entries to PyQt5 menu bar list
I wish to set the entries in an PyQt5 menu bar with a list of strings; the list can change.
Hard-coded from Qt Designer ui to py file, I have:
strList = ["1", "2", "3", "4" ]
self.action1 =…

oldHornPlayer
- 9
- 6
0
votes
1 answer
show category and tags when using register_post_type
So i used register_post_type to add books post_type section.
But i want to show category and tags(and more) on the back panel edit.php.
I know how to this(adding custom fields) in regular post.
add_action( 'init', 'bookworm_blog_cpt' );
function…

dede
- 19
- 5