Questions tagged [hooks]

Method by which plugins and themes extend core WordPress functionality.

Filter by
Sorted by
Tagged with
0
votes
1answer
27 views

Get terms of a taxonomy using useSelect

I'm developing a Gutenberg block and I need to show a dropdown with all the terms of a custom taxonomy in it. I'm using the useSelect hook for retrieving this data, but it's not working because it ...
1
vote
0answers
25 views

How to filter for user registration, be able to throw error message

I'm setting up a woocommerce/woprdpress site. Upon checkout, a user is created in the system. I want to take the user data and create the user in our external systems (both proprietary db and auth0). ...
0
votes
2answers
21 views

Restricting displayed posts to posts from only select authors

Is there any hook or filter I can use programmatically to restrict posts displayed in the frontend archives and in the dashboard to posts only from specified author ID's? We've been getting a lot of ...
0
votes
0answers
14 views

avoid subpage in function get_stylesheet_directory_uri() ,

to include a js file, i am using function wpb_hook_javascript() { wp_enqueue_script( 'cookieheader', get_stylesheet_directory_uri() . '/assets/cookie-script/cm-head.js',array(), '2.0.6', ...
0
votes
1answer
17 views

Auto-set a term's language upon creation (polylang)

I want to do a specific task each time a given term is created. My first approach was to do this via the addition of the following code into the main plugin file: add_action( 'created_term', ...
0
votes
1answer
49 views

wp_set_object_terms creates taxonomies but does not add custom posts to it

I am trying to call wp_set_object_terms in a function hooked to custom post creation (via wp_insert_post_data) to set taxonomies tags for the post from a custom field: $item_brand = ( ! empty( $_POST[ ...
0
votes
0answers
18 views

Is there a hook similar to “save_post” which only fires AFTER the post is completely published?

I am writing a plugin that involves fetching multiple images from an external server, uploading them into the Wordpress media gallery, then attaching them to a custom post type (Woocommerce product). ...
0
votes
0answers
20 views

Send a custom reminder email for woocommerce orders to logistic center after 4 hours if order is not cancelled [closed]

I have created my own function that customer can cancel their order within 4 hours after order created. But now what i want if customer not cancel the order, The logistic center(custom email) will ...
0
votes
1answer
20 views

Run command “composer install” when activating wordpress plugin

I want to run the command : "composer install --prefer-dist" in a wordpress plugin in the hook register_activation_hook to install the require vendors. But when I trying to activating the ...
0
votes
0answers
15 views

How can Use custom input field in functions.php page?

I have if clause to add action in functions.php page. But I want to give condition value from dashboard as a custom input instead of defining it functions.php. When I am trying 'echo get_field('...
0
votes
1answer
10 views

Missing variable options on add to cart form

I would like to display my add to cart doem in a modal but doing so make a part of becomes missing. I have variable products and the select field corresponding to the variation options is missing Here ...
0
votes
1answer
25 views

update_option_{$option} not working (do function after options are saved)

Below is my code for a simple plugin settings page. It works and saves an option ("EN", "CZ"). However, what I intend to do is run a function after the options get saved (see at ...
1
vote
1answer
13 views

Using a post-signup hook to get user details

Update: I got this working with a different hook user_register. It looks like wpmu_activate_user was never triggering. I would still like to have this happen after the user verifies and sets a ...
0
votes
1answer
19 views

How can I collect and output all attributes of all executed ShortCodes?

I would like to collect all attributes of the shortcodes that are stored in a page in the ShortCodes and then output them all. I do these in a Plugin. 1.) Set a global Variable in init.php ==> $...
0
votes
0answers
21 views

How to remove price column from vendor email?

I want to delete price column from Vendor Email Notification in WooCommerce. I need to update custom code into order-email-to-vendor.php Please advise proper way to update code into '...
0
votes
1answer
31 views

customer specific email attachment

I'm working on a website (client-side in Angular) and basically use WordPress as a “headless CMS” to be able to use useful plugins like “Woocomerce”. Problem: Based on customer input on the website, ...
0
votes
1answer
28 views

How to update global variables in plugin activation callback?

Sorry for being such a noob. I'm sure this is an easy question for most. I'm trying to register activation and deactivation hooks for my plugin. In the docs, they warn about the activation callback ...
1
vote
1answer
27 views

How do I target a single page to modify the comment form of only that page?

If I want to globally change the comment form for a theme I would use add_filter for "comment_form_default_fields". Then I might use add_action for "comment_form_logged_in_after" ...
0
votes
2answers
20 views

How to use a custom hook

I try to create and run a custom hook on my Wordpress site. In the header.php file I used do_action('somestuff'); On my home.php and page.php I does the add_action like add_action('somestuff', '...
0
votes
0answers
18 views

Forcing WooCommerce customers to create account before checking out

I'd like to force my site subscribers/members to create an account (and/or log in) before they can checkout. How would I go about doing this? I understand that I would be using something like '''...
0
votes
1answer
13 views

Woocommerce get_term_by() in transition_post_status hook doesn't works

Im having this code $concours_termine_cat = get_term_by('slug' , 'concours-termine' , 'product_cat'); get_term_by is returning false, after debugging the get_term_by function taxonomy_exists( '...
0
votes
0answers
13 views

Limiting search to html heading tags

Is there a way to limit the Wordpress search function to only search among headings (as in <h1> to <h6>)? Or, ideally, to search among headings and post titles? I basically want to exclude ...
0
votes
1answer
20 views

I would like to send a notification email (Asana) whenever something is published (posts, pages, custom post types) [duplicate]

The code below works perfectly When I create a new post, an email is sent out to the email included in the function. I would like to know how I can send an email when anything is published on the ...
0
votes
2answers
48 views

Use wp_head hook on template page

I try to use the hook wp_head on a template page but this does not work add_action('wp_head', 'to_head'); function to_head(){ //do stuff } I placed this code on a template part what is called by ...
0
votes
0answers
12 views

How to make a preloader to avoid flickering effect for my plugin?

I developed a WP plugin that displays a full screen content chat. Problem is: the post that includes that plugin first displays the content and then the plugin : that creates a nasty "flickering&...
0
votes
1answer
39 views

How to change footer credit text in Twenty Twenty One theme with a hook?

If I want to change the footer credits, I would usually copy the footer.php to a child theme and edit the following snippet: <div class="powered-by"> <?php printf( /*...
2
votes
2answers
27 views

enqueue hover function

I am trying to enqueue a hover function in my functios.php of my child theme, so that when hovering over a title, a div with a text will be visible. The code I am using is this: <?php add_action( '...
0
votes
0answers
13 views

Custom script/iframe after “Add to Cart” in WooCommerce for every product

I need to add a custom script/iframe for each product on a WordPress/WooCommerce site. I want it to show after the "Add to cart" button. I know I can use WooCommerce Hooks to perform this ...
0
votes
2answers
99 views

Add a counter beside menu item label

I'm using the following code to add a panel to the admin menu screen, so the users are able to add a Cart link to their menus: function my_add_meta_box() { add_meta_box( 'custom-meta-box', __( '...
0
votes
1answer
6 views

Add stuff above header edit form

I am searching for a hook that gives me the opportunity to add some stuff above the heading line in the edit page. I found these hook but this place some stuff between the heading and the title. ...
0
votes
0answers
20 views

Add content in cpt archive page

I am trying to add some custom content hooked into custom post type archive page but I can't. I have already achieved it in single page with: add_filter( 'the_content', 'yourprefix_add_to_content' ); ...
0
votes
1answer
30 views

Add html tot CPT edit screen - no metabox

Which hooks can I use to add my own HTML stuff to a CPT edit screen? I created an own CPT with $args = array ( 'labels' => array ( 'name' => 'Catalog', ), '...
0
votes
1answer
29 views

Set default value for “Additional CSS class(es)” for specific block types

For the columns block type, I'd like to add in a default value of wp-block-columns--padded in the "Additional CSS class(es)" field, the idea being that the user could remove or modify the ...
0
votes
0answers
42 views

add blacklist moderation list inside pre_comment_approved filter plugin

i am using Comment Whitelist plugin to create a whitelist of email domains for autoapporing comments. It seems that the plugin overrides wordpress : Settings->Discussion options->moderation ...
1
vote
1answer
41 views

Convert HTML Script to Shortcode [closed]

I want to convert this code into a shortcode from the Code Snippets plugin, I have seen an example come up but when I put it it does not work, the example is the following: add_shortcode( '...
0
votes
1answer
18 views

'wp' action hook not firing in admin and login?

I need to register an action via add_action('wp', function(){...}); The action works in frontend, but in backend and login page it doesn't work. It seems as if 'wp' hook doesn't exist for ...
0
votes
0answers
16 views

How Do I Modify the Post/Page Query used by the REST API?

I'm attempting to develop a simple access control plugin for WordPress which controls who has access to each post/page. I have used the template_redirect hook to check whether each user has access to ...
0
votes
1answer
21 views

Alternative Hook to the_content for Changing Background Color

I'm brand new at writing WordPress plugins and have tried to find which hook would be appropriate to use when changing the background color for front-end pages. I've tried the_content, stylesheet, and ...
0
votes
0answers
10 views

show it to members when there is a new post

I prepared a code, it works when there is a new post, but how do I show users that it is +1 each time a post is made, and if the user clicks on the list of posts, it will be deleted, then it will ...
0
votes
0answers
9 views

Alter the page title with a hook, without altering navigation links

I've written a basic function with the goal of altering the page title. It works. However, the new string also replaces every single navigation menu item on the page. At first I thought that might ...
0
votes
0answers
22 views

Custom field for Dokan booking product

Hi I have found a page (https://nayemdevs.com/how-to-add-a-new-field-on-product-upload-form-dokan-multivendor/) that shows a code to add, edit and show custom field in Dokan but it doesn't work on ...
3
votes
2answers
122 views

How to check if which hook triggered the call to a function?

I have a situation where I have a function hooked to more than one custom hooks. How to check in the callback function which custom hook triggered the call? Or the question in code will be add_action('...
0
votes
1answer
16 views

Add WordPress hook outside of Plugin or Theme

We have the following code that is used to hide our core theme so that it can't be enabled directly and you can only enable the child themes from the WordPress Dashboard. function hide_core_theme($...
0
votes
0answers
22 views

Wp_Schedule_Event every few minutes doesn't work

I wrote the folowing timer in my function.php file. It should be called every certain time (3 minutes) but it doesn't work at all. function myprefix_custom_cron_schedule( $schedules ) { $schedules['...
0
votes
0answers
12 views

What's the hook for modifying the html code added by Wordpress via Add Media Insert from URL?

Does anyone knows the Wordpress hook used to modify the HTML code generated by WP's Add Media -> Insert from URL -> Insert Into Post function. To clarify myself, let's say I want to add a media ...
0
votes
1answer
46 views

How to hook code in <body>?

In the question How to add code to Header.php in a child theme?, a recommended solution is to create a plugin, then hook into wp_head action by using this code: add_action('wp_head', '...
2
votes
2answers
144 views

Hooking new functions to actions + passing parameters

I am trying to understand some fundamentals of php with regards to adding new functions to actions. I found a tutorial where he adds a new function to the save_post action… add_action('save_post', '...
1
vote
1answer
36 views

Using wp_editor tinyMCE in metabox cause form alert on leaving page

Using tinyMCE as wp_editor in a custom post type metabox create an alert when I try to submit or If I want to change location I don't have such behavior using Quicktags, but since TinyMCE is easier ...
0
votes
0answers
19 views

Unpublished Pages Failing To Appear On Custom Path

The Context I have a domain, we'll call it example.com, where traffic travelling to this domain first hits a reverse proxy and depending on the path it is directed to two different containers. Traffic ...
1
vote
0answers
23 views

Map a custom id to wordpress post id

I am new to Wordpress and wondering what the best way might be to go about doing this. We have a requirement to map our own id (known as friendly_id) to the Wordpress's post id. The idea is to import ...

1
2 3 4 5
43