Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Method by which plugins and themes extend core WordPress functionality.

0
votes
2answers
7 views

Insert HTML in post, below nav bar but above content?

I'm trying to insert a dropdown (via HTML string) in to every post I have. I'd like to add it before the post information, but below the website nav. bar and header. In the screenshot, you'll notice ...
0
votes
0answers
2 views

Intercept password prior to wp_update_user committing and hashing?

I'm using a plugin that uses wp_update_user instead of password_reset and I need to use the password prior to hashing to sync the change to a secondary authentication system. Is there any way to do ...
1
vote
1answer
19 views

Add function to every post?

I have some code that generates a dropdown list of all my post files. I would like to add this dropdown to the top of every post page, right before the post content. What's the correct hook/action ...
0
votes
1answer
16 views

Hook into all password resets in Wordpress and get password before hashing?

I'm syncing my Wordpress authentication system with an secondary/external authentication system and my site has at least two ways of resetting the password, including: Password reset email User ...
0
votes
0answers
7 views

Filtering out HTML tags not working w preg_replace [migrated]

I have some posts that (in the actual post text on the backend) has some errant <strong> </strong> entries. I'm trying to filter these out before being rendered as HTML. (Note that I do ...
0
votes
1answer
8 views

Control the srcset much more (not all sizes in it each time)

I'd like to be have more control on the srcset on certain important images of my website if not all. By default the srcset includes all the sizes created by wordpress for all the images. I'd like to ...
0
votes
0answers
16 views

How can I delete a file off of Amazon S3 within the WordPress ecosystem [on hold]

I want to access my S3 bucket, and when I remove a file, use the delete_attachment hook to call to Amazon and delete those files ( we have a service that offloads files to S3 but doesn't delete them. ...
0
votes
0answers
12 views

How to add google tagmanager to default registration page?

How I add google tag manager to default registration page? So Ill can track the registration flow? Ill need to add a google the tagmanager script to the head and a tagmanager noscript to the body of ...
0
votes
1answer
30 views

WooCommerce Hook: Content get's displayed twice and not AFTER the order total

I've overwritten WooCommerce's review-order.php to change the checkout a little bit. Now everytime I add something to the hook woocommerce_review_order_after_order_total the contents get displayed ...
0
votes
1answer
80 views

OOP development and hooks

I'm currently working on writing my first OOP Plugin for Wordpress. To help out a little bit with structure I looked for, and found, a boiler plate that sets up the basics for me. In Main.php there'...
1
vote
2answers
47 views

Set meta field to publish date + 2 weeks

I have a meta field called postexpiry, and I want to set the value to the publish date, + 2 weeks. So if today were October 3rd, I want the field to be set to October 17th. I was thinking about ...
0
votes
0answers
20 views

Why always one post missing in wp query loop

I know this is duplicate of Why always one post missing but the solution suggested to use Hikari Hooks Troubleshooter plugin which was last updated 8 years ago and I was not able to comment on the ...
0
votes
2answers
40 views

Woocommerce - Adding row to cart table

I would like to add an extra row to the Cart Table in Woommerce, but I can't find the right action. From this file https://github.com/woocommerce/woocommerce/blob/master/templates/cart/cart.php, I ...
-1
votes
1answer
23 views

Add PHP code to header section from plugin

How can i add any type of PHP code to header section through plugin programmatically ? I did use add_action('wp_head', 'your_function'); function your_function() { echo ...
1
vote
0answers
33 views

WooCommerce order complete email logic

Can someone helps me to understand the logic of WooCommerce for sending email on a completed order? If I'm not wrong, the mail is send when the order is marked complete, but I'm not able to find the ...
-2
votes
1answer
24 views

How to display <div> before H1 Title

I need display custom block before H1 Title in my posts. Please, tell me. Is there any function or hook to implement this? I cant edit file single.php, because I create different single templates ...
0
votes
1answer
17 views

Needing to add a conditional PHP statement for woocommerce webhooks

So in a nutshell I have a code that checks if an item is listed with a price or not on my website. If there is no price, or the price is 0 it currently shows "Call # to Order" My problem is I need ...
1
vote
0answers
24 views

How to add an arrow to menu items has submenus

I want to add arrow (or anything like ...) after every menu item that have children menus. I know that there is some JavaScript solutions. But for some reasons (stability and ...), I don't want to ...
0
votes
1answer
41 views

How to re-arrange this hooked content?

I am trying to re-arrange Woocommerce Sensei hooked content. Basically, I would like to have course_image at the top (high priority). // code in sensei /includes/hooks/template.php <?php /...
0
votes
0answers
15 views

Echo HTML in Hook Doesn't Work

I use LearnDash plugin for e-learning courses. I am using the learndash hook for when a topic is completed to run some code. This looks a bit like this: add_action("learndash_topic_completed", "...
0
votes
0answers
16 views

Overrided parent function in child theme not load next content

So I want to change top header line display. To do that I'm trying to override parent theme function with my edited function. When I do that my function override parent function, but next page content ...
-1
votes
0answers
23 views

How to always load checkout shipping fields from customers profile?

Is it possible to always load the shipping fields in checkout page from customers account? Example: Customer has set shipping address in his/her profile from account page Customer proceeds to ...
0
votes
0answers
9 views

Add two fields to woocommerce product frontend

I've been following this tutorial: https://www.kathyisawesome.com/add-a-custom-field-to-woocommerce-product/ on how to add a custom field to the front end, that saves to the order and is stored in a ...
0
votes
0answers
18 views

How to call a plugin function / variable from the theme

I'm trying to access to a specific plugin function in my theme. I really don't know what I'm doing wrong. I tried with include, no luck. I tried wit add_action and do_action, no luck. What should I ...
0
votes
2answers
39 views

Generate links on all images in posts - is there a hook?

I am looking for a way to replace all links on images. Currently when a user clicks an image it links to the source file. What I want it to do is to ink to: example.com/editor=12&image=filename....
0
votes
1answer
27 views

How to properly setup an activation hook

I am trying to register an activation hook for my plugin. The plugin is using classes and the actual activation method is held in a separate admin class. Reading the documentation for ...
0
votes
1answer
31 views

Add suffix to price html does not work

I am trying to add a suffix through a filter hook to a product price in Wooommerce, but for some strange reason the woocommerce_get_price_html filter hook (like explained here) does not change ...
0
votes
0answers
29 views

is_page not triggering

Here is my code: add_action('template_redirect', 'ep_tags_redirect_lockout'); function ep_tags_redirect_lockout() { if ( is_user_logged_in() ) { return; } //echo 'XXXXXX'; if (...
0
votes
0answers
16 views

which hook do I use to present a message to the user when he adds an image in a post by a URL

I will make a code that when the user tries to put an image via URL without the HTTPS will present an Error message, however I do not know which hook to use, the error would have to appear in the ...
3
votes
0answers
29 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 ...
1
vote
1answer
15 views

How to use filter hook “the_posts” with a function that refers to $this?

I'm using Carbon Fields to manage event-related metadata (such as event dates) for certain posts on my site, but I want to make sure that past events do not show up in my site's feeds. I need to use ...
0
votes
0answers
21 views

Plugin Development - Call to undefined function comment_exists()

In my plugin I hooked my function to wp_loaded and there is a call to the function comment_exists() which fires a Fatal Error. In which hook in the loading process I can be sure that the function ...
0
votes
1answer
17 views

{status}_{post_type} does not run correctly?

I used the hook {status}_{post_type} from the docs here. In the docs it said: action will execute when a post of type {post_type} transitions to {status} from any other status. Here is my code: ...
10
votes
4answers
148 views

Is there any action filter/hook for validating a custom field before publishing the post?

I have a custom filed called xxxx_url. xxxx_url should be unique. So, before publishing the post, I want to make sure that xxxx_url is unique or not? If it isn't unique, publishing the post should be ...
0
votes
2answers
38 views

How to disable delete option for a specific page? [closed]

i found many questions like this but nothing matching to my requirement.Here i need to lock a specific page named settings,not to be deleted by other admins.But it should able to edit. Is there any ...
0
votes
1answer
21 views

How to register a widget when saving a post?

I've tried to solve my problem in the simplest way, but it doesn't work: why? function createNewWidgetSavingAPost($post_id) { add_action( 'widgets_init', function(){ $...
0
votes
1answer
23 views

Wordpress cronjob get scheduled but function does not run

I am trying to schedule wordpress cron job having dynamic hooks. I am developing a plugin and the cron jobs are to be scheduled dynamically. I need a way to name the hooks that directly corresponds to ...
0
votes
1answer
15 views

Notify admin when Custom post meta data gets updated or deletet

I am trying to email admin when an single custom post meta gets updated or deleted. This does not work with post save or post delete. All i need is to detect when this post meta gets updated or ...
0
votes
1answer
24 views

Correct way to register custom post type from external php file?

I have a class file and I have separated out my custom post types into their own files in a sub-folder for neatness, readability, etc. I want to init the CPT now in my plugin's index.php class. My ...
0
votes
1answer
24 views

How to direct user after comment save

I've been trying to direct the user to the specific page after they posted the comment, but that not luck for me. Here is the my code blocks My first try: add_action('wp_insert_comment', array($...
0
votes
2answers
25 views

How to delete WooCommerce categories in bulk that only have one product

I would like to bulk delete WooCommerce product categories that only contain a certain number of products, is there a hook that provides this functionality?
1
vote
0answers
13 views

WordPress Gravatar filter is removing my custom attributes

I am trying to add a style attribute on all the custom gravatar images. However, it is removing the style attribute before final output. Here is the code I am using: $background = ''; $args = [$...
2
votes
1answer
40 views

Modifying values with add_action to be sent to db

I am struggling with this problem for hours now, what is going on is that somewhere before inserting the values into the db, this action is being called. do_action_ref_array('h5p_alter_user_result', ...
1
vote
1answer
26 views

Featured Image Action Hook

Is there a hook available that returns the featured image, once a featured image is set to a post? I checked Which action hook can I use when a featured image has been selected and the action hooks ...
2
votes
0answers
23 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 ...
4
votes
1answer
216 views

Extend core block in Gutenberg

for a project I have to extend the core block core/cover-image. For the first basic try I came up with the following code: PHP: add_action('enqueue_block_editor_assets', function() { ...
0
votes
0answers
13 views

How to delete meta-field which is registered with register_meta to Rest API

I'm working on a Wordpress integration and updating our WP JSON api v1 to v2. We have custom post types which use two custom meta-fields. One of them should be preserved to the WP's database while ...
1
vote
0answers
23 views

Get Time Taken By Each Action Hook in Wordpress

I am developing a Plugin, and want to record Time taken by each Action Hook, I am able to get all the Hooks Triggered on a Page with the Action and Priority, but i am unable to get the Time taken by ...
0
votes
0answers
13 views

When would it be best to hook AJAX functions on a back-end page?

I'm setting up my page as follows: add_action( 'admin_menu', [$this, 'addAdminMenu' ], 80 ); And its content: public function addAdminMenu() { $this->hook_suffix = add_theme_page( ...
0
votes
2answers
99 views

Get The Caller (Plugin / Theme / Core) For All actions & Hook in Wordpress

I am developing a plugin which will show the caller of all the Hooks & Actions on a Page in Wordpress just like QueryMonitor. I know that global $wp_action & $wp_filter has all the information ...