Questions tagged [hooks]

Method by which plugins and themes extend core WordPress functionality.

Filter by
Sorted by
Tagged with
0 votes
1 answer
18 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
29 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
32 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
26 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
29 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
6 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
12 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
14 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
36 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
44 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
19 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
48 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
30 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
35 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
9 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
107 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
31 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
  • 286
0 votes
0 answers
15 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
15 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
25 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
11 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
40 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
13 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
17 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
17 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
30 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
  • 117
0 votes
0 answers
12 views

Hooks for Start/End of Batch Plugin Updates in wordpress

We're trying to get a hook to run before wordpress updates and after wordpress updates. We'd like this hook to run whether it's a)through the admin panel in these two cases: 1 - single plugin update ...
user avatar
0 votes
0 answers
14 views

Activation flow of a plugin in a multisite environment

I'm learning plugin development and I came across this issue where I need to activate my custom plugin and from my research on this topic there are three possible scenarios: Network admin activates ...
user avatar
0 votes
0 answers
18 views

Filter Media by attached page or blog post in Library

I am trying to create a filter using restrict_manage_posts that will filter all media according the page or post type that have been attached to. Actually i need to create a filter that refers to the ...
user avatar
0 votes
1 answer
32 views

How to alter taxes amounts when updating an order

I'm developing a plugin based on WooCommerce to allow ordering gift boxes. Each box is a WooCommerce product composed by multiple "alternative products" (that are made from a custom post ...
user avatar
0 votes
1 answer
26 views

Calling add_action on a filter hook?

I'm working with Ultimate Member plugin and while attempting to work through a modification I accidentally used add_action on a filter hook (not an action hook) and it still worked - as in the call ...
user avatar
1 vote
0 answers
33 views

Best action hook for placing ical requests

I would like to offer an iCal or webCal request on one of my pages. Which hook would be best to intercept the request that comes via URL? At the moment I use the following hook for this: add_action ( '...
user avatar
  • 11
0 votes
0 answers
24 views

'manage_users_custom_column' is a filter, but 'manage_posts_custom_column' is an action. Why?

I've been implementing some custom columns in admin tables for a Wordpress project, and I was caught out by the differences between manage_users_custom_column and manage_posts_custom_column (or ...
user avatar
0 votes
0 answers
29 views

remove_action('save_post') in function that was triggered by save post not working

The goal Update post title and slug on successful insertion into post table without re-triggering the save_post hook. Current behavior The function as it is, still triggers the save_post hook, even ...
user avatar
0 votes
0 answers
12 views

How to get template name or category before publish

I use wp_insert_post hook. I was trying to use get_page_template_slug, get_the_category, get_post_meta($post_id, '_wp_page_template', true) No success at all for a template. And category return ...
user avatar
1 vote
1 answer
106 views

How to add numeric slug for child page in WordPress 5.9?

I am trying to configure WordPress 5.9 to allow numeric slugs for child pages. Drawing from the 2015 answer to a similar question I took the up-to-date code of wp_unique_post_slug, removed || ...
user avatar
1 vote
1 answer
58 views

Should action callbacks start with a verb?

class Singleton { public function __construct() { // Case #1 add_action( 'woocommerce_before_shop_loop_item', [ $this, 'open_product_wrapper' ], 10 ); add_action( '...
user avatar
0 votes
1 answer
36 views

sortable columns for multiple custom post types not working

I have two custom post types named professor and campus. To each of these CPT's I have added two custom admin columns named image and last_modified, which currently display correctly on both CPT's ...
user avatar
  • 125
0 votes
1 answer
35 views

How to catch wordpress post ID when it's published

I am trying to either automatically a forum section when a post is published - like a discussion page. Normally, I wanted to make the users create the topic but I realized a forum category with many ...
user avatar
0 votes
0 answers
18 views

How to check if woocommerce_order_item_name is use in email?

I am using woocommerce_order_item_name to add meta info to item names in order detail page. I am adding a shortcode. Unfortunately the same shortcode is added to transactional emails and not parsed ...
user avatar
  • 1
0 votes
1 answer
53 views

Use a hook or filter, or overwrite this Gamipress function?

Currently, Gamipress allows you to import a CSV file that lists a username (email or ID), and a points value to add to the points type for that user. It uses this function to achieve this, which ...
user avatar
  • 33
0 votes
1 answer
18 views

How do I add a line break to a string that is output by PHP?

There is a heading output in my ad statistics page (WordPress): <h3 id="ad-title"><?php printf( __( 'Statistics for %s', 'advanced-ads-tracking' ), $ad_name ); ?></h3> I ...
user avatar
0 votes
1 answer
12 views

How to change Akismet commenter privacy notice?

I read the supposed explanation posted on their blog, and came away unenlightened. The following site-specific plugin does nothing (I have enabled it): <?php /* Plugin Name: Akismet Better Privacy ...
user avatar
1 vote
0 answers
15 views

Which WordPress hook fires after post content loaded?

Is there any hook that fires after post contents load? before comments and ... I need to add an element at the bottom of the post content.
user avatar
0 votes
0 answers
27 views

WordPress How to reorder Page/Post Settings

I am trying to move Yoast Seo to the bottom of my Post/Page settings sidebar. I am not sure how to hook into those so I can change the order. Order I need Status & Visibility Permalinks ...
user avatar
0 votes
0 answers
35 views

Hook from plugin doesn't fire up from external PHP script

I have this habit of installing a plugin with all my custom hooks, instead of writing a functions.php file with the same PHP code in it. That way I get the same functionality without the need of ...
user avatar
  • 121

1
2 3 4 5
45