Questions tagged [hooks]

Method by which plugins and themes extend core WordPress functionality.

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

Using "add_image_size" to register custom image sizes inside plugins not working

I noticed that most examples of add_image_size() is done via the after_setup_theme hook. Which means, for it to register, one has to switch theme and reactivate the theme. Which is not ideal for me as ...
user avatar
  • 139
1 vote
1 answer
19 views

Send retrieve password notification email with custom HTML email template

How to send custom HTML email for reset password? I know there will be a hook for that (retrieve_password_notification_email) But how to use it? Requesting for an example ...
user avatar
0 votes
0 answers
11 views

Customize Widget Navigation

How is it possible to customize the footer menu that has been added via widget and not defined in the functions file? I'm looking for a way to remove the container and add a predefined icon for the ...
user avatar
1 vote
1 answer
52 views

WordPress Hooks : Where to place callbacks that repetitively yield the same effect?

To give you the context first: Let's say you create a custom plugin by yourself. That plugin has for example: A) 30 different endpoints / REST calls, B) adds 15 different admin pages to the wp-admin, ...
user avatar
  • 359
2 votes
0 answers
23 views

How can I get a plugin to hook 'dbdelta_queries' -- a filter used during version update?

I have a plugin where I want to intercept database changes made during the upgrade process. It looks like the WordPress Way to do this is with the 'dbdelta_queries' filter. The trouble is, my plugin'...
user avatar
  • 457
0 votes
2 answers
19 views

upgrader_process_complete filter not fired using ajax updates

a very specific question about upgrader_process_complete filter (but also upgrader_post_install). I must call some functions whenever specific themes/plugins are updated. The code works perfectly when ...
user avatar
  • 351
1 vote
1 answer
137 views

How to execute a hook asynchronously?

I have a function to send user data to a google sheet whenever the user's profile gets updated: add_action('profile_update','send_user_data_to_google_sheet') function send_user_data_to_google_sheet(){ ...
user avatar
  • 129
0 votes
0 answers
26 views

Is there any reason for the nested filters to be applied on the first case and not in the second one?

// This Works -> Filters are applied add_action( 'current_screen', function(){ $type = get_current_screen()->post_type; if(is_admin()){ // "true" add_filter('...
user avatar
0 votes
0 answers
22 views

How to debug wordpress hooked functions?

I need to hide shipping method from checkout if certain items arent in stock. I found everything i need to do it. But.. When i'm trying to hook function and hide shipping method i see that nothing ...
user avatar
1 vote
1 answer
24 views

Getting the post ID in parse_query

I am creating a multilingual site, and trying to hook on to parse_query to throw a 404 if a specific translation doesn't exist (I have my own function to do the actual checking). I can successfully ...
user avatar
  • 21
2 votes
2 answers
100 views

Hook for inserting?

I'm using a plugin that doesn't provide many hooks for its actions. I would like to be able to hook in when the plugin adds a row to a plugin-specific table, and update some other data elsewhere. (For ...
user avatar
  • 8,746
0 votes
0 answers
14 views

Elementor posts custom query based on tag [closed]

How can I filter the Elementor Posts widget with a custom php query that returns posts with a specific tag attached? I want to do something similar to this: function my_query_by_post_types( $query ) { ...
user avatar
0 votes
0 answers
42 views

Print on screen during shutdown hook - error during saving in theme-editor.php

I'm trying to use this sample php code added to my funcion.php file: function echo_shutdown(){ echo 'test'; } add_action( 'shutdown', 'echo_shutdown', 10 ); It works, i can see "test" at ...
user avatar
0 votes
0 answers
11 views

Hooking save_post breaks check for term in added_term_relationship hook?

I have a feature that relies on checking if a term exists on a post when certain hooks fire. I added a callback to the added_term_relationship hook which uses has_term to check for the presence of the ...
user avatar
0 votes
1 answer
23 views

Hook a script as the very last one before the closing body tag

I'm trying to add a script in the very last position before the closing via function.php Other scripts are hooked by other plugins, so WP is placing my script as the firts one of the list. Like: [my ...
user avatar
0 votes
2 answers
50 views

Is it possible to add the_content filter upon login?

I've added a wp_login action and it's getting executed. Then within that function, I'm adding a filter to the_content so that a script gets inserted upon certain conditions but it's not getting ...
user avatar
  • 1
0 votes
0 answers
15 views

Why does "updated_post_meta" did not fire when uploading media other than image?

I am testing out the "updated_post_meta" hook by uploading items to media. I have notice that the hook is not firing if I am uploading files other than image. So I check the post_meta table ...
user avatar
0 votes
0 answers
21 views

Build a must-use plugin that tracks when other plugins are activated or deactivated

Here I am trying to utilize add_action to add a callback function to the hooked action of 'deactivate_plugin', but my function is not echoing as I expect. $plugin = 'polls_plugin';<br> function ...
user avatar
  • 1
0 votes
1 answer
35 views

Add action save post when create and publish

I try to use the hook save_post in my wp but I have a problem. I do this : function when_save_post_match($post_id, $post){ if (isset($post->post_status) && 'auto-draft' == $post->...
user avatar
  • 1
0 votes
0 answers
22 views

Trigger a JavaScript function based on the data fetched from Woo commerce hook

I have read quite a lot of possible ways to do it but after going through each of them I'm still not able to understand what should be the correct way of doing it and how the correct way works. ...
user avatar
0 votes
1 answer
23 views

Conditionally run function based on custom meta value?

I’m looking for a way to conditionally display an image within certain Woocommerce hooks that I choose based on whether a value is true within a custom meta field for the products on my site. For ...
user avatar
0 votes
1 answer
31 views

Hook before user is created and make some custom validation

I try to hook in user creation process in admin dashboard /wp/wp-admin/user-new.php to make some custom validation on data with the following hook, but the hook is not executed on form submit. What ...
user avatar
  • 824
0 votes
0 answers
47 views

manage_shop_order_posts_custom_column() hook is Not working In Functions.php file in my WordPress active theme

As I added the manage_shop_order_posts_custom_column() hook in the functions.php file But the custom column post data not showing on the shop_order page. manage_edit-shop_order_columns Filter is ...
user avatar
1 vote
1 answer
29 views

Is there a JavaScript equivalent of get_post_field?

I recently installed @wordpress/hooks so that I could use applyFilters on the react side of my plugin, but I'm looking for something for get_post_field as well. I haven't seen it in any of the NPM ...
user avatar
1 vote
1 answer
32 views

Append a code when at the current page in wp_list_pages()

I'm using wp_list_pages() to show pages and subpages in a tree view and I need to add a "read more" as a sub-item right after the current page. Example: We are at the "Page tree" ...
user avatar
  • 1,218
0 votes
1 answer
12 views

How to remove js ui library added by default by wordpress

I am trying to remove some script files added by wordpress. However, the code I wrote does not work. Where am I doing wrong? Can you show me the way? I looked at many sources. But I couldn't find an ...
user avatar
0 votes
0 answers
19 views

Display custom product option in admin order details

I'm trying to display the custom product option in admin order panel. I was able to pass all the data until the order is completed, but in the admin panel the data is returned is empty array. I share ...
user avatar
0 votes
0 answers
30 views

change wordpress pagination url after doing the request

I'm working with Wordpress pagination, I want to modify the returned URL when I click on a pagination link (number 2 for example in the pagination), at the moment I get: https://magicpallet.com/blog-2/...
user avatar
  • 3
1 vote
1 answer
43 views

What is the "correct" way to add hooks or similar PHP behavior to a blocktheme?

I'm building a new site and I wanted to build my theme from scratch. However, the WordPress ecosystem is moving more towards blocks and blockthemes. As far as I can tell, it is possible to put hooks (...
user avatar
0 votes
0 answers
120 views

Change Dashboard URL from wp-admin to wp-admin/index.php

Can anyone get me the solution to change WordPress Dashboard URL from wp-admin to wp-admin/index.php? I am getting a timeout error to access the Dashboard by using this URL https://my-site-url/wp-...
user avatar
0 votes
1 answer
21 views

Restrict editing of post type to list stored in user meta

What is the right action to invoke before a custom post type is getting edited in dashboard and contains the argument the post id? The url /wp-admin/post.php?post=282&action=edit&classic-...
user avatar
  • 824
0 votes
0 answers
21 views

Limiting actions only to edit.php page for specific custom post type

Excuse me if something like this has been asked before. So, I'm trying to alter the query which displays the posts of a custom post type, but on the admin side, more precisely, the edit.php page. This ...
user avatar
  • 13
0 votes
2 answers
72 views

How to stop execution of a function via add_action hook?

I have the following functions: function test($post_id){ do_action('test_action',$post_id); echo $post_id; } add_action('test_action',function($post_id){ if ( $post_id == 2 ) //Stop test function ...
user avatar
  • 83
0 votes
0 answers
33 views

Creating posts with links from a txt file

I have a script which scrapes articles from the web and saves the url to a .txt file. I've created a custom plugin which on activation, loops through the urls and creates a draft post with the content ...
user avatar
0 votes
0 answers
60 views

WP_Query retuning empty array in rest api

I recently started writing a rest api for my plugin. I need to access some custom posts however WP_Query is returning an empty array when I'm querying the db. There is the custom post type declaration....
user avatar
  • 1
0 votes
0 answers
11 views

Same URL for portfolio and for a page creates 404 error. Is there any filter that i can use for a child page?

What I try to achieve is to have the portfolio slug as a page slug also, and when I will assign the page as a parent to another, then that page must look for a specific page's parent ID and return the ...
user avatar
  • 11
2 votes
1 answer
110 views

Find variables available at a given hook

I'm hoping for a simple way to tell/find/echo what the available arguments are available for use at a given hook. For example — function example_function($something){ //do stuff with $something ...
user avatar
  • 123
-1 votes
1 answer
34 views

WordPress blocking polling request when signed into Admin

I've setup a polling script in js that sends an XMLHttpRequest to the server to wp-admin/admin-ajax.php (yes, legacy, I know) at a fixed interval of x seconds. The response returned by that request ...
user avatar
  • 359
0 votes
0 answers
16 views

Custom Header added within Dashboard pages, is this possible with custom template files?

I created a custom template and called it Header Home"header-home.php" <?php /** * Template Name: Header Home */ ?> <?php if( have_post() ) { while( have_post() ){ ...
user avatar
0 votes
0 answers
27 views

save_post trigerred twice

I am trying to add more functionality to the update button. My end result is that I wish to call a python script but for now I am messing around with writing a log file. This is resulting in the log ...
user avatar
  • 1
0 votes
1 answer
26 views

How to remove the message 'We could not find any results for your search' without changing template files and without adding posts/pages?

I take the question back with context. The goal is not to add posts or pages so that the post is replaced by the title of the post/page. The goal is not to modify the search.php file to remove this ...
user avatar
0 votes
0 answers
12 views

Set the payment processor callbacks to a plugin

We need for our Wordpress page a plugin which processes in certain situations the payments independently from the regular check-out page. Normally, a payment processor like PayPal, Stripe and others, ...
user avatar
0 votes
0 answers
26 views

Hooking after blog info update

I've been unsuccesfully looking for a way to hook into the "site information" update action. With "site information update", I mean when the blog's admin changes its title, ...
user avatar
  • 1
0 votes
1 answer
63 views

How to sort WooCommerce products page by latest in-stock items first?

How to sort the WooCommerce products page by latest in-stock items first and all the out-of-stock items to the last? Currently, I'm using a code snippet from "https://www.businessbloomer.com/...
user avatar
0 votes
1 answer
15 views

Hook to add_action('updated_option_my_option', [$this, 'save_data'], 10, 3]);

i want to modify my options data after save. Therefore i want to hook into "updated_option". This works without problem. I create a new option called "my_update_option" and want ...
user avatar
  • 121
0 votes
0 answers
18 views

Wordpress comment processing . Default unapproved comments detection before posting

I am working on wordpress comment section. I understand that when we are posting some comments for example comments with many links, then WordPress storing this comment in to the database with ...
user avatar
  • 25
0 votes
0 answers
20 views

Replace Data In Post & Update Meta Field Post Is Saved

I'm a bit lost & I'm wondering if someone can help. I have a post that is being generated from a podcast feed. That feed contains an audio player using the <audio> tag. I wanted to remove ...
user avatar
0 votes
1 answer
44 views

Warning at top of website & top menu gone

This warning has appeared at the top of our website, and our top menu bar has disappeared: Warning: call_user_func_array) expects parameter! +~ be a valid callback, function '...
user avatar
0 votes
1 answer
17 views

Get access to variable from previous pageview, excluding ajax-calls

I want to generate a random string, and get it passed to the next pageview. I currently have the following code: add_action('init', 'set_global_pixelcapival'); function set_global_pixelcapival() { ...
user avatar
0 votes
1 answer
35 views

How to read and write session data?

My website requires users to complete their profile before they can place an order. So far, I have been able to redirect a user to his profile editing page if his profile is incompleted when he tries ...
user avatar
  • 129

1
2 3 4 5
45