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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
50 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
48 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,284
0 votes
1 answer
93 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
74 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
27 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
23 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
43 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
4 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
19 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
52 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
20 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
29 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
22 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
39 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
40 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
92 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
21 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
17 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
20 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
32 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
46 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
19 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 = $...
ICTDEV's user avatar
  • 113
0 votes
0 answers
26 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 ...
ICTDEV's user avatar
  • 113
0 votes
1 answer
92 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
13 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
102 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
34 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 ...
Thica's user avatar
  • 17
0 votes
0 answers
35 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
0 votes
0 answers
23 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 ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
24 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
133 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
122 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, ...
ICTDEV's user avatar
  • 113
0 votes
1 answer
22 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
35 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
26 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
54 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
15 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 ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
29 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 ...
ICTDEV's user avatar
  • 113
0 votes
1 answer
51 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 ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
14 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
564 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
0 votes
0 answers
24 views

How to pull through page title depending on which radio button is selected on the specific page?

I'm pretty new to Wordpress, ACF and PHP. I am currently working on a project, the website has 11 different sports centres all with different sport/activities, on each centre they will have a sidebar ...
jonnyplat's user avatar
0 votes
0 answers
13 views

comments meta box not showing in my plugin post type

I´m still pretty new to coding, I might not understand lingo very well, but let me explain the best I can. here is an image of what I want. this is the comic easel plugin. I have comments checked in ...
Lunarian3's user avatar
0 votes
1 answer
13 views

Deleting all CPT related to user deleting

i have some Custom post type with "user-id" metakey how can i delete all row in table on deleting user request? the user is not author of post, he have only metakey (user_id) stored inside ...
Fabio's user avatar
  • 1
1 vote
0 answers
46 views

WordPress PHP Redirect - which hook to use?

I have site where users sign up to a subscription. When the subscription has ended (I can query that using PHP), I want the user to be redirected to the "subscription-ended" page. My current ...
roland's user avatar
  • 21
0 votes
2 answers
191 views

wp_mail - send emails after 24 hours from users registration

I have writed a lugin that will send emails after the user completed a custom registration form. I need to send emails after 24 hours from registration, is this possible by using the wp mail function? ...
ICTDEV's user avatar
  • 113
0 votes
1 answer
20 views

Update shortcode values using ajax call

I'm having a problem with a calendar, I've made a shortcode which returns events links in a grid that shows the current month view. I set $month_index in order to navigate through months (default is 0 ...
Enrico's user avatar
  • 11
0 votes
1 answer
66 views

Display two previous posts on single.php

At the bottom of single.php, I want to display "card" links to the next and previous posts in chronological order. This is pretty easy thanks to get_next_post() and get_previous_post, no ...
doofusb0y's user avatar