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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
19 views

Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder

I am getting the following error: Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder. I have gone through plenty of other similar questions ...
Aristocles's user avatar
0 votes
0 answers
15 views

How to get the post title inside a custom block in a loop? block.js

I have created a custom post type and I want to create blocks that display its values. To start with, I created a placeholder that gets replaced with the correct values using PHP. Everything works as ...
Ghiath Sardast's user avatar
1 vote
1 answer
127 views

Date not working correctly

I have made a custom theme and used CPT UI to create Event Post Type and ACF to create Event Date Field. I am using following code to display Remaining Event Days in frontend: $event_date = strtotime(...
Milan Bastola's user avatar
0 votes
0 answers
16 views

WooCommerce Mini-Cart Problem

I'm doing some customisation to the mini-cart. When a user adds a product to the cart, inside the mini-cart I'm creating a slider containing the added product's cross-sales. So for example, user adds ...
TsvetkoKrastev's user avatar
0 votes
1 answer
13 views

Add up all numbers from a WordPress query [closed]

I have the following code $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $post_id = ...
iWebbers's user avatar
0 votes
1 answer
36 views

How to add query string at the end of sitemap Yoast SEO

trying to add a query string for every products and product category pages onto sitemap so google can index them properly. My sitemap is generated by yoast seo plugin for wordpress. This query string ?...
Spriteboy82's user avatar
1 vote
2 answers
35 views

How can I cause run wp-cron to trigger sequentially?

I have a custom plugin that pulls in data from an API once per day at 2 AM. This mostly works fine, except that because I need to pull in the data in chunks, I keep running in to issues when I try to ...
JacobTheDev's user avatar
  • 1,241
0 votes
1 answer
23 views

How to Customize the Admin Sidebar Menu in WordPress Multisite Network by changing the backend code of the wp-admin code files?

I'm working on customizing the admin sidebar menu specifically for the WordPress Multisite Network Admin area. I want to add a new top-level menu called "Header Builder" and some submenus ...
TheAM's user avatar
  • 1
0 votes
0 answers
19 views

EC2 Wrodpress plugin WP offload Media not upload files to S3 Bucket [closed]

I have two wordpress projects hosted in AWS EC2 (with ubuntu/apache). I am using RDS for database and try to upload all media contents into S3 bucket by using the plugin called WP Offload Media Lite. ...
Kevin's user avatar
  • 1
0 votes
0 answers
12 views

How to Bulk Update CPT Taxonomy Values Using CSV Lookup Table

I have a CPT named Places on a very large website with a few million posts. Each post has a value for the taxonomy States (e.g, FL). Normally I use WP All Import, but it's very slow. Processes about ...
J.R.'s user avatar
  • 1
0 votes
0 answers
30 views

Removing website URL in comments causes misalignment of submit button and tickbox

I am using Astra free theme, I have created a child theme with functions.php, comments.php, style.css. I have managed to remove the Wesbite URL entry using the following code in functions.php: ...
kira123's user avatar
1 vote
1 answer
32 views

i18n in Wordpress Theme

I'm trying to set up language translations based on the Wordpress language setting. I feel like I've done all the steps outlined in https://developer.wordpress.org/themes/functionality/...
Fluxian's user avatar
  • 180
1 vote
2 answers
14 views

Category Attachment Pagination 404 Error on 2nd Page

I'm customizing category.php to display all attachments with a specific category, but when I click on a link for a page besides the first one, I get a 404 error. To reproduce: Install a new Wordpress ...
The-Coder-Who-Knew-Too-Little's user avatar
0 votes
1 answer
25 views

Add Imports to Existing WordPress Import Map

How can imports be added to the existing WordPress import map? Preparing the Module I have a JavaScript module threeDTest.js which is enqueued using a PHP short-code (set to run everywhere): ...
Dave's user avatar
  • 11
0 votes
1 answer
25 views

Custom page template from plugin does not work with pre-installed themes in WordPress 6.6.1

So I have a simple Wordpress plugin that just allows me to use custom page templates. Here's the code: my-special-template.php <?php /** * Plugin Name: My Special Template * Description: Awesome ...
darkhorse's user avatar
  • 127
0 votes
0 answers
25 views

Custom Dynamic Tag in Elementor not showing image

Hi I am trying to add dynamic tags to the wordpress "image" widget, so that I will be able to choose custom featured image: second-featured-image and third-featured-image. These second and ...
Brango's user avatar
  • 1
0 votes
2 answers
38 views

Split titles by the " - " in Wordpress

I wanted to divide a Wordpress post title by the hyphen, in PHP and HTML in a Wordpress page for different div's. Here's an example of the title i wanna divide "Charli XCX ft. Billie Eilish - ...
Daniel Martins's user avatar
0 votes
1 answer
25 views

How can I allow a user to add any number of custom user_meta fields on a WordPress front-end page?

I have a requirement to generate a rate calculator accessible to multiple users, each with their own set of criteria and values. I'm using user_meta fields to store the values for each user. One ...
Mussy's user avatar
  • 1
1 vote
2 answers
71 views

Warning: Undefined variable $post_id

Hi can anyone please help. I'm no computer buff and need a step-by-step guide if possible. In getting this error on my product pages: Warning: Undefined variable $post_id in /customers/5/f/d/...
Andy's user avatar
  • 11
1 vote
1 answer
28 views

Can't programmatically log user in php

I am looking to programmatically login users from php, but after reviewing multiple threads about achieving this I have found that none of the methods work for me and I am not sure why. Currently I am ...
user9102437's user avatar
0 votes
1 answer
33 views

I neеd hеlp with a WordPress project

WordPress is installed in the root of the site. I can't log in to my uploaded file, I find myself on page 404. For example, I upload a new folder to the site, which is separate from WordPress index....
Rinat's user avatar
  • 1
0 votes
1 answer
20 views

Wordpress per ACF - permalink is not working

I wrote this code: <?php $category_border_color = get_field('category_border_color'); $image = get_field('main_image'); $short_description = get_field('short_description'); $permalink = ...
Caro's user avatar
  • 1
0 votes
0 answers
9 views

How to display all submenu items as a breadcrumb

I'm trying to display all submenus of the active page as a breadcrumb navigation on a section of the page. How could I go about this? For example; Home Program P1 P2 P3 About When I navigate to the ...
99 PetStop's user avatar
0 votes
2 answers
27 views

WooCommerce coupon codes in order overview HPOS

I've been using this code to show coupon codes in WooCommerce order overview. With updating the WooCommerce database to high-performance order storage (HPOS) it doesn't work anymore and I don't know ...
FStefan's user avatar
0 votes
0 answers
14 views

How can I make this shortcode multilanguage

I'm tryng to make my shortcode multilanguage but this code is not working: add_shortcode('periodo_affitti', 'translate_rent'); function translate_rent() { global $post; $lang = substr(...
Andrea Sacconi's user avatar
0 votes
0 answers
20 views

PHP session sending header "Cache-Control: no-store, no-cache, must-revalidate". How to remove this?

PHP session sending header Cache-Control: no-store, no-cache, must-revalidate I want to completely remove Cache-Control in header
Bharat's user avatar
  • 13
0 votes
1 answer
20 views

Automatically populating a date parameter within a shortcode

On one of my sites, I use Formidable Forms. I need monthly numbers (simple counts) on submissions for these forms. My current solution is to use this shortcode built-in from Formidable: [frm-stats id=...
MidPiedmont's user avatar
0 votes
0 answers
25 views

How to save Wordpress post and attachment images from front end using media library?

I'm developing a wordpress page to submit a post and its images attachment. I don't use input type="file" instead use jQuery wordpress media library. frame.on("select", function (...
Samuel Limawan's user avatar
0 votes
1 answer
45 views

How to display only the first 2 words of a post title

I am learning WP and want to display only the first two words of a post title to the user. For the end user only the first two words of the Post title (H1 class) should be shown but source should have ...
Prad G's user avatar
  • 1
0 votes
0 answers
32 views

taxonomy pages returning “NULL” when running default WordPress function 'get_queried_object()'

i keep seeing the following in the php error log, repeating: [05-Aug-2024 02:34:41 UTC] PHP Warning: Attempt to read property "post_content" on null in /home/euognau/public_html/wp-content/...
vulgarbulgar's user avatar
0 votes
0 answers
26 views

Wordpress search every time shows no search found even data exists

I am using wordpress. What I am doing is, that when the user enters anything then it will search from the post and will show the result. I have added static content $_REQUEST['keyword']="team&...
Naren Verma's user avatar
0 votes
0 answers
13 views

require used as a function to load theme dependencies?

I've inherited a site from another company recently and found this in their functions.php file: function themeLoader() { locate_template(include('inc/wp_reset.php'), true, true); locate_template(...
Adam Taylor's user avatar
0 votes
0 answers
19 views

Can't set a cookie from php

I am trying to add a cookie in my add_cookie.php file like so: <?php setcookie("TestCookie", 'epic_test', time()+3600); exit('cookie set'); But when accessing https://my-site.com/...
user9102437's user avatar
0 votes
1 answer
20 views

Adding code before any page loads

I would like to make a call to the external API before the page is loaded on my WordPress website. It looks somewhat like this: $si = session_id(); $res = @file_get_contents("https://my-api.com/...
user9102437's user avatar
0 votes
1 answer
25 views

Generate random number 1-10 upon registration without repeat

I have an event with 10 spaces available for booking. When a user registers for the event, I need to assign them a random draw number from 1 through 10. I will include this number in the confirmation ...
LBF's user avatar
  • 529
0 votes
0 answers
25 views

How to get ACF field to show up on all posts on front end?

I have thousands of posts with attached files. These attached files are part of Advanced Custom Fields Pro. However, they are not showing on the front end for the posts. These files are utilizing the ...
user246199's user avatar
0 votes
0 answers
10 views

how to append ACF field data using one of the following filter/ hooks

using a plugin which lists the following as filters/hooks to append data: // Data Filters apply_filters('woocommerce_print_products_title', $this->post->post_title); apply_filters('...
vulgarbulgar's user avatar
0 votes
1 answer
25 views

Upgraded php & wordpress but theme broke

I just upgraded wordpress from v3.3 to v6.6 and PHP from 7.2 to 8.2. Once upgraded my wordpress theme just break and I have no idea how to fix this since it worked on the older version. The error ...
TravelWhere's user avatar
0 votes
0 answers
25 views

Assembly Options at checkout

I want to add Assembly options at the checkout page like this https://imgur.com/a/WrzWCiO Anyone knows how to do it without plugin? Thanks add_action('woocommerce_after_order_notes', '...
Tasnim's user avatar
  • 1
0 votes
1 answer
24 views

Wordpress admin area not sending mail (but works with WP Mail SMTP, Test Mail, and PHP mail() function)

My wordpress admin area does not seem to be able to send mails. For an example, I tried to change the admin mail address, but I never received the confirmation mail and had to use the plugin Change ...
John Kravicz's user avatar
0 votes
0 answers
17 views

Global update of records after import WP All Import Pro

friends. I have encountered a problem updating records. I am importing vacancies into the WP Job Board Pro plugin via the WP All Import Pro plugin. When importing, I have a field in wp_postmeta ...
Givanni Dev's user avatar
0 votes
1 answer
12 views

Redirect to non-Wordpress version of home page for search results via index.php customization overwritten

Because the Wordpress pages in my web site can have an extremely unacceptable 2000+ millisecond TTFB, non-Wordpress web pages has been my approach. By saving large HTML blocks in a couple of ...
Ted's user avatar
  • 1
0 votes
1 answer
16 views

Custom post type removing /page/2/ from URL when trying to access it

I made a shortcode to list form entry data that paginates using paginate_links(). I added this shortcode to a regular page and it works fine. If I click on page 2, it refreshes the page and adds the /...
Aristocles's user avatar
0 votes
0 answers
14 views

Wordpress site calling debug.log and .user.ini at certain hour

Im having a hard time understanding what is this behaviour. I have around 300 Wordpress Sites on two big servers. They normally work pretty well, but from some time to now, they started to have a ...
P4R0DY's user avatar
  • 1
0 votes
0 answers
20 views

Error message not appearing in error email or in the error log

I am developing a plugin. I am getting an error when activating, but I can't find out what is causing the error, even which file is causing the error. I don't receive an email for the fatal error, and ...
Sloan Thrasher's user avatar
0 votes
0 answers
21 views

Put ACF function output code the_terms

I would like to put an ACF field in the of my the_terms function, is this possible? Because I can't figure out how to put it. <?php $dev = get_field ('my_field', 'option');?> <?php ...
user avatar
0 votes
1 answer
41 views

Options for using custom PHP in a wordpress site? No FTP access

My professional background is backend engineering, but I volunteered to help a nonprofit, and their website runs on wordpress, so I wrote some php that solves a problem for them, which I tested by ...
eipxen's user avatar
  • 101
0 votes
0 answers
25 views

Get User By Email - Not Working with Variables (PHP)

I'm trying to return user data based on an email input, code is simply: $email = '[email protected]'; $user = get_user_by( 'email', $email ); This returns nothing and when I try filter_var($email, ...
Morts81's user avatar
  • 123
1 vote
1 answer
30 views

WooCommerce: Custom dropdown for variation selection

In WooCommerce, I have an attribute called License Type. This attribute has 2 terms: Single Site License Multi Site License With the above, I'm trying to create a custom select dropdown, where the ...
Freddy's user avatar
  • 167
0 votes
0 answers
35 views

Are there any legitimate reasons for a web browser to directly access wp-includes/*.php?

This question would appear similar to Deny php execution in /wp-includes - using .htaccess in /wp-includes VS root folder - but is different in that that question asserts the questioner has already ...
davidgo's user avatar
  • 222

1
2 3 4 5
212