Questions tagged [hooks]

Method by which plugins and themes extend core WordPress functionality.

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

check to see if hook is available

I'm using a theme-specific, custom hook to add some custom attributes/values to the page's <body> element. There are however pages on my site that use a template that do not have that hook ...
2
votes
1answer
219 views

How to add extra attributes to the script tag added via wp_localize_script()

So, wp_localize_script() are awesome to add custom data to a script. And these data gets added to the HTML like: <script id='woocommerce_some-js-extra' type="text/javascript"> var ...
1
vote
1answer
676 views

Is there a better way to implement responsive images than what WordPress uses by default?

I am new to WordPress, and I started with my own custom theme. For responsive images in WordPress, I currently use custom html blocks in my theme with picture or img elements that use multiple ...
0
votes
2answers
311 views

How do I add $_SESSION[''] to my wordpress page?

I am trying to take my existing object array then json_encode it and add it to a $_SESSION[''] so I can request it on other pages on my website. Is there a way to save my session string (or array) and ...
2
votes
1answer
67 views

How to prevent action in ajax request, when in admin side?

I have a plugin that hides certain posts in the frontend. For this to be consistent, I need posts to also be hidden in searches and AJAX searches (needs to work with any theme and search). To make ...
0
votes
1answer
64 views

Content including hooks inside wp-settings.php are being called twice in WordPress

I found that init hook is being called twice and then I try to trace and find out wp-settings.php is also being called twice. I originally want to post a question to find out why. And after some code ...
1
vote
0answers
10 views

How can I get my Script to work on the Login page?

I am trying to disable the right click feature, on the login page, using the following code: <?php function disable_right_click() { ?> <script> jQuery(document).ready(function(){ ...
0
votes
0answers
20 views

What is the earliest Hook a Script can use?

At present, I am disabling Right Click through the use of the following code: <?php // Disable Right Click function disable_right_click() { ?> <script> jQuery(document).ready(function(){ ...
0
votes
0answers
67 views

How can I remove the 'File URL' field from the image attachment editor?

When you go into the Media Library and select an image to edit, its associated 'Attachment details' page appears. On this page, there is a 'File URL' field which details the attachment file's URL. ...
0
votes
1answer
28 views

Change the Default Plugin page filter to Active intead of All

Thanks in advance to all, is there a way to change the default filter in the plugins page that is set to All to something else like Active ? I'v tried to find a hook, but couldn't find any info.
0
votes
0answers
34 views

Send Mail when coupon code is applied and order is successful

i tried with code below to send mail when coupon code is applied, though my requirement says when the order is successful and coupon code is applied it should send mail. add_action( '...
0
votes
1answer
16 views

How to edit the <body> Tags within the image file URLs?

At present, my image files appear within the following URL structure: www.example.com/wp-content/uploads/year/month/image-file-name.jpg These image files, contain the following Body Tag <body ...
0
votes
0answers
107 views

get_image_tag_class hook only works with the get_image_tag() function

i have this on my plugin's constructor add_filter('get_image_tag_class', [$this, 'filterImageTagClass'], 999); the filterImageTagClass being like this: public function filterImageTagClass($class) { ...
0
votes
0answers
102 views

Mocking @wordpress/data `useSelect` hook

I am trying to use useSelect. I want to test The string pass select is video-store I am actually calling getVideoCollection However I am getting following error. TypeError: useSelect....
0
votes
1answer
44 views

Populate acf-field, depending on block name

I have an acf select "global_fargtema" for all blocks what i am trying to do is, if a block name is == "acf/full-width-talker" populate the field "global_fargtema" with $...
0
votes
0answers
73 views

How to use WP conditional tag in a functions.php with OCEANWP Theme?

Theme - OceanWP Page Builder - Elementor Single Post templated created using Elementor I am trying to add custom code for the SINGLE BLOG POST. Using a conditional tag "is_single", I want to ...
1
vote
0answers
50 views

Trigger Elementor Popup via code [closed]

Is anybody here using Elementor plugin? How do you trigger the Popup via code or within functions.php? Is that possible? For example; function popup_call(){ ... if(...condition is true...){ ...
0
votes
0answers
47 views

Custom order details text not displayed in Woocommerce App (works in browser)

My script is working fine on desktop (in browser), properly displaying text below shipping details. All green lights. The issue is when viewing orders from within the WooCommerce application - doesn't ...
0
votes
0answers
27 views

Set custom directory in theme for page templates

I have a directory structure in my theme like this: src/ templates/ pages/ - faqs.php views/ - page.php In my custom functions I have a hook that tells WordPress to look in the ...
0
votes
0answers
28 views

How to use Load more button ajax in wordpress for post

I'm trying to display a click event for displaying the posts list in WordPress. I've used my template file for this code. template loadmore.php <?php /** * Template Name: Ajax pagination Template ...
0
votes
0answers
17 views

hook add_attachment cannot complete its work

Good afternoon! I need to clear everything fields when inserting an image in the WordPress loader. On the Internet, I found a function: function my_set_image_meta_upon_image_upload( $post_ID ) { ...
0
votes
0answers
36 views

How to show the search result to archive page without redirection to search result page

In the archive page, used Jet-Ajax-search widget/Elementor pro to filter products and products putted by using Jet-woo-builder product grid. Just wanted to show search result to archive page with same ...
0
votes
1answer
25 views

Hook when post is set from published to draft?

Is there an action i can hook into when a post is set from published back to draft? I have tried both transition_post_status and publish_to_draft but they don't seem to work when I set the post back ...
0
votes
1answer
10 views

ACF Fields are not showing up on Homepage

I want to Customize the Yith Plugin for which I want to add some custom fields with Existing fields. I am getting fields from ACF and adding them to an array ACF Fields are showing up in Yith Setting ...
0
votes
0answers
53 views

How to listen on Wordpress REST API calls ( single post )

I'm building a mobile app and need to collect site visitors count through the mobile app using the only way available to me and that's The REST API. I found a plugin called WordPress Popular Posts ...
2
votes
1answer
386 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 ...
1
vote
1answer
18 views

wp_get_post_terms is difference obj model than the one in rest api response

I'm building a mobile app and using the rest API on WordPress to do that, I am customizing the /wp/v2/posts response by using the following code: add_filter('rest_prepare_post', '...
0
votes
0answers
30 views

Have get_the_post_thumbnail output different image if custom meta exists

I have a meta box on each post where a user is able to select another image from the media library. I want this image to override the output whenever get_the_post_thumbnail is used across the whole ...
0
votes
0answers
180 views

Trouble Accessing Gravity Forms API (GFAPI)

I'm having trouble figuring out where I should be registering my function in such a way that I can access the Gravity Forms API (GFAPI). At first glance, this may appear to be native to Gravity Forms, ...
0
votes
0answers
15 views

Override template with child theme on specific conditions only

I have a template override of the woocommerce checkout page in my child theme. However, I only want to override on specific conditions. Is there an easy way to do that? Let's say I only want to ...
0
votes
0answers
10 views

Events with booking

I'm trying to achive an event system somehow but I couldn't get it with any plugin. What I need is: A custom post type for events and custom fields A subscription/booking method to events (for free, ...
0
votes
0answers
18 views

Add a new page for every value added in my db table

i'm working on plugin and i need create a page every time a new values is insert in my table. That s my function for create a page with value name. In $name there are all the values from my db and in ...
0
votes
1answer
38 views

Modify WordPress Page Title (<head></head>)

I'm trying to modify the WordPress page title. However I'm fairly new to WordPress functions, hooks (filters & actions) and so on. What I could achieve is to change and modify WordPress titles in ...
0
votes
2answers
62 views

Removing parent theme action on pluggable function not working

I'm trying to remove a parent theme's add_action call to a pluggable function, but can't get it to work by calling remove_action() - I have to redeclare the function and just leave it empty. Is this ...
1
vote
1answer
185 views

How to remove query string from current page URL?

On page load, I wanted to remove specific query string from the current URL, is that possible? Is there a specific function for that? There is a function remove_query_arg('query_key'); and ...
0
votes
1answer
197 views

Modify existing plugin function with add_filter

I am relatively new to Wordpress and using custom filters and hooks. My site uses the TablePress plugin. But I need to be able to add the html attribute of role=presentation To all tables created ...
0
votes
0answers
23 views

How to write this wordpress code

The idea here is to share bulk WordPress posts between multisite blogs automatically. I have googled some tutorials and I know I can use save_post action hook, switch_to_blog and get_post() + ...
0
votes
1answer
77 views

check shipping amount in woocommerce_after_checkout_validation?

I am using a third-party shipping plugin. Sometimes, this plugin somehow acts up, and only charges the client something like 1$. I'd like to add a sanity check before the order is accepted, that the ...
0
votes
0answers
154 views

custom error message for empty username and password using authenticate filter not working

I'm trying to override the authenticate to edit the default error message. /** Purposed: Custom Login Error Message Description: This function override the default error message on login form. **/ ...
1
vote
1answer
61 views

Randomize attachment IDs

I'd like to have my attachments IDs being random (not sequential). Just like what this plugin does, but for attachments. I've tried to look into the source code of the plugin, but it uses filters that ...
0
votes
2answers
48 views

Easy Digital Downloads - How to use hooks correctly?

I’m using Easy Digital Downloads for my Wordpress webshop. After someone buy a item it needs to add data to the SQL database. I got this working by adding PHP code to shortcode-receipt.php. This is ...
0
votes
0answers
18 views

How can I make a proxy call to this Wordpress PHP function, one time without a parameter, other time with?

So in Wordpress, I have a hook for an ajax action, that looks like this: add_action( 'wp_ajax_myhook', __NAMESPACE__ .'\myhook' ); function myhook() { $username = "webmaster@example.com"...
0
votes
0answers
14 views

How to sort products in shop page by defined category order?

I am currently working on sorting the shop page products based on a defined category order and stock count. I got the stock count sorting working but I am unable to find a proper way to implement sort ...
0
votes
0answers
28 views

Add an attribute to the root from functions.php with add_filter

I followed this link. First thing I did was to add my dark-mode switcher, add JS to handle it and edit my CSS accordingly. Thing is, I didn't exactly do that, I used the possibility to have a global ...
0
votes
1answer
389 views

Would like to use hook or filters to customize email templates

I hired a contractor to help me with my site a few years ago when I didn't have the coding experience that I do today. The contractor ended up making new templates for almost every email, and they are ...
0
votes
1answer
375 views

How to display two different custom taxonomy terms on a WooCommerce single product page

Our WooCommerce products have two custom taxonomies: sizes and colors. I'm trying to display the custom toxonomy terms for a product on its single product page. I'm using the ...
4
votes
1answer
83 views

How can I remove a hooked action created by a plugin?

public function orddd_capabilities() { $role = get_role( 'shop_manager' ); if ( $role != '' ) { $role->add_cap( 'manage_options' ); } } add_action( '...
0
votes
0answers
170 views

How to filter menu of categories on attribute archive pages

The following PHP displays menu of WooCommerce product categories: <?php $orderby = 'name'; $order = 'asc'; $hide_empty = true ; $cat_args = array( 'orderby' => $orderby, 'order' ...
0
votes
0answers
23 views

delete_user hook failed

I would like to delete a specific post when the user is deleted in admin/users.php. I did this code : add_action('delete_user', array(__CLASS__, "delete_user_profile"), 10 ); //I´m sure the ...
0
votes
1answer
293 views

Remove Header and Footer if user is not logged on

Using Hook, is there a way to remove the Header and Footer from the specific page that is trying to access by users, if the current user is not logged on? function footer_header_remove() { if(!...

1 2 3
4
5
43