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
9 views

register_rest_route, Compare purchase codes and send a response

I have a question, I would be grateful if someone could help me I am working on WordPress plugins, I have 2 files, the first file is Verification which is for users and the second file is the ...
pooyan golkar's user avatar
0 votes
0 answers
6 views

Phone number custom field and woocommerce updating issue noticed

I use Wordpress user frontend plugin to allow guests to post their woocommerce product on my website but I have observed some issues. Firstly, I added a phone number field in the form, then also added ...
Titus's user avatar
  • 1
0 votes
0 answers
10 views

(plesk)After adding 1000 youtube url to my 1000 different wordpress article, my all websites doesnt show yt url as embed

i added 1000 article with 1000 youtube url, i directly pasted youtube url, but after that, including that site, my all sites on my dedicated hosting doesnt show the youtube embed after i paste direct ...
teamzane's user avatar
0 votes
0 answers
8 views

Output categories as seperate list items instead of one paragraph [closed]

I have some code snippets provided by a plugin author as part of documentation to customise the plugin. It adds the ability to display categories on a store listing: add_filter( 'wpsl_store_meta', '...
Glasshalfpool's user avatar
0 votes
1 answer
14 views

How to capture number input from wordpress form into acf field in woocommerce

WUFP Phone fieldI am trying to capture the phone number of guests that submit a form on my woocommerce website using the advancedwoocommerce custom field for phone no custom field plugin. I noticed ...
Titus's user avatar
  • 1
0 votes
0 answers
16 views

Replace attribute terms with wp_update_term (woocommerce)

On the edit.php?post_type=product&page=product_attributes page I want to replace (when I import a product via my importer plugin) the term name of the Terms attribute with a new name. For example:...
Linux's user avatar
  • 1
0 votes
0 answers
8 views

How to add icon to WooCommerce add to cart button

in woocommerce, I want to add an icon from the iconify library to the add to cart button of my site I made some attempts, but I did not get the desired result. I used WooCommerce hooks, but this icon ...
MahmoodZamaniNemati's user avatar
0 votes
0 answers
12 views

How do I see logs of critical errors of specific pages without enabling public debug for everyone?

I have a site that works well in production, say with N pages currenly being used by users. I am doing some PHP scripting in one specific page and I want to debug some data. Usually in projects not ...
Xavi Montero's user avatar
0 votes
0 answers
8 views

How to fetch WordPress Gallery Images to a Custom Post Type?

I am using the WordPress Email Contact Form plugin to create a custom contact form. I want to be able to fetch images from the WordPress gallery and display them in the contact form. I have tried ...
Muhammad Usman Qureshi's user avatar
0 votes
0 answers
13 views

Creating product pages from excel sheet

Hi I need to create a script or use a plugin which will create product pages from an excel sheet. I have a very limited understanding of wordpress and PHP. And have been struggling with this problem. ...
JurTheProgrammer's user avatar
0 votes
0 answers
22 views

How prevent STDOUT of Plugin_Upgrader->upgrade(...)?

🖥️ Code function my_custom_endpoint(WP_REST_Request $request) { $plugin_file = $request->get_param("plugin_file"); if(!class_exists('Plugin_Upgrader')) { require_once ABSPATH ....
Adrien Villalonga's user avatar
0 votes
1 answer
25 views

WP_Error Object in wp_remote_post & wp_remote_get

I am using localhost and working on a wordpress plugin, I try to get and post data with wp_remote_get and wp_remote_post,i installed lmfwc and i create a rest-api-key, as you can see i used consumer ...
pooyan golkar's user avatar
0 votes
0 answers
19 views

Execute a PHP Function when a Block is used and access it's attributes

I've just build my first block using the @wordpress/create-block package. Everything is working as expected however I need to access the attributes on save and place a script containing a JSON schema ...
Walrus's user avatar
  • 111
0 votes
2 answers
33 views

Import Wordpress header / footer into an external page(s)

I have an external forum application, which has an option to include a header and footer as HTML. In theory I could use HTML to create the header, but this would be very hard to keep up to date, even ...
Ian's user avatar
  • 1
0 votes
1 answer
26 views

add_action() not working for admin

Making my own custom plugin and using add_action several times without a problem with one exception. Currently function below are located in functions.php in the appropriate themes folder. function ...
PerK's user avatar
  • 28
-1 votes
1 answer
21 views

Custom rest fields not loaded in rest api cpt response

I have a custom endpoint that will be used from my vue app to load custom post type I've registered using a custom plugin. I need to add some custom fields to the response when the posts are loaded ...
ICTDEV's user avatar
  • 111
0 votes
0 answers
12 views

Jetpack update causes Wordpress to report PHP Fatal error - relevance unclear

Upon updating the Jetpack by WordPress.com plugin from v7.7 to v12.5, WordPress v6.3.1 reports the following: PHP Fatal error: Uncaught Error: Class 'Automattic\Jetpack\Roles' not found in /www/wp-...
HeymJ's user avatar
  • 1
0 votes
0 answers
8 views

Add 2 links in between the navigation using the Breadcrumb Navxt plugin hook

I am using the Breadcrumb NavXT Plugin. I have 2 links at a page, and want to add 2 more links in between on that specific page. I used the below hook, but did not get the result. add_filter('...
Rizeen's user avatar
  • 101
0 votes
1 answer
20 views

how to test for options(fields) in settings API?

I've created an options page in wordpress with this code: <?php add_action( 'admin_menu', 'rtwhc_add_admin_menu' ); add_action( 'admin_init', 'rtwhc_settings_init' ); function rtwhc_add_admin_menu(...
rudtek's user avatar
  • 5,884
0 votes
0 answers
12 views

change the blog in the url if you go from a specific page wordpress

I have a products page on my site, and the products themselves are actually posts. And also, I have a blog with posts. When I am on the products page, I have a link like: site.com/products And go to ...
s.kuznetsov's user avatar
0 votes
1 answer
17 views

Remove custom menu pages for admin users

I've added some custom menù pages to my WordPress dashboard using the add_menu_page() function. I need to remove these pages for super admin roles, but the remove_menu_page() seems not working. This ...
ICTDEV's user avatar
  • 111
0 votes
0 answers
14 views

Custom uploader - Upload files and save link into database

I'm working on a file manager plugin. I need to store the saved files in custom folders and save the link into database to be able to get all the files and folders structure inside my vue front-end. ...
ICTDEV's user avatar
  • 111
0 votes
0 answers
13 views

Can external API content be added to Rest API in Wordpress

Is it possible to fetch data from an external API, and put them inside of Wordpress REST API? For example, schema would look like this $api = 'https://valorant-api.com/v1/agents'; $json_data = ...
Jovan Jovanovic's user avatar
0 votes
0 answers
16 views

Sort Woocommerce Products with Numbered Titles Numerically

I have a woocommerce shop with many products all of which have numbered titles from 1-3000 and the problem is, the alphabetical sorting is leaving me with an order like this: 1, 10, 11, 12, 100 and so ...
Hangman's user avatar
0 votes
0 answers
24 views

Implement Google SSO in custom plugin

I have this code that is used for the callback of a custom route public function login_user_with_google( WP_REST_Request $request ) { $client = new Google\Client(); $client->...
ICTDEV's user avatar
  • 111
0 votes
0 answers
13 views

Unable to use correctly composer autoload in plugin file

I've installed google php client library because I need to integrate some google services inside my wordpress dashboard. I've some classes that I will need to load inside my main plugin file, I've ...
ICTDEV's user avatar
  • 111
0 votes
0 answers
19 views

add class to woocommerce single product template gallery thumbnails if media attachment ACF field toggled (true/false)

i have the following custom field (quick_ship): i've added this in functions but not working at the moment: <?php $image = get_field('quick_ship'); $size = 'full'; // (thumbnail, medium, ...
vulgarbulgar's user avatar
0 votes
0 answers
11 views

Is It Possible to Block Redirect Checker Tools from Knowing Where URLs are Redirected?

I want to block URL Redirect Chain Checker tools such as wheregoes(.)com. Is it possible to do it? For example: wheregoes com/trace/20234194180/ this url can easily tell people where my affiliate link ...
Stephen Hawk's user avatar
0 votes
1 answer
11 views

CPU Overloading due to some hooks

I have some functions restricted in some hooks. The purpose of these hooks was to have consistent author name in the DB(which is a product attribute) and also update the display name. I placed this in ...
Varun Muchanapally's user avatar
0 votes
0 answers
9 views

Display WooCommerce Order Custom Field In Template (HPOS)

Until now, I used this code to display a order custom field value inside a template: <?php echo esc_html( get_post_meta( $order->get_id(), 'my_custom_field', true ) ); ?> When enabling HPOS ...
Daniel's user avatar
  • 1
0 votes
0 answers
12 views

How to make posts_like_dislike reference current post when iterating?

I am using plugin https://wordpress.org/plugins/posts-like-dislike/ . It adds a [posts_like_dislike] shortcode. When inside the default wordpress Twenty Twenty-Three in posts "Blog Home" ...
KamilCuk's user avatar
  • 101
1 vote
1 answer
37 views

Why does WordPress not make use of gettext directly?

When you develop WordPress plugins and internationalize them, the official WP docs instruct you to use gettext, by generating the according .po and .mo files. When your .mo files are however put to ...
DevelJoe's user avatar
  • 467
0 votes
1 answer
14 views

Only registered users can see part of the contents of single.php

On my wordpress blog, I want a part of single.php to be visible only to registered users. For example: /code/<?php the_title(); ?>/code/ Is there a function that works on a php basis? What ...
GbR's user avatar
  • 1
0 votes
0 answers
21 views

Sections dependent on checkbox the Wordpress WP_Customize_Control

I would need to create checkbox dependent sections in wordpress customization panel if possible. They should work so that when the checkbox is checked the section "eg 1" will be shown and ...
Josef Volný's user avatar
0 votes
0 answers
21 views

Help with get_categories code

I have listed the following code below, and where it is pulling the sub-title into the banner I need to change this to pull the category of the linked article instead. This is the link to the website ...
Richard Pearson's user avatar
1 vote
1 answer
29 views

WordPress theme requires PHP v >=8.1 - How to a dd different PHP version to docker-composer

I'm new to docker and stumbling into a PHP issue with a WP theme (sage 9). I can add a WordPress site, Database and phpmyadmin with no issues. But when visting the site, the below message displays ...
user avatar
1 vote
1 answer
63 views

Conditional concerning a selected tag not working

I'm trying to print some content in all the posts under a certain author only if a specific tag (default wp taxonomy) is set the tag is "animali permessi" here is the code $posttags = '...
Andrea Sacconi's user avatar
0 votes
0 answers
11 views

AND and OR in my CPT search query depending on checkbox

I have a checkbox, that when checked is supposed to change a query from AND to OR. The moods, genres and the checkbox data comes through just fine via a ajax call, and based on this, it will filter a ...
Jannickla's user avatar
0 votes
1 answer
24 views

Get a list of folders inside uploads directory

I know I can create a folder in uploads directory using wp_mkdir_p() function of WordPress. I'm working on a file manager that will use the rest api to get a list of files since it's vue based for the ...
ICTDEV's user avatar
  • 111
0 votes
1 answer
32 views

REST API - filters not working inside plugin class

I have this code inside plugin I'm writing. I need to add some filters to customize WP REST API anyway I'm noticing that filters seems not working if( !defined( 'ABSPATH' ) ) { exit; } class ...
ICTDEV's user avatar
  • 111
0 votes
1 answer
15 views

condition for specific pages

I have a php page template used for all archive product categories. If I want to change the button on one of the categories, is there an 'if' 'then' condition I can put in? e.g button for all ...
imdes's user avatar
  • 1
0 votes
0 answers
16 views

Using .net VB I ftp an image to woocommerce but it wrongly places it in a non existent URL

I place an image using a FTP upload(.net vb) in the folder https://streetgym.co.za/wp-content/uploads/ProductImage/2-807.jpg; wordpress then creates a url AT https://streetgym.co.za/wp-content/uploads/...
BASit Bulbulia's user avatar
0 votes
0 answers
12 views

change Dashboard default page on login

I found almost the same question here - Remove dashboard, use Pages tab as default and I tried to implement it for my own needs and couldn't get it to work. I am doing a hotel site and I am making a ...
Will Bode's user avatar
0 votes
1 answer
30 views

I'm unable to remove the code that I used to restrict access to the profile page for subscribers

Even after I removed the code, I am still getting the error message "Sorry, you are not allowed to access this page." please help me to fix this function remove_read_wpse_93843(){ $...
Roma VV's user avatar
0 votes
0 answers
26 views

Is it possible to go to the next post in the same category?

Is there someone who can help me to change the code so the button goes to the next post in the same category? TaaaaannnnnXXXX <div class="nk-pagination nk-pagination-center"> ...
Jasper Stamm's user avatar
0 votes
1 answer
24 views

Wordpress Product Page Change Label From 'Category' to 'Artist'

I would like to add a php snippet to Change Label From 'Category' to 'Artist' on wordpress product pages (alternatively throughout the whole site) I see many examples of how to remove the label, but ...
Peter M's user avatar
1 vote
1 answer
140 views

PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in Stack trace:\n#0 [internal function]: img_caption_shortcode()

Why am I getting this error in my apache logs? ==> tech.michaelaltfield.net/error.log <== [Wed Aug 23 00:00:09.968658 2023] [php:error] [pid 459909] [client 0.0.0.0:0] PHP Fatal error: Uncaught ...
Michael Altfield's user avatar
0 votes
0 answers
18 views

Programmatic replacement of Publish date with Modified date does not work outside the_content area

I am having a problem replacing the Publish date with the Modified date when the theme is created using Avada Theme Builder. The following code works fine on a theme created with Elementor: add_filter(...
bee's user avatar
  • 1
0 votes
0 answers
87 views

Send summary email from a form with wp_mail

I'm trying to send two emails (one to the site manager and one to the user) with the data entered in a contact form made by me and placed in a wordpress template, but this doesn't work. i am using ...
LesCa's user avatar
  • 21
0 votes
0 answers
21 views

Trying to add a wp block and update the post content using PHP (wp_post_update)

I'm looking to write some PHP code that will be capable of looping through all of a certain custom post type and adding a specific block to the post_content, and then updating the post. For testing, I'...
Jordan K's user avatar

1
2 3 4 5
209