All Questions
3,069 questions
3
votes
1
answer
290
views
What is the best filter where to use register_block_type?
I'm using register_block_type to register my blocks.
I'm not sure what is the best hook to use, between init and enqueue_block_editor_assets.
I suppose that enqueue_block_editor_assets it is loaded ...
0
votes
1
answer
54
views
I'm having trouble with Related Product "tax_query" 'terms' value
I have two custom page types. the first is "product" and the second is "accessories". On the product page, there is the accessories category "inputs" raleted post. Inputs ...
0
votes
1
answer
108
views
Is there a way to know when a page has been updated and do some action only once?
Have few pages in wordpress cms. Whenever any page is published or updated, there is need to do some action (basically call an API to update some data in another backend service).
For publish, I am ...
0
votes
1
answer
141
views
add_action taking an array with the 2nd argument?
I was going through some source code of Astra theme and found these lines in theme/astra/inc/class-astra-loop.php:
class Astra_Loop {
.....
public function __construct() {
add_action(...
0
votes
2
answers
223
views
Show meta box only for default page template
I'm having an issue with one of my meta box. I want the meta box displayed only on the default page template editing page.php.
The meta box doesn't show up on the editing page.
add_action('...
0
votes
1
answer
479
views
style_loader_tag not changing stylesheet to preload
I am trying to change rel='stylesheet' to rel='preload' using style_loader_tag but it isn't doing something. Could anyone please tell me what is wrong with my code?
add_filter( 'style_loader_tag', '...
1
vote
1
answer
462
views
add element with add_action to posts from a specific category ID
I just try to add some content at the bottom of each posts from a specific category but the content is added in all posts. I use a hook in GeneratePress theme. I don't understand why it is not working....
0
votes
1
answer
487
views
I need help using pre_get_comments to limit comments in the comments admin screen
I am trying to limit the comments in the comments admin screen to:
Display all comments for the current user
Display all the comments made on the current user's post
if(!current_user_can('...
1
vote
1
answer
731
views
How to redirect user after login to a specific page?
I have a page with mixed content in three different tabs. The first tab is open access to all but the content of the last two are for logged in users only so by sending the users to login with:
<p&...
0
votes
1
answer
1k
views
Illegal string offset in PHP function
I'm creating a metabox to upload PDF files.
I have the following warning notice for this line of code: $this_file = $filearray['url'];
Warning: Illegal string offset ‘url’ in...
The complete function ...
0
votes
2
answers
406
views
How to check in functions.php if there is data in a WP_Query?
I have 2 different WP Query on the home page.
I need to check $home_query condition in functions.php then I want to do something if $home_query returns null.
I tried with pre_get_posts action I couldn'...
0
votes
0
answers
276
views
do_action in API call
I have a woocommerce plugin and it provides an API url ?wc-api=myplugin.
The plugin adds a new email also.
function add_newstatus_woocommerce_email( $email_classes ) {
require( 'emails/class-...
0
votes
0
answers
82
views
Display metabox galleries on specific page template in admin editor
I'm building a Wordpress website with two metabox galleries displayed only on post type page in admin editor.
What I'm trying to do is to display them only for a specific template page in the admin ...
0
votes
0
answers
160
views
Add metabox to pages that use custom template in WordPress
I am trying to add custom metaboxes to only those pages that use a certain custom template that is applied to them.
How can i do this? I based on this this guide:
How to add add_meta_box to specific ...
1
vote
1
answer
135
views
Can the wp_filter object hold multiple values with the same key
I'm trying to understand the internals of the $wp_filter object and I'm looking at the code posted by Fuxia in this question How to know what functions are hooked to an action/filter?
function ...
1
vote
0
answers
258
views
How to use custom form on add_meta_boxes callback
I am trying to trigger the echo when the form button will click.
but not able to do this. if I don't use form and direct echo there. this is working. but when I use a form, it's not working.
can ...
0
votes
0
answers
585
views
Adding link options in insert/edit link dialog window
Good afternoon! I am looking for a way to insert a text box inside this insert/edit link dialog window. Due to googles recent changes for rel/nofollow links, we would like to insert an option to add a ...
0
votes
1
answer
80
views
How to 'clone' select metabox options with a callback function? [closed]
Here is my metabox
array(
'id' => 'all_btns',
'name' => 'Button Select',
'type' => 'select',
'options' => array(
'button' =&...
1
vote
1
answer
777
views
Gutenberg - Dispatch action or setAttributes() on Post Save/Update action instead of onChange listener
I have a requirement to add up to 8 user selected custom colors to the list of default options when using the Colour Palette.
I have registered a meta that saves custom colours.
Problem:
I want to ...
0
votes
1
answer
39
views
WP nonce field checkbox prints checked='checked' outside input field
I'm currently creating a custom post type in wich I want to add some custom meta boxes. All the fields just go as expected excepting a checkbox field wich prints on the html checked='checked' after ...
0
votes
0
answers
224
views
Add Tag to post after publishing
I want to add a specific tag to posts being published, I tried the following code and searched for answers here but it doesn't work. Does anyone have an idea why?
function tag_to_published_post( $...
0
votes
0
answers
237
views
Render metabox gallery in frontend
I'm building two metabox galleries on the same page with the help of a tutorial. The code works fine. However the galleries are automatically displayed after the content on the front end.
What I would ...
0
votes
0
answers
429
views
Making custom meta box required (with error message if not filled in) on Gutenberg
<input required name="myName" type="text" value="<?php echo $myValue; ?>" class="regular-text">
Does not produce an error message if the field is ...
0
votes
0
answers
312
views
HTML for adding a meta box (basic text field) to page editor?
I am following this tutorial from to add a meta box to pages of a certain page template.
Unfortunately the code omits the part on how to create the actual meta box on the page (the HTML).
The code in ...
0
votes
1
answer
299
views
Dequeue styles with query doesn't work
In my theme there is the following code (that is printing some inline css on the head of my site)
final class Design_Scheme {
/**
* Design_Scheme constructor.
*/
private function __construct() {
...
1
vote
1
answer
534
views
remove an action hook function on a plugin from a theme
first I did my homework by checking the answer on this question and this question, both didn't work.
after long debuging the function I want to remove is protected in 2 nested classes, and follows ...
0
votes
1
answer
187
views
How can I specify the post status of an untrashed post?
By default Wordpress assigns the draft status to a post that has been untrashed. I would like to assign the pending status to posts that are untrashed.
This seems to be possible with ...
0
votes
0
answers
49
views
Remove Username and just show Name in Author Metabox in backend
In the Author Metaboxes for Posts / pages / custom types, it shows: Name (Username)
Is there anyway to customize this to just show Name only? Or maybe Name and Role?
I am pretty sure if it done with ...
0
votes
0
answers
18
views
How can Use custom input field in functions.php page?
I have if clause to add action in functions.php page. But I want to give condition value from dashboard as a custom input instead of defining it functions.php. When I am trying 'echo get_field('...
0
votes
1
answer
378
views
update_option_{$option} not working (do function after options are saved)
Below is my code for a simple plugin settings page. It works and saves an option ("EN", "CZ").
However, what I intend to do is run a function after the options get saved (see at ...
0
votes
1
answer
896
views
How to modify the output of wp_terms_checklist when used within the built-in category metabox on edit posts?
On the Edit Screen in the WP Admin there is a meta box for WP's built-in Category taxonomy. This meta box is built using post_categories_meta_box() (/wp-admin/includes/meta-boxes.php).
This meta box ...
0
votes
1
answer
168
views
How can I collect and output all attributes of all executed ShortCodes?
I would like to collect all attributes of the shortcodes that are stored in a page in the ShortCodes and then output them all.
I do these in a Plugin.
1.) Set a global Variable in init.php ==> $...
0
votes
1
answer
61
views
remove_action: how to access to a method in an child class?
I've this in my main plugin file:
$main_admin_class = new MainAdminClass();
$main_admin_class->init();
MainAdminClass has this code:
class MainAdminClass {
public function init() {
$...
0
votes
1
answer
51
views
I would like to send a notification email (Asana) whenever something is published (posts, pages, custom post types) [duplicate]
The code below works perfectly
When I create a new post, an email is sent out to the email included in the function.
I would like to know how I can send an email when anything is published on the ...
-1
votes
1
answer
73
views
Remove action of an external plugin after checking if custom post meta is set
Edit:The problem were 2 folds - somehow the order list I found before indicated wp_head was before wp_enqueue_scripts but that is not the case. Found another more updated one and it is actually right ...
0
votes
1
answer
195
views
How to hide metaboxes in WordPress Admin on WooCommerce "Add Product" page - Remove side sortables for a specific user role
How do I hide certain metaboxes in WordPress Admin screen options for specific user roles?
For example, I allow the user role "Store Vendor" to access the WordPress admin to upload their ...
0
votes
1
answer
199
views
default post thumbnail and category if there is no thumbnail and category
I want to do following...
1 - Publish the new post,
2 - Check if this new post has a featured image,
3 - If it has not a featured image, define its category and save the specific prepared image as the ...
1
vote
1
answer
233
views
Custom HTML in specific category single page and its descendant categories
I am trying to insert a "style" in single page of a category and its child categories.
.relatednews{display:none}.
I inserted the following code in functions.php of Child Theme, but it didn'...
0
votes
0
answers
172
views
Post and Pages section inside WordPress admin are completely blank
Meta Tags - Undefined array due to meta tags!
I have created my own custom post meta tags but all works fine until I test my WordPress theme on the new WordPress Installation.
What I came through ...
1
vote
0
answers
41
views
Change the context of excerpt metabox for the 'New Post' page
With the Gutenberg layout, is it possible to adjust the context, or position, of the Excerpt metabox from the sidebar of the 'New Post' or 'Edit Post' admin page, to the main area, i.e. to a 'normal' ...
0
votes
0
answers
78
views
How to redirect a unique link based on login status
I have webstore on woocommerce, and on one of my wordpress pages (that page is not woocommerce page, but just wordpress and it is edited by Colibri free theme) I have download links for some products.
...
0
votes
1
answer
81
views
Unable to display selected post title in frontend from metabox wp_dropdown_pages()
I created a metabox in admin using wp_dropdown_pages() to display the list of posts from my custom post type workshop. The metabox dropdown works fine in admin, I can select the post title and save it....
1
vote
0
answers
75
views
How to detect if metabox content was updated by the user
I am handling metaboxes and their updating process the standard way:
// Attached to the save_post hook
function the_save_stuff_handler($post_id, $post){
// Early return
if(defined('...
0
votes
1
answer
141
views
Show metabox value last post excerpt, title and link
I'm facing a problem I can't solve.
I'd like to get the excerpt, title and link of the last post containing a particular meta-box button status.
For example: I would like to retrieve the last post ...
0
votes
1
answer
25
views
Gravity Forms parameters return 1
I'm not sure what's causing gravity forms $entry and $form parameters to return 1.
Here is my class.
namespace GrvityFormsIntegration\DataTools;
ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
...
4
votes
2
answers
3k
views
How to check if which hook triggered the call to a function?
I have a situation where I have a function hooked to more than one custom hooks.
How to check in the callback function which custom hook triggered the call?
Or the question in code will be
add_action('...
0
votes
1
answer
53
views
Move the metaboxes to the very top of post editor
I have this function that creates a custom metabox (with the metabox .io plugin), i would like the metabox to stay on top just below the title field
this is the code i am using
function generator_api()...
0
votes
1
answer
35
views
Nested "do" and "add" Actions is possible?
I'm wondering
Questions were asked about more than one "add_action" and filter nested before and it was deemed possible.
Are nested cross actions added?
Eg.
add_action('init', function(){
...
8
votes
2
answers
1k
views
Do WordPress' cron's clean up expired transients?
WordPress has a cron named "delete_expired_transients" as seen in the image below.
In this way, does it clean expired transients daily?
Or is it just giving us action?
Should we clean it ...
4
votes
2
answers
2k
views
Hooking new functions to actions + passing parameters
I am trying to understand some fundamentals of php with regards to adding new functions to actions. I found a tutorial where he adds a new function to the save_post action…
add_action('save_post', '...