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
1 answer
25 views

Remove links to the comments section

I need to remove links to the comments section from every post and page on the site. Links to comments look like this: These links appear: In the post's byline as a speech bubble icon with the ...
Dave's user avatar
  • 119
1 vote
0 answers
11 views

WordPress add_rewrite_rule not working with page_on_front

I am using the following code to rewrite "example.com?my_var=test" to "example.com/my_var/test": function my_query_vars($vars) { $vars[] = 'my_var'; return $vars; } ...
Jan K's user avatar
  • 11
0 votes
1 answer
56 views

How to make Wordpress Plugin run on single specific Admin Page

I've written a plugin and it has regular functions and a few class functions. At the end of the class function I have a line that runs the class like this: $the_function = new the_function(); The ...
Angel Hess's user avatar
0 votes
0 answers
17 views

Customize product card Up-sell on Woocomerce

I changed the product cards to also show the category and short description of the product but I can't show it in up-sell products. this is the code i used function category_single_product(){ $...
LesCa's user avatar
  • 21
0 votes
0 answers
31 views

Change WooCommerce Product Permalink Structure

According to my suppliers they want the local site and the international site to have the same product URL's just different domain. However my site is built on WooCommerce and there's is a custom PHP ...
Alex Moura's user avatar
0 votes
0 answers
15 views

Show the value of the custom field of the order on the My Account Front-end page

I would like to show the value of the custom fields filled during the order also in the frontend my account page. This is the URL of the location: https://example.it/my-account/view-order/860/ I would ...
LesCa's user avatar
  • 21
0 votes
1 answer
48 views

How to show a message after submitting a form (form made using plugin)

I want to show a message either on the same page or different page after the user submits the form. The form is implemented using the user registration plugin, using a shortcode. I tried the following ...
Tom532's user avatar
  • 1
0 votes
1 answer
43 views

How to pass variable from wp_loaded hook to custom function?

I'm editing functions.php of my theme, and I'm having trouble passing hook $_GET value from hook to function. Here is the hook to get URL parameter: // Get sender email via URL parameter - returns the ...
Yotam Dahan's user avatar
0 votes
1 answer
56 views

Restricting Image Upload Sizes using 'wp_handle_upload_prefilter' - Stuck media progress bar when Featured Image?

I have grabbed this function and adjusted it to my needs. add_filter( 'wp_handle_upload_prefilter', 'check_image_dimensions_during_upload' ); function check_image_dimensions_during_upload( $file ){ ...
dekkyd's user avatar
  • 5
0 votes
0 answers
17 views

Updating post_parent caused the website to become unresponsive for 40 seconds or more

I am building a WordPress plugin the sets the post_parent of a post to the id of a custom post type called series. However, once I click update on the post it successfully updates the post and the ...
Petar Vasilev's user avatar
0 votes
0 answers
23 views

block the cart to a product without blocking the quantity

I'm creating a course site where it is possible to register and pay via Woocomerce, I need to block the possibility of adding multiple courses (products) to the cart but leave the possibility to ...
LesCa's user avatar
  • 21
0 votes
0 answers
9 views

woocommerce new order alert on a specific non admin page

I'm relatively new to WordPress but have basic understanding of how it works; I have a page where non admins can see woocommerce orders, I want to trigger a popup on this page when there is a new ...
petey's user avatar
  • 1
-1 votes
2 answers
54 views

How to add global CSS to all webpages without installing any plugin?

Version 6.3 core website; no plugins, no themes, no customizations whatsoever. Plain core website which should stay plain core. I want to add global CSS that will effect all webpages but without ...
templater's user avatar
0 votes
2 answers
31 views

Display data with a yes or no condition ACF

There is a condition that is fulfilled via ACF yes or no and if it is fulfilled (yes) then I need to display part of my code, if (no) then don't need to display anything $output .= $value = get_field( ...
Dmitriy Moiseenko's user avatar
1 vote
0 answers
32 views

Updated theme conflicts with updated php version

I have an old site that hasn't been touched in a while. If I update php version from the current one (5.something) to 8.something the site breaks because the theme version is too old; and I cannot ...
DavideL's user avatar
  • 111
1 vote
0 answers
20 views

Login Forms Display on Checkout Page When Already Logged In

My client has a site that was built by another developer. When on the CHECKOUT page, the pay shows the LOGIN and REGISTER forms, even when the user is already logged in. Logging in again does nothing ...
Augusta J.'s user avatar
0 votes
0 answers
277 views

How to use s3 bucket images on wordpress media library without plugin

For a week i am trying to find a solution to connect my aws s3 with wordpress site. Best solution for me was using plugins which built to handle this but I am using docker container, even there's no ...
utkuyceng's user avatar
0 votes
0 answers
75 views

How to link the path of a folder situated in public.html for a random video player?

I'm new to coding and I'm struggling a bit with migrating my code to wordpress. I made a Random Video player with PHP to play a random file from specific folder on load. I tested it locally and ...
big beans's user avatar
0 votes
1 answer
26 views

Strip and print only the numbers found in current's post excerpt (even if they are without space)

I have a working code for printing just the year (number) if found in the current post excerpt, but the problem arises when the number (a year) is followed by a Japanese character (example: '2023年', ...
vyperlook's user avatar
  • 167
0 votes
1 answer
137 views

How to get default variation ID (woocommerce)

I need to create an additional "Add to Cart" button on the product page. In a simple product there is no problem with this. It is more difficult in a product with variants. To create such a ...
patryk siuta's user avatar
0 votes
0 answers
12 views

Why does my search query loop double on the second element?

I'm writing a custom query for a wordpress loop that should match and filter elements into three categories 'premium', 'nachhaltig', 'guenstig'. I do that with a counting variable: $search_count. At ...
Lisa's user avatar
  • 3
0 votes
1 answer
35 views

Site Health and PHP 8.1

I just switched from PHP 7.4 to PHP 8.1 and I noticed that in Site Health under WordPress Constants, both WP_HOME and WP_SITEURL show as Undefined. Shortcodes that use site url still appear to be ...
Mike Witt's user avatar
0 votes
1 answer
23 views

wordpress media library description column

I have added a code to show a description column on media libray on wordpress, below is the code: function column_id($columns) { $columns['description'] = __('Description'); return $columns; } ...
sarika's user avatar
  • 1
0 votes
1 answer
171 views

Run a WP-CLI command from within PHP without using shell_exec()

Is there another way for me to run a WP-CLI command from within a PHP script other than using the shell_exec() function.
TKEz's user avatar
  • 111
0 votes
1 answer
30 views

How can i add a script with parameters?

I am trying to consume the google maps api in a metabox but i don´t know where to add the script provided by the api. <script src="https://maps.googleapis.com/maps/api/js?key=MYKEY></...
mateo ghidini's user avatar
0 votes
1 answer
27 views

is_singular() in mu-plugins not working

I wanted to use mu-plugins to load the plugin only on a page with a single blog post. Unfortunately, the is_singular('post') function is not working properly. So I tried using $post->post_type, but ...
patryk siuta's user avatar
0 votes
0 answers
44 views

I can't change version of PHP

I recently upgraded the PHP version on my website from 7.4 to 8.0, but now I'm encountering an error 500. To troubleshoot the issue, I performed the following steps: Disabled all plugins: I ...
LuchiniChiara's user avatar
2 votes
1 answer
115 views

Show the terms of the hierarchical taxonomy

I'm trying to display buttons with category term names. i am using this code which works to show terms of categories which without hierarchy, but i can't figure out how to adjust it for hierarchical ...
LesCa's user avatar
  • 21
0 votes
1 answer
102 views

How to register a template in [NEW] WordPress site editor through a plugin

I am trying to add a new template in the WordPress site editor like this but unable to do it with my custom plugin. I have found a filter to register a custom template add_filter( '...
Syed Ali Ahmed's user avatar
0 votes
0 answers
28 views

Disable RSS /feed/ endpoints on posts without disabling RSS overall

I recently found that Google Search Console has picked up the RSS links for the individual posts and pages on a client site and is attempting to index them. For example, https://example.com/this-is-...
kevinmcgillivray's user avatar
0 votes
0 answers
46 views

Open WP Insert/Edit Link modal inside the Customizer

Is there a way to call the WP Insert/Edit Link modal when inside the Wordpress Theme Customizer? I am trying to make a custom control button that will open up the WP Insert/Edit Link modal, instead of ...
CanvasOfGod's user avatar
1 vote
1 answer
186 views

Embed dynamic media query in a Gutenberg block

I'm working on a custom block that renders a series of DIVs differently depending on the device on which it is displayed. On desktop, the DIVs need to be displayed horizontally with a right margin of ...
leemon's user avatar
  • 1,806
1 vote
1 answer
64 views

The theme doesn't load css and JS files doesn't load in functions.php

I'm just moving a theme from Vercel that done in HTML/CSS/Bootstrap/Nuxt.js to be deployed in WordPress trying to enqueue the css files and js but doesn't load at all the content of front-page.php and ...
Mostafa Ezzat's user avatar
0 votes
0 answers
49 views

How to do SEO friendly filters urls?

I have a WordPress website. It uses Woocommerce. All products are loaded and attributes are created. When the user opens the catalog page and selects the filter values, there are problems with the URL....
Artm's user avatar
  • 1
0 votes
1 answer
197 views

Add/Modify rel=canonical of all the pages of a wordpress website

Some background to the situation: We're currently running two exact wordpress websites at two different domains, xfilpak.com and xfilpak.ca. We want to make xfilpak.ca the canonical website. ...
Mohsen's user avatar
  • 1
0 votes
1 answer
89 views

Wordpress site server getting blocked due to resource abuse

I have a very weird problem going on. Namecheap always blocked my server by sayings I am overusing resource allocation. It’s hard to figure out what plugins or files are creating problems. I need to ...
LearningROR's user avatar
0 votes
0 answers
59 views

search issue in posts with ’ and ' WordPress search not considering variations of apostrophe in product post type

I have a WordPress website with a custom product post type. I'm experiencing an issue with the search functionality where it doesn't consider variations of the apostrophe character ('). For example, ...
Tejas Gajjar's user avatar
0 votes
2 answers
63 views

create custom post type and populate custom fields using php

I am trying to programatically create posts of a certain custom-post-type. Within the custom post type i've enabled 'show in rest api' and set a slug. Within ACF i've setup a group that contains ...
RkdL's user avatar
  • 1
0 votes
1 answer
24 views

Check if User Meta has Existing Value

Before running a command, I'm trying to check if a user already has a specific value (which is a Post ID) in a user meta key "saved_sessions". (This is a "favorites" type of system ...
Blake Miller's user avatar
1 vote
1 answer
459 views

"Cannot start session when headers already sent" when attempting session

I've read all the similar threads on the Exchange and nothing is resonating. I recently migrated this site from another dedicated server to a new dedicated server. This function, in functions.php, ...
breadwild's user avatar
  • 319
0 votes
1 answer
44 views

Want to add custom post type for facebook feed

I have Facebook api for feeds. I want to add multiple user's Facebook feeds on their page. So, how can I add custom post type for Facebook feeds, which users can login to their account to get feeds ...
Devil mind's user avatar
0 votes
1 answer
35 views

I have issue with decoding json ex. '{"a":"b"}'

Hey I am trying to send JSON data from (WRITE AN EXCERPT (OPTIONAL)) this section. Let say I pass this '{"a":"b"}' as Map now in the wordpress templete I tried to get this so I was ...
waqas023's user avatar
0 votes
1 answer
80 views

Enabling pretty permalinks with Docker, Multisite Wordpress and Caddy

My task is to migrate several existing blogs, which where hosted on individual instances, to a multisite instance. The entire multisite instance is dockerized due to company policy and using "...
Julian Kirsch's user avatar
0 votes
0 answers
157 views

Finding plugin that makes this part of page (finding sweetwinsprizes.info virus's origin)

I have a website with several plugins installed. in 70% of page loading everything is OK and header is something like this: <head> <meta charset="UTF-8"> <link rel=&...
qwerty13's user avatar
0 votes
0 answers
42 views

wp_get_post_terms not working when using AJAX

I am trying to display terms with a load more button on the website, but I have come across a problem while the page loads first the below code works perfectly giving me 4 terms in the correct ...
mjcoder's user avatar
  • 101
2 votes
1 answer
401 views

Can I send a body using wp_remote_get()?

I'm writing a WordPress plugin and want to retrieve data from my API on another domain using wp_remote_get() On this page: https://wp-kama.com/function/wp_remote_get There is a Usage Template: $...
HardlyNoticeable's user avatar
0 votes
1 answer
94 views

Remove H1 title in admin post edit screen

As a priority i need to just display some custom html inside the Title(h1.wp-heading-inline) in the Post Edit Screen (Top Left Corner). While trying various methods i found that all html is filtered ...
Ion T's user avatar
  • 15
0 votes
2 answers
105 views

"acf/load_field" Critical error upon saving/updating WooCommerce products [closed]

I'm trying to prepopulate an ACF field called "upcoming_class_date" using "acf/load_field" but my code snippet returns a critical error upon saving/updating a product in ...
GrumpyCat000's user avatar
0 votes
2 answers
87 views

Exclude first post from wp query

I am building a WordPress website and I want to show post in it. But the problem is that, I want to exclude the first post in query. I have not much knowledge of PHP. So please help me to de this. ...
Ahmed Muneeb's user avatar
0 votes
1 answer
218 views

Registered a REST Route but I’m Getting a 400 Bad Request

I'm new to this so please bare with me. I'm trying to register a REST route to save the dynamically added custom fields of a custom post along with the post when the user clicks the "Update" ...
Samuel Bacay's user avatar