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.

3,595 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8 votes
2 answers
1k views

Pass media upload value to input field

I have created a meta-box that provides a upload function via the default media uploader from WordPress. This works fine as long as I have one upload option. But guess what? I want another one. If I ...
Interactive's user avatar
8 votes
1 answer
635 views

static variable loop not working in Wordpress

I have a function in my wordpress theme that deletes the first embedded video in a video post. See code below. This is in the functions.php file. /* - function that hides first video in post content -...
danny471's user avatar
  • 191
7 votes
2 answers
8k views

why is translation not working on theme?

Background I am using the theme Rookie from Sportpress. I created a child theme. Translation files are existing, especially german in my case. Wordpress is set to german language. The Problem ...
André Kelling's user avatar
6 votes
0 answers
462 views

Gutenberg Blocks doesn't render correctly when using do_blocks

I'm trying to render a post_content with blocks using the do_blocks function, that takes a gutenberg content, parses every block, and returns an HTML string. The problem is that some blocks aren't ...
Raba's user avatar
  • 406
5 votes
1 answer
2k views

Find out what is using PHP sessions in WordPress

Is there a way to find out what is using PHP sessions or spawning PHP processes? My Wordpress site gets heavy traffic (3.5 million hits per month). We discovered recently that we had permissions set ...
mayabelle's user avatar
  • 151
5 votes
1 answer
2k views

WSOD but WP_DEBUG not giving any errors

I am running Wordpress on a WAMP stack and I'm trying to debug a WSOD error, which I think is a PHP error, as I have tried disabling all my plugins and themes and they don't seem to be the problem. I'...
Alistair67's user avatar
5 votes
3 answers
1k views

Making plugin unique to not conflict with plugins with the same name

I have plugin that has the same name as other plugin uploaded to wordpress.org How can i make it unique so it doesn't share "View Detais" link and auto-update with other plugin uploaded to wordpress....
Danil Solodunov's user avatar
5 votes
1 answer
590 views

Cropping, Re-sizing and Saving images from one folder to another folder in wordpress

I'm adding an upgrade for the WordPress plugin which I have developed ages ago. This plugin is just a product catalog, so just show products and their images. Products can have more than one images. ...
Omer's user avatar
  • 275
4 votes
1 answer
2k views

WordPress “Link has expired” error on updating posts

I'm maintaining a WordPress site on GoDaddy for a client and they started to get the "this link has expired error" when they saved a post. It does not happen when I upload a file. However, I am ...
Josh's user avatar
  • 91
4 votes
1 answer
2k views

Creating a post with the REST API, curl and oauth returning 401 error

I'm trying to create a WordPress post using the REST API, OAuth, and cURL. However, I'm running into some trouble. I'm able to create a blank post (no title, slug, etc) using the following code: $...
Dan P's user avatar
  • 41
4 votes
2 answers
631 views

load/require specific php files for specific pages/templates/post types

I have a plugin with multiple php files. I want to load some of them only when specific template files are loaded. I don't want to load everything. Currently, I'm doing it with add_action( 'wp', '...
eddr's user avatar
  • 41
4 votes
0 answers
88 views

my function doesn't return my post from today

I'm using gravity form to create some custom post type - as events. Everything is working great, There is some date field to setup the event from x to y date. ALl of this working great. However, I ...
tibewww's user avatar
  • 297
4 votes
1 answer
677 views

Display message once per session to users with a specific role

I need to display a message to only users with a specific role. The message should appear either as soon as the user logs in or if they re-open their browser after having closed it when logged in to ...
user1462's user avatar
  • 1,274
3 votes
3 answers
2k views

How to automatically convert images to WebP on WordPress?

I want to convert every PNG and JPEG to WebP on upload so that I can serve WebP and PNG/JPEG without requiring the user to upload a WebP version of every photo. I want to save the WebP in the same ...
Ron's user avatar
  • 31
3 votes
1 answer
7k views

PHP Fatal error: Uncaught mysqli_sql_exception: Table doesn't exist in wordpress/wp-includes/wp-db.php

I am writing a plugin and want to create a database table when the user installs / activates it I have written the following into an install.php global $wpdb; $fm_db_version = '1.0.0'; $db_table_name ...
Justin Erswell's user avatar
3 votes
1 answer
310 views

Loading class files via autoload method

We have core classes created for theme and we are moving those classes to client-mu-plugins. Is there any way we can load all of the classes without adding require_once function for every single files?...
Jignesh Bhavani's user avatar
3 votes
0 answers
2k views

WordPress Ignoring .user.ini

I have a server using Apache and PHP-FPM. The server hosts several WordPress sites with each site running as a different user and using a different pool. I'm trying to configure the post_max_size and ...
tech-otaku's user avatar
3 votes
1 answer
389 views

How to remove "out of stock" variation options from size dropdown in woocommerce?

I'm using woocommerce to display products and their variations. I have a variation called 'Size' for all of the products. Some of the variations are out of stock, but these are still showing in the ...
SohaIb AhmEd's user avatar
3 votes
0 answers
1k views

Is it possible to intercept all ajax requests and get the parameters and the returns?

Is there any hook that always goes through it, where I can see all the requests, and also the returns after the "action" that is executed? I need to intercept all requests, including requests from ...
rafaelfndev's user avatar
3 votes
1 answer
968 views

Wordpress can't find temporary folder, but folder it's looking at has correct permissions

So, I've spent a couple of hours looking around the internet to try to figure out this problem, since it seems like a dumb one that would probably be a duplicate, but apparently it isn't. I'm hosting ...
Alexis Purslane's user avatar
3 votes
0 answers
52 views

Get widget settings function?

I am using this to find if a new widget has been added or removed from my site: serialize(retrieve_widgets()); Works great for added or removed widgets. But it doesn't detect if a widget setting has ...
joq3's user avatar
  • 371
3 votes
1 answer
559 views

Replacing the NavWalker dropdown element

I'm creating a website for my school with Material Design for Bootstrap and the NavWalker is giving me some issues, I want to change the element of dropdown i.e. from ul to div. I've tried to edit the ...
Azzaz's user avatar
  • 33
3 votes
1 answer
870 views

Image upload via FTP to wordpress media library

Is there any permanant way to upload images via FTP to WordPress media library other than the available plugins which don't really work well most of the time? I would really appreciate if anyone ...
John D's user avatar
  • 41
3 votes
0 answers
725 views

Setting Up PHPUnit tests for WP development on Windows

I've been following the instructions in this article to try to set up some testing. I got as far as this instruction bash bin/install-wp-tests.sh wordpress_test root 'mypass' localhost latest before ...
Robin Andrews's user avatar
3 votes
1 answer
781 views

How to display related posts from parent category

I am using the following code to display the related posts but it is showing posts for that category only like brand showing brand posts only. What I am looking for is if I select any of the posts ...
stack kid's user avatar
3 votes
1 answer
111 views

Adding a span when custom post type is updated

What I'm trying to do is have a span tag appear on the top of the post type whenever the post is updated. The way the page is setup, there is a query of different post types that list jobs currently ...
David Kim's user avatar
3 votes
1 answer
1k views

Foreach insert query the best way

Hi i've got this code which works fine but I think it uses a lot of server resources because execute a query to the database for each user id stored in a group, is there any way to solve this problem? ...
pippo's user avatar
  • 43
3 votes
0 answers
245 views

allow arabic letters when register new account

How can allow arabic letters when register new account ? i don't need to lose any security. If any of us, Arabs, want to register in any wordpress blogs we have to use English letters in “username” ...
Ahmed's user avatar
  • 31
3 votes
2 answers
3k views

Customizer Show/Hide Logo and Site Title

I've setup checkbox controls in my theme Customizer to show/hide the Logo and Site Title when they are checked/unchecked. By default, I want the Logo to display and the Site Title to be hidden. ...
Troy Templeman's user avatar
3 votes
1 answer
2k views

How to resolve error “Cookies are blocked due to unexpected output.”?

I am facing an error as per below at admin panel login. "ERROR: Cookies are blocked due to unexpected output." I've tried several solutions like, Log checking (No logs are showing in log file) ...
Purvik Dhorajiya's user avatar
3 votes
0 answers
190 views

wp_handle_upload_prefilter valid date from input file

I want to ask some help, i'm having problem with thewp_handle_upload_prefilter Here is the code: add_filter('wp_handle_upload_prefilter','mdu_validate_image_size'); function mdu_validate_image_size( $...
user avatar
3 votes
0 answers
276 views

Dynamically add styles to WP TinyMCE editor

I want to add custom styles to Wordpress using dynamic arrays. My question is how can I add the two arrays to the style_formats array within the 'my_mce_before_init_insert_formats' function ...
Daniel Florido's user avatar
3 votes
0 answers
695 views

Making a follow button, Ajax not talking to php

I'm trying to make a user follow button using AJAX, but for some reason my AJAX isn't talking to my jk_user_follow function and setting the wp_set_object_terms. PHP function register_user_taxonomy(){...
Julian's user avatar
  • 53
3 votes
1 answer
128 views

Adding Field to Profile "Name"

I am trying to add an extra field or two underneath the "Name" or "About" section in the Wordpress user profile. So far I have only been able to accomplish this by: //Begin add_action('...
Corey's user avatar
  • 131
3 votes
0 answers
2k views

Getting Post Thumbnail from RSS feed with SimplePie

I am trying to pull the post thumbnail from an RSS feed to output on an external site. I am using the following function to add the post thumbnail to the site: function rss_post_thumbnail($content) { ...
Andrew's user avatar
  • 239
3 votes
0 answers
1k views

Unique key for each row in a repeater field

Is it possible to have a unique key for each sub fields in a repeater field? I don't want to use the array index, because the array index can be changed, when adding new rows between existing rows. I ...
user1149117's user avatar
3 votes
1 answer
2k views

How to merge local and live databases?

We've been developing for Wordpress for several years and whilst our workflow has been upgraded at several points there's one thing that we've never solved... merging a local Wordpress database with a ...
Rob's user avatar
  • 1,406
3 votes
1 answer
1k views

How to track a users progress through pages by inserting data into Wordpress Database?

My website users can learn British Sign Language through Video Tuts, Quizzes and games etc. I would like to track the users progress through the pages of the course and add that data to a Wordpress ...
samfrommadesimple's user avatar
2 votes
0 answers
22 views

How do I stylize selected comments?

I built my own theme from scratch, which has worked well for years, but I'm very rusty now on how I did it, and I could do with some help with my re-learning process. When certain people comment (and ...
Chris Rand's user avatar
2 votes
0 answers
133 views

AJAX returning blank result

I'm using ajax to filter a list. The filter works as it should most of the time, but for some queries it returns a blank result. When this happens, the error in the console is: PHP Errors in Ajax ...
Jillian Hoenig's user avatar
2 votes
0 answers
44 views

Creating a table via dbDelta

I'm trying to figure out exactly how to create table structures in databases correctly, and after doing my research I'm left with a couple of questions that I can't find an answer to: In MySQL, there ...
doesnot's user avatar
  • 21
2 votes
0 answers
54 views

Hide categories that are not used in the post type

I have a situation where I need to display categories on the Archive Page of CPTs, but if the category is not used anywhere in the CPT, it needs to be excluded from the list. For example, I have a CPT ...
naveenkharwar's user avatar
2 votes
0 answers
18 views

Is there CSS to expand the gallery limit on Index Pages?

On a wordpress index page, I am only allowed to add 12 galleries. I would like to add many more. Is there a way that I can expand the gallery limit allowed on index pages? If this is not possible, is ...
Rhino_Kadabra's user avatar
2 votes
0 answers
803 views

AJAX function running TWICE with WordPress admin-ajax.php

I have a form submit event that calls a WordPress ajax function. The form submit event occurs only once (It is correct as expected). But the ajax function loaded TWICE (expected to occur once). Here ...
Irfan's user avatar
  • 430
2 votes
0 answers
1k views

Uncaught Error: Call to undefined function get_user_by() after moving function from theme to plugin

I have a code I always used in my themes or child-themes. I'm doing right now a project with plugin-only as a solution, so I tried to copy paste some stuff from child-theme to plugin file, but I get ...
Paweł Bystrzan's user avatar
2 votes
0 answers
21 views

Newbie question: no index.php? in my plain wordpress permalink

I am trying to learn about the Rewrite API and I see people write their plain permalink as "index.php?page_id=", but my local Wordpress site shows "?page_id=" instead. Is there any ...
George Paresishvili's user avatar
2 votes
1 answer
775 views

Getting media library popup in custom plugin admin page

I’m creating plugin and I need to upload images. And I’m wondering if I can somehow trigger same popup as “add featured image” triggers. Is that possible? If not, how can I make an alternative? Thanks ...
krystof18's user avatar
  • 121
2 votes
1 answer
317 views

Add meta noindex to post if it has a specific taxonomy

How can I add the following line to the current post if the product_type = 'enviso_group_ticket'? <meta name=”robots” content=”noindex,nofollow”/> product_type is a default taxonomy of the ...
Dennis's user avatar
  • 135
2 votes
2 answers
432 views

Sort products without thumbnail in WooCommerce shop page

I would like to create a function that instead of hiding the products without thumbnails, would be ordered in such a way that the products with the highlighted image appear first on the shop page ...
Naycom's user avatar
  • 23
2 votes
0 answers
162 views

Change title and meta description in included page (not template)

I'm trying to change title and meta description for pages used for products. The goal is to have the same effect as here: <script>document.title = "<?php echo $new_title; ?>";<...
jackaaxc's user avatar

1
2 3 4 5
72