Skip to main content

Questions tagged [php]

For questions about the server-side programming language that the WordPress core, plugins and themes are written in. Questions about using PHP outside a WordPress context are off-topic but might be asked on Stack Overflow.

0 votes
1 answer
355 views

WordPress PHP8.2 Critical Error in class-wp-widget.php

Recently updated to PHP8.2 and I'm getting a critical error related to the theme. The critical error is: Fatal error: Uncaught ArgumentCountError: Too few arguments to function WP_Widget::__construct()...
miko's user avatar
  • 1
1 vote
1 answer
47 views

How to temporarily set the featured image for a post when the post is loaded

I like to set my hero sections of my site to dynamically use the featured image as the background. This works great for most things but sometimes not, such as when it's an archive page and it just ...
dovidev's user avatar
  • 121
0 votes
1 answer
241 views

do_blocks not working with a custom block

i am trying to render one of my custom blocks inside a PHP file: <?php $block_content = do_blocks( ' <!-- wp:create-block/gb-button-block /-->' ); echo $block_content; ...
JPD's user avatar
  • 13
0 votes
1 answer
36 views

Updates applied to staging WordPress site affecting production even with different databases

I am experiencing strange database-related behaviours on my server that hosts a few versions of the same website. The problem relates to making content and theme updates to one of the subdomain sites ...
Mike Hermary's user avatar
0 votes
0 answers
36 views

How to change product title color in shop page if product has specific product tag (Woocommerce)?

How to make Woocommerce automatically change product title color for shop page if product has specific product tag (Woocommerce)? Example: if products have tag "banana" or "melon", ...
null's user avatar
  • 1
0 votes
3 answers
130 views

Modify the permalink structure for a specific category

I searched for many solutions before opening this post, but none worked correctly. This is a complicated matter because it can significantly impact the site if not done correctly. I need to have a ...
Jader's user avatar
  • 1
0 votes
0 answers
22 views

If you want to implement custom field-wise search functionality in the WordPress admin area

function extend_admin_search( $query ) { // Extend search for document post type $post_type = 'document'; // Custom fields to search for $custom_fields = array( "...
Tansukh Parmar's user avatar
0 votes
0 answers
51 views

Resolving Google Search Console Error: Video Too Tall for Embedded YouTube URLs

I'm facing a Google Search Console error stating "Video Too Tall" for embedded YouTube URLs on my WordPress site. I found a PHP snippet that claims to fix this by setting a specific height ...
user avatar
0 votes
0 answers
53 views

Display featured posts first, then display all others within a specific category in WordPress

I want to display featured posts first, then all other posts not marked as featured on a category archive page. I am using a plugin that has functionality to mark posts as featured. I have figured out ...
user1462's user avatar
  • 1,294
0 votes
1 answer
274 views

Parse error: syntax error, unexpected token "endif", expecting end of file in C:\xampp\htdocs\Blog\register.php

I am trying this code but not getting the result, what should I have to try? <?php if(count($errors) > 0): ?> <div class="msg error"> <?php foreach ($errors as $...
Manish's user avatar
  • 1
0 votes
0 answers
111 views

How can I modify the shortcode values of a nextgen gallery using php?

I am trying to modify the parameters of a NextGen gallery shortcode when displayed in a theme template. I paste the shortcode into an ACF WYSIWYG field like this [ngg src="galleries" ids=&...
Destiny2Gamer's user avatar
0 votes
0 answers
33 views

How to add input field value to Users in Wordpress Dashboard

I've got a request where the client would like to store provided emails in the WordPress Dashboard so they can access them for marketing. I've added an email input field like so: <div class="...
Simon Lowe's user avatar
0 votes
0 answers
33 views

What is the error and how can I fix it please?

Notice: Function is_post_type_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for ...
Ashraf's user avatar
  • 1
0 votes
1 answer
56 views

Encountering 400 Bad Request Error When Sending Form Information to API through Elementor

I’m currently working with an API and Elementor, and I’m trying to send form information to the platform API. However, I’m encountering a 400 Bad Request error when making a request to my server. The ...
Diane Rendel's user avatar
0 votes
0 answers
5 views

"Joined in" or "Member since" displayed on single store page and then using shortcode to add

I'm trying to add the registration date of users (vendors) to my single store page. This would ideally read "member since (date)". I also want to use shortcode so I can apply this manually ...
MattyC's user avatar
  • 1
0 votes
0 answers
53 views

Send email with a PDF embedded

I am trying to send an email with a PDF embedded in the body of the email. The email gets sent, but the PDF doesn't show up. If I view the source of the email, the code does show the embedded PDF, but ...
Darth Mikey D's user avatar
0 votes
0 answers
76 views

Trouble Sending Elementor Form Data via cURL in WordPress

I'm adapting the code to retrieve information from the Elementor form. I've referred to the documentation, and I have an example code snippet. function send_custom_webhook( $record, $handler ) { ...
Diane Rendel's user avatar
0 votes
0 answers
27 views

WooCommerce / Elementor change Add To Cart button text and link for variable products

I'm trying to edit the 'add to cart' button on WooCommerce and I'm using Elementor products widget to show them on shop page and other category pages. I need to change the button text to 'Quick Add' ...
Matt's user avatar
  • 1
1 vote
1 answer
30 views

Trouble with WordPress Settings API: Form Submits When Fields Called Directly, Fails When Using Callbacks

0 I'm working on a WordPress plugin and facing an issue with the Settings API. I have a settings page with two forms. The first form uses do_settings_sections() to call fields from a public function (...
user2765920's user avatar
0 votes
1 answer
33 views

Bring your own theme to PHP 8

My self-created theme no longer works under PHP 8. I would like to change it so that it continues to work. Currently only the navigation is displayed. I have deactivated all plugins. I have tried to ...
johannes_k's user avatar
0 votes
0 answers
7 views

Quiz page template, checked attribute missing when option selected

I would like to add a quiz page template to my WordPress site. Part of the template is the code below. The problem is that when any of the inputs is selected, the checked attribute is missing. <div ...
Kostas Stoumpos's user avatar
0 votes
0 answers
35 views

How to pass php array to external js file in WordPress

I am trying to pass my php array to my external js file. PHP if (!function_exists('myScripts')) { function myScripts() { wp_enqueue_style('my-css', get_stylesheet_directory_uri() . '/...
DigitalDesigner's user avatar
0 votes
0 answers
62 views

Uncaught Error: Class ‘WP_Upgrader_Skin’ not found

WP-CLI 2.9.0 run with –debug …. Debug (bootstrap): argv: /bin/wp core check-update –debug –path=/home/web/public_html (0.752s) Debug (bootstrap): ABSPATH defined: /home/web/public_html/ (0.752s) Debug ...
Jimmy's user avatar
  • 1
0 votes
1 answer
54 views

Mixed results with is_page() WordPress function, when using $this, or self

I'm converting an old plugin from PHP5 -> PHP8 and I came across this check, which caused an error when executing: Notice: Accessing static property PropertySearch::$listing_details_template_name ...
level42's user avatar
  • 113
0 votes
0 answers
121 views

call_user_func_array() expects parameter 1 to be a valid callback, class 'Automattic\Jetpack\Extensions\Contact_Form\Contact_Form_Block' not found

I got his error message above every page of my website, https://changyuan.com.tw/: Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Automattic\Jetpack\Extensions\...
Chipmunkai's user avatar
0 votes
1 answer
25 views

Check for a value in a custom query

I have a custom query to show people working in a specific division (label) in an organisation. I want to display the specific division’s name before the cards of the people are displayed. Currently I ...
Woohoo's user avatar
  • 1
0 votes
0 answers
24 views

Insert attributes names according to language with polylang programmatically

This is my problem. I try to insert in _product_attributes meta_value field the names of each language. When I print out my query, I am getting only the products in the right language, so ...
Rich's user avatar
  • 1
0 votes
0 answers
22 views

How can I process data in parts to prevent Fatal error: Maximum execution time of 30 seconds exceeded

In a Wordpress plugin I am trying to copy bulk posts all at once. This takes a long time for complicated posts with lots of settings and content etc , is there a way to break up the process into ...
Enjabain's user avatar
  • 101
0 votes
0 answers
48 views

How to set default product type in WooCommerce to External/Affiliate

I've been struggling to set the default product type in WooCommerce to be "External/Affiliate". I tried every line of code I found in this forum but none of them seem to be working. ...
Chris's user avatar
  • 13
0 votes
1 answer
69 views

How can I run a second wp_remote_post() based on the response of the first?

I'm using wp_remote_post() to integrate with an API that requires me to send one request after another to a REST API. (The first to create a user record, the second to add a tag to it). Using Guzzle I ...
fyrekcaz's user avatar
0 votes
0 answers
22 views

check difference between two timestamp in custom plugin

I have this code in my custom plugin. It's supposed to check if a timestamp is older than 24 hours $today = new DateTime(); foreach( $customers_to_activate as $customer_details ){ $time = $...
OHICT's user avatar
  • 133
0 votes
0 answers
36 views

Edit password change email text or disable it

I have a function in my custom plugin that will be called after the user do the fisrt login. The function, after a check will give to the user the ability to change it's assigned password with a ...
OHICT's user avatar
  • 133
0 votes
1 answer
285 views

Where is WooCommerce order shipping methods stored

I need to create statistic about shipping methods used. I know that there a method get_shipping_methods() but it takes a very long time to use it with tens of thousands of orders. I would like to ...
Vlado's user avatar
  • 111
0 votes
0 answers
14 views

Help with uploading file with AJAX and PHP

I have a form that I am trying to upload a file to the server with and then save the info to the database. Saving the info to the database works fine except for the file information and the file doesn'...
Darth Mikey D's user avatar
0 votes
0 answers
173 views

PHP is NOT allowed in your code (disabled by your theme or a plugin)

I am using the Head, Footer, and Post injections plugin and it is displaying this error. I am using the plugin to create a lightbox that will handle booking appointments, and everything about the ...
Callum's user avatar
  • 1
0 votes
0 answers
53 views

ACF block gutenberg aligncenter don't work

I'm starting with creating Gutenberg blocks with ACF. I would like to create a simple button, so far so good. My problem comes from the center alignment. When I align my element to the left and right ...
user avatar
0 votes
0 answers
47 views

Help with creating commenting system using PHP, jQuery and AJAX

I am working on creating a comment system for an events plugin I am working on. I've got the main comments working fine with them saving to the database and displaying on the page. What I need help ...
Darth Mikey D's user avatar
1 vote
0 answers
45 views

Using send_password_email filter after wp_update_user

I have created a custom plugin that will provide some custom user roles that are named customers and operators. When an user will create a new account, I've created some logics that imply that ...
OHICT's user avatar
  • 133
0 votes
0 answers
43 views

Change WordPress Multisite Domain to subfolder

I want to change my existing WordPress Multisite main site to be in a folder. For example, this is my current main site of the network: example.com. Other domains in the network have folders like ...
Cray's user avatar
  • 145
1 vote
0 answers
367 views

"Object-cache.php" disables wp_cron and even disables my entire site, and keeps reappearing by itself again after I delete it

I'm having a truly maddening issue. It may involve plugins (or it may not, I don't know) but I believe it is sufficiently technical to be allowed here. A few weeks ago, I needed to revert to a backup, ...
John Smith's user avatar
0 votes
0 answers
186 views

Application password header not checked in REST API

I have this code in my custom plugin. I've created an application password and I want to check it every time a custom endpoint is called. register_rest_route( $this->namespace, ...
OHICT's user avatar
  • 133
0 votes
1 answer
47 views

What is the PHP Code for Woo Customer Type (New/Returning)

I've seen that there is a Customer Type column in the in-built Analytics. Can someone tell me the php code for this? I want to use it somewhere else and it seems like a ready function which I could ...
Csaba.io's user avatar
0 votes
1 answer
54 views

Redirect WordPress page to the latest created post by the logged in author/user

I have a basic WordPress code that redirects someone to the last post type created on the site, in this case is the "case" post type: <?php /* Template Name: Redirect */ $args = ...
Sean Bagheri's user avatar
0 votes
0 answers
81 views

"Virtual" image in WP Media Library (external URL)

We are using a CDN in an external system (DAM) to store all of our images, and I am trying to find a way to integrate this to WordPress. The functionality I would like to achieve is: Use the WP Media ...
user2868900's user avatar
0 votes
3 answers
77 views

Help with AJAX request

I am creating an events plugin with a commenting section for each event. I am able to save each comment, but the problem I'm having now is that I am taken to admin-ajax.php which is blank. When the ...
Darth Mikey D's user avatar
0 votes
1 answer
18 views

Compare user meta values before update them

I have this pseudo code I'm writing to compare the user meta values. I have some user meta that will hold a null value until the user update his account, before the values are updated I need to check ...
OHICT's user avatar
  • 133
0 votes
0 answers
41 views

404 error on page reload

I have created a WordPress based web app that will rely on template pages that will host some vue.js different front-end apps. I've added this code to the theme functions file to rewrite all the ...
OHICT's user avatar
  • 133
0 votes
1 answer
94 views

Execute scheduled cron with ajax call to wp-cron.php

According to this question where my doubt on how to schedule an email sending each 24 hours, I've modified my plugin code to use a custom action hook and the wp_schedule_single_event() to achive the ...
OHICT's user avatar
  • 133
0 votes
0 answers
20 views

Scrape Meta data from another platform and put in wordpress site

I've recently built a site in wordpress and the original site was using Travelize CMS as backend. But in the original site there were meta data in all the pages which aren't currently available in the ...
buzz's user avatar
  • 101
0 votes
1 answer
1k views

PHP Warning: Attempt to read property "id" on null

I'm receiving a php warning in the error when I run the below script in the footer.php file. The code works but is there is a way to write it better? <?php global $product; $mpn = ...
Ricardo Parsons's user avatar

15 30 50 per page
1
3 4
5
6 7
212