Skip to main content

Questions tagged [hooks]

Method by which plugins and themes extend core WordPress functionality.

630 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
2 answers
8k views

trigger save_post event programmatically

Is there a way to trigger the post saving or updating event in code? such as do_action('save_post', $post_id); The function here seems to imply that a WP_POST object needs to be passed in. Is there a ...
TurtleTread's user avatar
4 votes
0 answers
188 views

Hooking a callback into the code within a Gutenberg block

I want to run some JavaScript when a user uploads an image or images using the core/image block or core/gallery block. Ideally I would run my own code when the onSelectImage function is called (and ...
Sean's user avatar
  • 647
4 votes
1 answer
589 views

Featured image upload finished hook

I'm looking for a way to hook into the process of uploading a featured image. Ideally I would want to be able to do some stuff right when the upload has finished, before the thumbnails are generated. ...
INT's user avatar
  • 1,281
4 votes
2 answers
692 views

Wordpress scheduled task is called but not executed

I created a plugin with a cron to update all posts of a certain type every 5 minutes. I installed WP Crontrol to check if the cron is registered correctly and everything seems to be okay. This is how ...
Frederik Voordeckers's user avatar
3 votes
1 answer
436 views

How to remove "out of stock" variation options from size dropdown in woocommerce?

I'm using woocommerce to display products and their variations. I have a variation called 'Size' for all of the products. Some of the variations are out of stock, but these are still showing in the ...
SohaIb AhmEd's user avatar
3 votes
1 answer
796 views

how to create endpoint for downloading pdf files?

I would like the logged-in user to be able to download the PDF file, but not to see the real path to the file. Additionally, in this PDF file, I enter information about the user name and date of ...
patryk siuta's user avatar
3 votes
1 answer
4k views

Is there a Woocommerce hook that fires when applying a coupon but before checking if it's valid?

I want to add an item to the cart (that same item gets discounted with the coupon) upon using a coupon code (with a hook). E.g. when using the coupon code SAMPLECODE, a product is added to the cart ...
lastnoob's user avatar
  • 153
3 votes
0 answers
388 views

When using the block.getSaveElement hook can you output different markup based on whether or not you are in the edit view or the live page view?

I am trying to extend the core/image block to add an option for a deferred image. I want to replace the src attribute of the image with an empty string and add the url as a data attribute to be loaded ...
James Hamann's user avatar
3 votes
0 answers
1k views

Is it possible to intercept all ajax requests and get the parameters and the returns?

Is there any hook that always goes through it, where I can see all the requests, and also the returns after the "action" that is executed? I need to intercept all requests, including requests from ...
rafaelfndev's user avatar
3 votes
0 answers
74 views

How to find out what blocks are added by a plugin

I am creating a plugin, which adds a number of blocks defined by JS/PHP as per Gutenberg documentation. I want to display these block names on an admin page. Is there a hook or function I can use ...
Aravona's user avatar
  • 585
3 votes
0 answers
329 views

Make default new sites https (multisite)

Quick background case: If I use Softaculous to install WP in cPanel, I can specify which protocol I would like the site to be in... (so they have something that addresses this). However with my ...
Drewdavid's user avatar
  • 219
3 votes
1 answer
53 views

How can I add a fifth option to the alignment picker?

I'd like to have the following options in the image alignment picker: Left Right Center Full None Obviously four of those are there by default, but the "full" one doesn't currently exist. The idea ...
JacobTheDev's user avatar
  • 1,221
2 votes
0 answers
15 views

get_meta_sql hook is not firing

WP_Query uses WP_Meta_Query. I thought this calls the WP_Meta_Query::get_sql() to define the meta query SQL which is where the get_meta_sql filter is applied. I can't get the get_meta_sql filter to ...
Adam's user avatar
  • 103
2 votes
0 answers
298 views

Gutenberg - Add align controls to a custom block

I want to add align controls to a custom block. I wrote this code thad adds the code that adds the default block alignment toolbar to the block, but I select and change the align, I get an the ...
BenB's user avatar
  • 795
2 votes
0 answers
79 views

Hook all http requests

How do I hook all http requests in wordpress? More specifically I am interested in examining an http header in the request and then potentially modifying headers in the request so that other plugins ...
jjxtra's user avatar
  • 141
2 votes
0 answers
352 views

Gutenberg disable the "block" tab in right sidebar

I'm working on a Gutenberg setup that allows only one classic block. I want to disable the "block" tab in right sidebar since no settings appear there anyway, but can't find a hook or way to achieve ...
BenB's user avatar
  • 795
2 votes
0 answers
1k views

How to send data from a form created by a plugin to an external API?

I need to send the form data created with a plug-in to an external API, would it be the case to write a plugin for this case? And if this type of function is viable, any tip for initiation is very ...
José Roberto Oliveira's user avatar
2 votes
0 answers
184 views

`rest_user_query` can't access post author in post edit screen

I'm trying to modify the user dropdown in the post edit screen to show only (a) the current user and (b) the current author of the post. I can't do this using wp_dropdown_users_args because the meta ...
Jay's user avatar
  • 175
2 votes
0 answers
301 views

@wordpress/hooks use to add actions/filters within multiple plugin

I am trying to use @wordpress/hooks package in one of my react based plugin. I have added some hooks(filters/actions) and I need to hook into these from different plugin. I am able to add filter for ...
Varun Kumar's user avatar
2 votes
1 answer
416 views

Remove a div from RSS feed

If someone can help to remove a div from my RSS feed. I want to remove below code from my RSS feed. <div class="well"> <a class="btn" href="foo.com">foo</a></div> Thanks in ...
veggera's user avatar
  • 21
2 votes
1 answer
792 views

How to get all functions with priority '1' attached to hook 'wp_head'

How to get (loop through to disable unnecessary) all functions with priority '1' attached to hook 'wp_head' ('_wp_render_title_tag', 'wp_enqueue_scripts', 'noindex' etc.)? It is necessary to get it ...
Андрей Бочкин's user avatar
2 votes
1 answer
295 views

Hook into theme-switching later than `setup_theme`

I need to add a theme-switching logic to a site. Unfortunately, what I've tried already doesn't seem to work as required. The themes needs to switch based on whether the user is on the blog part of ...
indextwo's user avatar
  • 441
2 votes
2 answers
1k views

How To Change The Html of Products filtration sidebar in Woocommerce?

I have Used the function dynamic_sidebar('sidebarId') in the sidebar.php file. and all the functionality of the sidebar is Working succsessfully My Question is How To Change the Html of the sidebar ...
Ali Beshir's user avatar
2 votes
0 answers
3k views

How to use wp_trash_post (or wp_delete_post) for deleting a (or all) post(s) from custom post type?

I know, my question is general and here is some similar questions, I checked the all, but I dont find any solution for my problem... I try using the wp_trash_post() in my function.php, but for some ...
Galgóczi Levente's user avatar
2 votes
0 answers
1k views

Hook (upgrader_process_complete) running moment

i want to use the upgrader_process_complete (documentation) to check if my plugin was updated (to run some scripts). My question is: when this action is triggered, WordPress is already running the ...
Maxwell s.c's user avatar
2 votes
0 answers
147 views

Trigger Plugin database update after git pull

I have a couple of WordPress websites that I'm maintaining. The websites are on various git repositories (one for each site) with individual remotes. Currently when there is a plugin update ...
wadge's user avatar
  • 145
2 votes
0 answers
66 views

How get list all users who edited post?

How get user list who's edited post? Ex.: admin1 create post, editor1 make changes an update, editor2 make changes and update. Function result: admin1 editor1 editor2 Thank you!
Vladimir's user avatar
2 votes
1 answer
76 views

Does an action fire when adding a tag via the "Tags" meta box?

When a user adds a tag to a post, I'm trying to determine if they have permission to post in to that specific tag. If the user is not assigned to a tag that they try adding via the input in the "Tags" ...
JacobTheDev's user avatar
  • 1,221
2 votes
1 answer
167 views

Stuck in redirect loop after using wp_login action

I'm stuck in a WordPress redirect loop which happened after hooking into the wp_login action. The strange thing is that I've already removed the piece of code in question, cleared cookies and ...
Simon's user avatar
  • 31
2 votes
1 answer
572 views

How to use do_action_ref_array?

I have a plugin which has this method in it that is supposed to have a hook for custom validation. I have two issues: I'm not sure how to call it (have posted my attempt below) It looks like the ...
rtpHarry's user avatar
  • 237
2 votes
0 answers
1k views

Add tab to profile.php wordpress plugin development

I already know how to add an extra field in user profile. But in my case I have A lot of field to add and It is good practice that your form is not too long. So I decided to implement tab panel in the ...
Danryl Tigol Carpio's user avatar
2 votes
0 answers
667 views

Is it possible to delay execution of shortcode output callback?

I have a problem : shortcode output callback triggered too early. /* Defined in plugin constructor */ add_shortcode( 'foobar' , array($this,'pre_render_routine')); function ...
Ivan Varlamov's user avatar
2 votes
0 answers
188 views

wp.media add context

I have wp.media frame on my plugin to upload doc, docx file. I am filtering the uploaded file. If uploaded other than supported file, it will display this error I am filtering it at ...
user98239820's user avatar
2 votes
0 answers
532 views

Hook before & after plugin / core update

I'm working on a maintenance plugin for my website and I want to enable it before plugin/core upgrade starts and disable it after plugin/upgrade ends. Any ideas ? Thanks! :) PS: all I know is I can ...
George Jipa's user avatar
2 votes
0 answers
3k views

How to set a custom path, for ajax image upload folder in admin?

I am coding my first Wordpress plugin that handles some data for a custom (shop-like) post type. It also has an image uploader within a metabox, where you simply drag in your images and it ...
Raphael's user avatar
  • 53
2 votes
2 answers
783 views

add_action on inherit post status

I'm trying to use the add_action() hook to run a custom function, but am struggling with the post status. I originally tried using: add_action('pending_to_publish_portfolio', 'my_function'); (...
Barry Jarvis's user avatar
2 votes
1 answer
401 views

publish_post plugin hook doesn't always pass $post->post_content

I've written a simple plugin that grabs the contents of a post, as the post is published, and sends them to an external site for archiving. This generally works but when dealing with posts that haven'...
d13design's user avatar
2 votes
1 answer
1k views

WordPress Ajax callback function from plugin - OOP

Using PluginBoilerplate to write a plugin. I need to make an ajax call. I added to main plugin.php file, class to register scripts and handle ajax calls. if ( ! class_exists( 'PoorMansNameSpaceAJAX' ...
Amit Rahav's user avatar
1 vote
0 answers
13 views

Custom filter not affecting gtag script position in WordPress footer

I am using a custom filter to place the gtag script in footer if it is applied in functions.php. The filter code is: if (apply_filters('myplugin_ga_script_position', $position = 'footer')) { ...
ahmedwp's user avatar
  • 21
1 vote
0 answers
10 views

Adding custom filter not working

this maybe a stupid question, when I’m trying to create a custom filter to hook into later and filter and return something, I don’t get any results. I am testing this in the themes functions.php //...
Aldo's user avatar
  • 11
1 vote
0 answers
26 views

Core/Image access caption in render_template and in wp.hooks

I am making an override to core/image block -disabling styles, changing markup and such. I have managed to solve some things, but struggle with some others. Here is my code: filters.php <?php use ...
Sam Tyurenkov's user avatar
1 vote
0 answers
26 views

Preview for revision?

Is this possible: to allow admins to preview revisions from revision history, either with a plugin or hook? I would like to allow the admin to view post and page revisions, without having to restore ...
Jillian Hoenig's user avatar
1 vote
0 answers
47 views

Responsive images, per image type?

I am new to understand responsive images. Unfortunately the resources out in the internet did not help me to fully understand the concept, so please bare with me. I would like to know hdavidow if it ...
kocjs's user avatar
  • 23
1 vote
0 answers
26 views

HowTo modify BlockEdit-Component in Filter-Hooks for core-block Extensions

I've had a problem blocking me for days... I have extended the core block 'core/group'. The extension inserts an (overlay) div into the container and wraps the InnerBlocks into another div so that the ...
Jürgen's user avatar
  • 11
1 vote
0 answers
32 views

Appropriate WP hook to use set PHP cookie

I'm trying to set cookie in init hook. add_action( 'init', 'sa_maybe_set_cookie' ); function sa_maybe_set_cookie() { if ( ! empty( get_option( 'sa_allow_cookie' ) ) { setcookie( 'sa-...
micky's user avatar
  • 113
1 vote
0 answers
58 views

Ship block templates or block template parts with plugins

Using the following code one can ship CLASSIC PHP templates for custom post types registered in plugins. An example for a custom post type named MOVIE: function my_template_include( $template ) { ...
leemon's user avatar
  • 1,898
1 vote
2 answers
497 views

Execute callback after REST API request completes + Response is sent

In WordPress, is there an action hook or anything which allows you to run a callback after the response to a custom REST API endpoint, registered via register_rest_route(), has been sent to the client?...
DevelJoe's user avatar
  • 487
1 vote
0 answers
158 views

Change social icon in twenty twenty three theme

I am trying to replace some of the default social icons with custom icons. Does anyone know how to change the svg icons for the Social Icons block in the Twenty Twenty Three theme? I don’t see the ...
Jason's user avatar
  • 205
1 vote
1 answer
139 views

theme.json is altering Group block HTML

I am creating Blog within the existing site which will have completely different look, styles, features and functionalities. I need theme.json only on the Blog pages, but the problem is that theme....
Tahi Reu's user avatar
  • 236
1 vote
0 answers
86 views

wp_trash_post not firing as expected (also applies to trashed_post)

This is similar to wp_trash_post not firing but follows on from there. I have a piece of code to run on this hook; function to_fire_on_hook($post_id) { ... do stuff // Get the slug of the $post_id ...
Chris Pink's user avatar

1
2 3 4 5
13