Questions tagged [hooks]

Method by which plugins and themes extend core WordPress functionality.

Filter by
Sorted by
Tagged with
1 vote
0 answers
21 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
  • 103
0 votes
1 answer
22 views

I only want to show links to categories that have posts in 'publish' state in my menu

I am working on a WordPress project where I want to dynamically filter menu items (and possibly their parent items) based on whether they are associated with any published posts. Specifically, I am ...
Webwoman's user avatar
  • 101
0 votes
0 answers
27 views

Skipping all WP functions for a cached version

I started making the following caching codes in order to create an experimental plugin that provides a solution to my own needs. add_action('wp_loaded', 'buffer_start'); add_action('shutdown', '...
G.D.i's user avatar
  • 23
0 votes
0 answers
8 views

Add 2 links in between the navigation using the Breadcrumb Navxt plugin hook

I am using the Breadcrumb NavXT Plugin. I have 2 links at a page, and want to add 2 more links in between on that specific page. I used the below hook, but did not get the result. add_filter('...
Rizeen's user avatar
  • 101
0 votes
1 answer
26 views

Does a wordpress custom plugin is fired by default on php theme ajax request?

Inside My custom wordpress plugin to translate all posts depending on get_locale() I created a php file that's add_filter() to each post content element. Ajax requests are called from functions.php ...
imagIne's user avatar
  • 45
0 votes
0 answers
9 views

How to modify username before logging in?

I know a solution exists for Wordpress admin from this Stack Exchange question: Change username before login However, while this works for logging into Wordpress directly, I am trying to use it for ...
Harish Prabhakar's user avatar
0 votes
0 answers
23 views

How can I trigger an Account deletion in WordPress trough the press of a link?

I have a form in JetForm Builder that can trigger a hook, how can I cofigure it so that when a button is pressed an email gets sent out with a link and wehen the user presses that link his account ...
AYNTK's user avatar
  • 5
0 votes
0 answers
17 views

How do I modify the TinyMCE editor Add Media button to insert a thumbnail preview of PDFs in addition to a text link?

We're still using TinyMCE as our post editor. When Editors use the 'Add Media' button to select a PDF from the Media Library, they choose the preview image from the Attachment Display Settings at ...
jchwebdev's user avatar
  • 765
0 votes
0 answers
10 views

filter hook 'authenticate' runs twice

I am writing a custom function for logging into wordpress multisite. I take the name of the site via blog_id and append it to the username then pass it into 'authenticate' filter hook. Eg) Username ...
Harish Prabhakar's user avatar
0 votes
1 answer
17 views

Is there a way to assign a default Category to a Post when the user creates a new Post?

So far the best I've been able to figure out is how to assign a category when the Save Draft button is pressed. That is not what users want. They want to a particular Category ticked when they first ...
jchwebdev's user avatar
  • 765
0 votes
1 answer
65 views

Custom fields in the billing address section woocommerce

I have added custom fields in the billing address in Woocommerce checkout page, this works fine. Now I would like to show these custom fields inside the "billing address" box in the email ...
LesCa's user avatar
  • 21
0 votes
0 answers
18 views

Search with synonym letters for arabic language

How can I have WordPress search different letters in Arabic? For example, أ-ا-إ are the same letters but in different formats. E.g. can I search WordPress for something like "world" > &...
AbuKotsh's user avatar
0 votes
0 answers
6 views

woocommerce new order alert on a specific non admin page

I'm relatively new to WordPress but have basic understanding of how it works; I have a page where non admins can see woocommerce orders, I want to trigger a popup on this page when there is a new ...
petey's user avatar
  • 1
0 votes
0 answers
10 views

How to add "Leave a Comment" link or button at the bottom of each post in the "Latest Posts" block?

I have been digging around in WordPress developer resources to see if I can figure out how to add "Leave a Comment" link or button at the bottom of each post in the "Latest Posts" ...
bistromatic's user avatar
0 votes
0 answers
42 views

What hook runs wpautop on template content?

I have a shortcode that outputs HTML and I've inserted it into a single post template. The output gets extraneous <br/> and <p> tags, which I've read in other topics are likely due to ...
Aayla Secura's user avatar
0 votes
0 answers
24 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,766
0 votes
0 answers
21 views

Is there a wrapper to develop a plugin for WordPress and Prestashop in generic code?

I'm looking for a wrapper or other tool that lets me develop a plugin for both WordPress and Prestashop in one go. So that I can write generic code to create a page, and have hooks to run on page load ...
Lode's user avatar
  • 101
0 votes
1 answer
65 views

Remove H1 title in admin post edit screen

As a priority i need to just display some custom html inside the Title(h1.wp-heading-inline) in the Post Edit Screen (Top Left Corner). While trying various methods i found that all html is filtered ...
Ion T's user avatar
  • 15
0 votes
1 answer
32 views

Why does my function create extra empty files?

The code below, added to functions.php, is saving the texts (pre-formatting) of the posts when they are saved, published, or updated. During the first run, I also added save_all_post_to_database() to ...
Yulia V's user avatar
  • 115
0 votes
0 answers
56 views

WordPress Backend - Custom Login Flow

What do I want to achieve : Login based on the mobile number and OTP each time the user logs in, an OTP will be sent to his number. The OTP service is linked to an external server, meaning that, I do ...
sayo's user avatar
  • 1
0 votes
0 answers
35 views

How to add field new in account bacs in woocommerce?

i was looking for a way to add a new field to woocommerce bank account info, my theme has no child theme and i put my code in functions.php I found the solution but it doesn't work. function ...
Le Xuan Phat's user avatar
2 votes
1 answer
86 views

At what stage does wp_ajax hooks gets applied during Wordpress request?

At some point between muplugins_loaded and shutdown wp_ajax_*, wp_ajax_nopriv_* are executed, but where/when exactly? I have found that this is working: add_action( 'wp_ajax_actionname', '...
Miloš Đakonović's user avatar
0 votes
1 answer
24 views

Log in and out using custom pages, no logout confirmation and redirects for logging in and out 2023

Good day, I'm having fun and games with having a custom elementor login page that i've designed myself that has a log in widget, having that redirect to a page with a different logged in menu and ...
indieben's user avatar
0 votes
0 answers
20 views

Event Manager – how to access to event title

I am trying modify the grid- & list-view event title. I need to access the title, test for certain conditions and modify as required. My first thought was to use the template [...
user232682's user avatar
0 votes
1 answer
117 views

Hook function when taxonomy terms change

I have a custom post type with a custom taxonomy. When the custom taxonomy is set to "bar", I want to disable comments with: wp_update_post(array( 'ID' => $post->ID, '...
dtw's user avatar
  • 105
0 votes
2 answers
64 views

Is there a hook that I can use when a fatal error occurs?

Ideally I would like to log the user or page that triggers a fatal error so that I can follow up with that person or go directly to the page they were on for testing. My thought is that if there is an ...
Aristocles's user avatar
1 vote
2 answers
174 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
  • 467
0 votes
0 answers
21 views

Why does before_delete_post run when opening a post in the backend?

I need to disable the permanent deletion of posts (it's ok to trash them, but users shouldn't be able to delete them from trash). I did that by hooking into before_delete_post and redirecting (thanks ...
user232080's user avatar
1 vote
0 answers
130 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
  • 195
0 votes
1 answer
48 views

is_user_logged_in() undefined at shutdown in plugin context

The function is_user_logged_in() is not available at shutdown (plugin context, not theme). I want my plugin to run only (1) on front-end pages and (2) when the user is not logged in. This works, but ...
Jeff's user avatar
  • 125
0 votes
1 answer
157 views

Creating my own "recent blog posts" static Gutenberg block, can't use react hooks in the frontend

so I was trying to learn more about Gutenberg Blocks and I wanted to make a block that shows the last three blog posts - something that could be used at the bottom of each page of my Wordpress site. I ...
Mike Sav's user avatar
  • 105
0 votes
1 answer
57 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
  • 206
0 votes
1 answer
37 views

How do I set a custom post type Category after import using wp_set_post_terms

I'm importing Events from a Salesforce Event Manager into WordPress, specifically into the The Events Calendar. The Events Calendar creates a CPT called Events. It also has its own Categories, which ...
Mikey B's user avatar
1 vote
1 answer
45 views

What is the equivalent hook for both admin_head() and wp_head() combined, if any?

I know about wp_head() and admin_head() for hooking into their respective <head>s, but what is the hook for both of these combined, if any? The purpose is to: add_action('wp_head', 'custom_css');...
Jeff's user avatar
  • 125
0 votes
1 answer
8 views

Get post ID before add_theme_support

I need to enable font sizes options in editor with add_theme_support, but only for the specific post types and page templates. To distinct them, I need to get the post ID in the WP admin, before ...
Tahi Reu's user avatar
  • 206
0 votes
0 answers
31 views

How can I get the ID before after_setup_theme?

I need to get the ID of the currently edited post (in the WP admin) before the after_setup_theme is triggered, because what happens on after_setup_theme will depend on the currently edited post ID. ...
Tahi Reu's user avatar
  • 206
0 votes
1 answer
23 views

Guests comment form - prevent duplicate email addresses

I am trying to prevent guests (not users) from posting comments on one single page if they fill in the same email address. My further goal is to collect their unique addresses for a contest (The best ...
futurebreeze's user avatar
0 votes
0 answers
27 views

Not able to set userId and email at wp_set_current_user in Worpdress

I am trying to create a plugin where user can login using our platform where we have login with google and other options. I want to override worpdress login system. So I am trying to set userId and ...
Saurabh's user avatar
0 votes
0 answers
45 views

Add button and title on submenu WordPress

I would like to add a "Back" button and menu title on the submenu but I do not know how. I am guessing to use wp_nav_menu_items() filter but I am not 100% sure how to start. Here's what I ...
ddd's user avatar
  • 7
0 votes
0 answers
46 views

Ninja Forms: Front-End Forms, Post ID?

I have been scouring all day, trying multiple things to get the Post ID of the Create Post action within a Ninja Form and it doesn't seem to be possible. The reason I need to, is because the data that ...
dcolumbus's user avatar
  • 627
0 votes
1 answer
14 views

Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only

I wrote below code but facing issue to run it only on archive, categories, author, date pages to improve page speed. add_action( 'wp_footer', function () { ?> <script> if( is_archive || ...
Sunny's user avatar
  • 3
0 votes
0 answers
18 views

Create section wit form

At the moment i am study wordpress and i have some questions about create a section on my own template with hooks. I want create section with custom form below comments and above table filters, in ...
4WordPress's user avatar
0 votes
1 answer
83 views

Hook on opening a media/document

I am trying to find a hook to be able to set a datalayer.push everytime a document is opened. It could even be something that runs after the document is opened ex: https://example.com/wp-content/...
David Vimaweb's user avatar
0 votes
0 answers
21 views

Change password reqts with NO plugin without breaking resetpass link?

I'm trying to change password requirements in WP 6.1.1 without using a plugin. It's a clean install with just wp-cli plugin list +---------------------------------------+----------+--------+----...
GlenS's user avatar
  • 1
0 votes
0 answers
37 views

Add text when displying attribute with a hook on single product page

I have books as products in woocommerce and I'm trying to show the order of the book in the series. It should look something like this: "The book 1 of Series" I've managed to add the link to ...
Mrs Vanklik's user avatar
0 votes
0 answers
504 views

Fatal error Class-wp-hook, again, but not sure what's triggering it

We're suddenly getting these errors in some of our page templates: mod_fcgid: stderr: PHP Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, ...
Khom Nazid's user avatar
1 vote
1 answer
42 views

Why is my activator class adding the files/running the actions I add?

I am using the WP Plugin Boilerplate to develop a plugin, but when I activate the plugin, the require files and actions I put inside the activate() function are not working. I have tested the class ...
JayDev95's user avatar
  • 157
0 votes
1 answer
82 views

Admin Notice is only localized when displaying the "Plugins" Backend Page

My plugin checks if a specific theme is activated. The check is hooked on init. If the theme is not activated, it displays a warning, hooked on admin_notices. This works fine. Now I added localization ...
Maxwwos's user avatar
0 votes
1 answer
39 views

Hooks to trigger a callback when adding, removing, rearranging or updating a widget in the widget area

I am looking for hooks that fire when inside of Appearance -> Widgets: A widget gets added to a widget area A widget gets deleted from a widget area Widgets are being rearranged to new positions A ...
Kevin M's user avatar
  • 143
1 vote
2 answers
81 views

Why callback function is not working in wp_head hook?

I have two versions of the simplest function that hooked to the wp_head action. One is working, andother one is not. Can someone explain? // Works ! function custom_description() { ?> ...
Taras Parashchuk's user avatar

1
2 3 4 5
46