Stack Exchange Network

Stack Exchange network consists of 174 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]

The server-side programming language that the WordPress core, plugins and themes are written in.

0
votes
0answers
14 views

Searchform for custom table

I have a custom SQL Table in my database with a list of places and their information. I would like to create a searchform to search this table for places and that the results are displayed in a ...
-1
votes
2answers
40 views

post_exists() returns a 0 but the 0 doesn't register [closed]

Strange... I put an if statement for $testvalue = 0. The else part runs and when I echo the value of the $testvalue it gives me a 0. So what is the true value of $testvalue? I need to be able for ...
0
votes
0answers
23 views

remove wp- prefix using a php script [duplicate]

I want to remove the wp- prefix from the wp-admin folder. I don't want to use a plugin, this because I want to code myself this wordpress hack. My question is, what files I need to edit after I've ...
0
votes
1answer
27 views

exchange words in echo

with this code $wptitle = str_replace(array('Versandkostenfrei'), 'Kostenloser Versand', $wptitle); I exchange words in one of my loops. Now I am trying to change a word that is called with echo $...
0
votes
3answers
24 views

static array on functions.php

In functions.php, I want to access the DB once to get an ACF object, and then "save" it locally to prevent further requests to the DB. I thought of first calling the following function in the "init' ...
2
votes
2answers
829 views

functions.php not adding css to website?

So I went through the forum to find a solution before I post a question, however I have yet to find it. I'm new to wordpress and I'm having a lot of fun learning on how to build my own website. ...
0
votes
2answers
24 views

Cant display an image via PHP in wordpress

I have a strange problem, when I try to enter the source of an image tag using PHP it shows me the following error in the inspector <img src=(unknown) alt=""> this code fragment gives me the ...
0
votes
2answers
18 views

Getting different user data depending on where I use variable

I'm looping through all users with $allusers = get_users($args); foreach ( $allusers as $user ): And then I have an email user button (firstname and lastname are ...
0
votes
0answers
28 views

Woocommerce overriding the “Add to Cart” Button based on a true/false ACF

Currently working with this code, changed some stuff to display some data based on price, but I am attempting to target the "Add to Cart" button instead of the $price. Any help on reformatting? //* ...
0
votes
0answers
18 views

WP_Query: compare multiple values with serialized data in database

I am using WP_Query and I need to compare multiple dates with a meta_key named data_evento, containing multiple dates as well. If at least one date is matched, corresponding posts should be returned. ...
0
votes
0answers
16 views

Simple Ajax in WP: Always execute error block

myJsFile.js jQuery(document).ready(function($){ //sample variable that will pass to response PHP function var fruit = 'apple'; //AJAX Request $.ajax({ url: ...
0
votes
0answers
16 views

Rich Snippets woocommerce

I have noticed that when searching for products on Google, a lot of results contain -pricing -Stock status -ratings etc... I have been trying to add this to my store and have tried different ...
0
votes
0answers
24 views

Pagination in shortcode not working

I got a shortcode that displays a loop of posts with pagination. My problem is I can seem to make the pagination work. Although the URL changes but the list of the page is not working. function ...
0
votes
3answers
49 views

Adding Gravity Form With if(is_page) Is Not Working

Please bear with me as I am a front-end developer trying to grapple with PHP. I am attempting to add a gravity form to specific pages on my website website by adding a function to my functions.php ...
-1
votes
0answers
28 views

How can I add a transaction type custom field to WooCommerce order?

I am developing a custom payment method for WooCommerce. My code is as follows: class WC_Gateway_Custom extends WC_Payment_Gateway { public $domain; /** * Constructor for the gateway. ...
0
votes
1answer
29 views

Cross origin ajax request always returns 0 when calling get_current_user_id();

I currently work on localhost and when I want to test ajax requests to my web server, the function get_current_user_id() always returns 0. When I make the ajax request from my website however, it ...
0
votes
0answers
20 views

Make variation stock quantity appear when clicked on dropdown

Currently this is what it shows in our site with the current code: enter image description here The current code shows all the stocks before even clicking on any of the variation/sizes. What our ...
-1
votes
1answer
18 views

Query posts by custom fields (object post)

As described in ACF documentation, here is the way to find all posts where a custom field called ‘color’ has a value of ‘red’. $posts = get_posts(array( 'numberposts' => -1, 'post_type' ...
0
votes
0answers
8 views

Place Order without Checkout

I run a business that does customisable supplies. On my site, customers can chose the options that they would like to customisable. But at checkout, I want it to send as an request for enquiry for us ...
0
votes
0answers
21 views

How to make iframe with variable content length responsive?

Following on from my previous question here, I am trying to embed html files into WordPress posts using oEmbed. The embed itself was successful, but the problem is that contents of each html file is ...
0
votes
1answer
43 views

How to disable all logins except Network login in WordPress Multi site?

I have N number of sites in WordPress multi-site. I want to restrict individual site login i.e., http://www.example.com/site1/wp-admin http://www.example.com/site2/wp-admin Only Network admin can ...
0
votes
1answer
41 views

Download PDF after CF7 form submission

I'm working on a client's build, and I'd like to change as little as possible. I'm not too familiar with all this, my apologies - I'll try to show where I'm at. The client wants a form submission to ...
0
votes
1answer
28 views

The plugin generated 225 characters of unexpected output during activation

I am getting the famous "The plugin generated xxx characters of unexpected output during activation." error when I activate plugin I am working on. Terminal says my files are in us-ascii, but when I ...
2
votes
1answer
64 views

wp_embed_register_handler to embed html files

I am creating a new Wordpress website that will contain thousands of online books and articles to read, in addition to other media, like videos. I don't want to bloat my database by pasting tens of ...
0
votes
0answers
12 views

block access to wordpress users to the folder that contains an external web application

First, sorry for my english. I am developing a web application that works on wordpress. I have a folder called GSC, and inside it is my application. The problem I have, is when I have to control ...
0
votes
0answers
20 views

Run htmlentities() on all submitted values through gravity forms

I need a way to run through all submitted values throghh the htmlentities() filter in gravity forms. I am using the gform_pre_submission filter. I am successfuly able to find the type of field since ...
3
votes
1answer
64 views

Custom post type column which compares dates?

I have a custom post type where the posts have a start date and an end date. These are saved to the database as Unix timestamp/Epoch. I want to create a column for this custom post type called Active ...
0
votes
1answer
20 views

Check class_exists before class definition / Doxygen problem

Currently when I create a class for my WordPress, I start the class with if ( ! class_exist( 'class_i_want_create' ) ) : .... class_definition .... endif; But now I want to create a ...
0
votes
0answers
14 views

Woocommerce refund tax line items meta issue

I am trying to add some functionality to refund orders programmatically. I have found some code online in several places that say to use this for the tax refund portion. $tax_data = $item_meta['...
0
votes
0answers
16 views

edit-tags.php custom taxonomy term list count link doesn't work when custom taxonomy is registered to multiple CPTs

On the edit-tags.php admin page for a custom taxonomy which is registered to multiple custom post types the count link's count is updated correctly however the link doesn't go to an admin page that ...
0
votes
1answer
23 views

Wordpress PHP command and ELSE IF problem

I am trying to show different messages based on user's custom field data. 'Site-access' meta field can be 0 or 1 and I was able to retrieve it for logged in user using the_field('site-access', ...
0
votes
1answer
17 views

WooCommerce Custom Pagination

Can anybody help me with a situation I have on my custom archive-product.php? I am trying to add pagination to my grid I have made but do not know where to start. This is the code for my products: &...
0
votes
0answers
17 views

Adjust Wp-query based on the $_GET parameters in URL

I want to sort my posts using year, month, category and keywords. This is my code: $current_url = $_SERVER['REQUEST_URI']; $count = 0; $paged = ( get_query_var( 'paged' ) ) ? get_query_var( '...
0
votes
0answers
43 views

Wordpress returns “The link you followed has expired” error page whenever I add a new site, add a user etc

I have a Wordpress Multisite (subdomains) instance running on a VPS which seems to be working as expected a part from the fact whenever I add a user or add a site a "The link you followed has expired" ...
0
votes
1answer
15 views

Shortcode to pull posts

I need some help please. I have created a shortcode to pull in posts, then using ajax it loads more posts. I have everything working but it is duplicating the first group of posts. below is my code. ...
0
votes
1answer
11 views

Autoloading Classes in Plugins

In a custom WordPress plugin I have a folder /classes with about 20 classes. Classes sometimes change, come and go. I want all those classes from the folder to be loaded automatically. No my idea was ...
0
votes
0answers
34 views

Set Post Visibility to Private (Not Post Status)

I know there are some questions already about this but none seem to be working for me. I am using a Custom theme (Betube) to upload video posts - however no matter what I try I cant get the post ...
0
votes
1answer
12 views

Remove specific javascript when viewing page in Customizer?

I have a javascript which reloads the page when content change is detected. This is the behaviour I want on the main site. But when I use the Wordpress Customizer I don't want this behaviour as it ...
0
votes
1answer
37 views

JqueryUi Dialog giving Uncaught TypeError: this._addClass is not a function error

I have a site we needed some custom php coding to connect to an external database to grab product review urls for several vendors that sell our products. The basic idea we are trying to accomplish is ...
0
votes
1answer
13 views

Priority call methods - PHPMailer->addAddress(NULL)

I am currently making a WP widget and I am stuck with this. I want to pass a variable $emailReceiver from my form() method to my deliver_mail() method. The problem is that my deliver_mail() method ...
0
votes
1answer
32 views

Any possible way to make $wpdb->get_results() return anything else than array?

So I'm using $wpdb->get_results() to query my database and then make AJAX call from JS file. The problem is that I need to get the value itself, like a string, instead of array, but as much as I ...
0
votes
0answers
13 views

AJAX request returns back Array0 to console

I'm making an AJAX request in wordpress for the first time and I'm trying to access my custom made table to retrieve single name (string) or multiple names. It all works without the errors, except for ...
0
votes
0answers
8 views

sql query for selecting btween two amounts

I am trying to achieve result by selecting dropdown between two amount range. echo '<option value="browse-events?city='.$browse_city.'&type='.$browse_type.'&price=Free">Free</option&...
-1
votes
1answer
30 views

Cannot modify header information - headers already sent

So I have a form on one page, which is submitting to admin-post.php, then there is a function in functions.php which is processing the form. It stores the input field data to database and then after ...
0
votes
0answers
8 views

Comments show perfectly on regular posts, but won't display on custom posts

As the title says, I'm seeing no comment entry fields for custom posts, but they're working just fine for standard posts. In my functions.php: function custom_post_register() { // creating (...
-1
votes
2answers
26 views

How to customize posts in WordPress by using HTML and CSS?

I've tried to find the information on the Internet and stackoverflow, but there is nothing about it. So I've migrated my website(html,css,js) to WordPress(index.php,header.php,footer.php etc) and I ...
1
vote
1answer
21 views

How to handle a custom form in wordpress to submit to another page?

I know in PHP I can just put action equal to random.php file and process the data there, but how in wordpress can I use already existing page with a custom template to submit a form to, so that after ...
1
vote
1answer
11 views

Adding number to date not working [closed]

I am adding number stored in custom user meta data to current date. Here is my code $addeddays = get_user_meta($this->order->user_id, 'xxx', true); $timeBase = date('j.n.Y'); echo date('j.n.Y', ...
0
votes
0answers
14 views

How to grab data from input and store it into custom table in database?

Question asked million times and answered, but still not working for me for the simplest form. My code looks like this right now: <?php if (!empty($_POST)) { global $wpdb; $...
0
votes
0answers
21 views

WPquery mulitple sort orderby

I have a post_type with multiple dates and would like to sort it a certain way - but after way too long on this simple task, I'm still stuck :) How I want it to sort: Every post with a Date2 set, ...