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]

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
0answers
27 views

Unable to update the meta boxes with multiple fields

I successfully build a function, that is able to import data from a CSV into posts of a Custom Post Type (CPT). I am able to parse data into the native Title and Description fields, but it fails, when ...
0
votes
1answer
17 views

Search result based on URL

Currently I am using bellow function to display search results from Custom Post Type. add_filter( 'pre_get_posts', 'tgm_io_cpt_search' ); function tgm_io_cpt_search( $query ) { if ( $query->...
1
vote
1answer
295 views

Wordpress Warning: preg_replace(): JIT compilation failed: no more memory

I just have installed xampp with php 7.3.1 on mac with OS El capitan. The problem that when i run a WordPress project will show: Warning: preg_replace(): JIT compilation failed: no more memory in ...
0
votes
0answers
26 views

WP post meta - for loop inside for loop

I wanna make a portfolio on-click opening images gallery using meta fields. So firstly I make array of portfolio images and loop them. Then I loop gallery images of every portfolio item, but it loops ...
0
votes
0answers
8 views

Wordpress & RabbitMQ Intergration issue [closed]

I am trying to send a message to rabbitmq when a wordpress hook is triggered. I have setup wordpress and rabbitmq on docker containers. I also installed all the required dependencies for the wordpress ...
0
votes
1answer
33 views

Related Posts: if there is no category use tags

I found this script on one of the sites. This script is in accordance with what I want. Related articles use category posts, if there are no categories, they will take tags from posts. But this ...
0
votes
0answers
20 views

Php cron job (wp-cron) not working

I try to create a php cron job with help of the WP Control plugin. The purpose is to delete all files in the uploads directory for the current year and month. I use this code: $files = glob('./wp-...
0
votes
1answer
20 views

How to set up and use a custom upload directory for post type 'product'

I try to set up a custom upload directory for just product images. I use this code to create the folder 'product' in the uploads directory function fcsp_type_upload_dir( $args ) { // Get the ...
1
vote
1answer
32 views

WordPress 5 WP REST routes - No errors

I'm using WP JSON to return JSON for certain routes. Prior to WordPress 5, WP JSON would return PHP errors in the response, e.g. Notice:xxx or Warning:xxx when a PHP error was encountered. Since I ...
0
votes
1answer
24 views

Filter Custom Post Type Posts by Taxonomy

I created a custom post type named "listas" and a custom taxonomy named "taxolistas". I would like to fix this function from the plugin Thumbs Rating to make it filter posts by custom taxonomies ...
1
vote
1answer
27 views

Passing PHP Function Arguments from CLI vs URL

For this code: <?php define('WP_USE_THEMES', false); require('./wp-blog-header.php'); if (PHP_SAPI === 'cli') { $post_id =$argv[1]; $post_title =$argv[2]; } else { $post_id ...
0
votes
0answers
13 views

Taxonomy Brand Archive with Product Categories Integration

The following code is inserted in a the taxonomy brand page and it shows all product_cats for a specific brand. <?php $argsproduct = array( 'post_type' => '...
-1
votes
1answer
11 views

How to get the actual time, without the time

At this moment I am busy writing a widget, you can place on each page. One of the problems I am facing, is that I want to remove the time from the comment. foreach (get_comments($args) as $response) ...
1
vote
1answer
34 views

Include a PHP file inside an array

I'm trying to add a custom PHP script inside of the nav menu (before the closing ) and struggling. Code here: <?php wp_nav_menu(array( 'theme_location' => 'menu-1'...
0
votes
1answer
16 views

Huge time to first byte on live site

I have problems with loading my site. Time to first byte varies from 0,5 to even 10s. I can't find what may cause that lag in back-end processing. My site : www.mm.bartoszwasz.pl Test with GMetrix ...
0
votes
1answer
30 views

Can't successfully check if post with title exist in database

In WordPress, I am trying to import posts from a CSV file. I want to check, if post with title already exist. I am trying to do this using a database query, but I am still able to import the same ...
0
votes
1answer
14 views

image on homepage disappeared due to change of permalink name

where to do this in Wordpress backend? I need to add the missing icons for "Smart living" and "Smart workspace" on homepage section - image is not in available in Media - It is in a section of the ...
0
votes
0answers
38 views

Woocommerce: Update SKU after add to cart button

Some products have the standard SKU (inventory) field from woocommerce (SKU1) and an extra SKU (sku2) custom field. I added a mandatory selection box: "With barcode", "without barcode", if the user ...
0
votes
1answer
37 views

Is it best to avoid using $wpdb for security issues?

I'm using WordPress Multisite with multilingualpress. In order to get the href, outside of my navbar, to the page with the appropriate language, I am using an SQL query that queries $wpdb within the ...
0
votes
1answer
34 views

PHP error after theme update

I just updated my theme and I'm having errors on the homepage, the elements of the visual composer do not appear, and I get a php error. Undefined index: focus in /inc/admin/option-tree/ot-...
0
votes
1answer
17 views

Wordpress Post undefined error with Post Date (New to Wordpres Dev)

I'm getting an error on a new page with the current Date posted Notice : Undefined index: ama_text_field_01_2019 on line 57 http://magazine.americanmotorcyclist.com/6607/quest-completed/ When I ...
1
vote
1answer
38 views

Renaming post IDs - Okay to do?

Is it possible to change the post IDs within the wp_posts table without causing problems? I ask this because I have a WordPress Multisite in which I separate the sites by language. Unfortunately, the ...
0
votes
1answer
23 views

CPT in a shortcode

I'm having trouble with putting my custom post type content in the shortcode and was wondering can someone help me with this. I need this in shortcode: // List judges shortcode function ...
-2
votes
1answer
43 views

Display Current Time using shortcode

I am using the below code to display current time in php supported time zones: <?php date_default_timezone_set('Asia/Kolkata'); $currentTime = date( 'd-m-Y h:i:s A', time () ); echo $currentTime; ...
0
votes
0answers
34 views

Dynamic CSS styles with ACF

I'm playing around with ACF to try to create my own rudimentary page-builder. One thing I'm trying to accomplish is using it with Gutenberg to create somewhat of a WYSIWYG. I'm not sure the best ...
0
votes
0answers
7 views

How do i updated auto generate password into the database using custom function into the function.php

How do i updated auto generate password into the database using custom function into the function.php? Currently function updated auto generate password into the database but problem is that unable to ...
1
vote
2answers
110 views

How to create a WP_Query to search the Title or Tag?

I have created a search using WP_Query, it seems like this query is looking for the queried term in title AND tags. Is there a way to have this search the title OR tags? $s = $request['s']; $tags = ...
0
votes
1answer
24 views

Cant connect to database with php 7.3

when i update my site from php 5.6 => 7.3.0 . i recviced this error 'Error establishing a database connection'.. But when i downgrade php to 5.6 , my website work fine . Anyone know this issue . this ...
0
votes
0answers
33 views

Deprecated errors in my browser

can anyone help me with these errors. My website is www.theme30.com Deprecated: __autoload() is deprecated, use spl_autoload_register() instead in /home/theme30/public_html/wp-includes/compat.php on ...
0
votes
0answers
24 views

Cleaner 'for each' loop for registering scripts in functions.php

I'm looking for a elegant way to register a ton of scripts I have sitting in a js directory on my server without having to sit and type them all out. I found this question here but it is 3 years ...
0
votes
0answers
24 views

WooCommerce Product save() function returns php notice: Trying to get property 'name' of non-object

I can't figure this one out. I've written the following function which updates the stock quantity of a particular item: public function update_stock( $sku, $quantity ) { $id = $this->...
1
vote
1answer
47 views

Same log message keeps on printing to debug.log file thousand of times

So i was debugging my PHP code while working with Wordpress site by writing to debug.log with error_log($message) or trigger_error($message). My message in these log statements keeps on printing ...
0
votes
1answer
15 views

Set a cookie inside the 404.php theme page

I'm trying to set a cookie with these code but the cookie is not created setcookie( 'name', 'carl', 0, '/names', 'https://my.webdomain.com', isset($_SERVER["HTTPS"]), true); I was looking on the ...
0
votes
2answers
22 views

WP + MySql db / PHP

I have a website running WP connected to a MySql db, where the latter uses PHP. I did not make the site and have only small experience with WP. This may be a simple question. The WP also uses ...
0
votes
0answers
17 views

Bifurcate woocommerce cart plugin in two parts

[woocommerce_cart] The above shortcode renders the woocommerce cart page, which will have these looks: What if we want just to generate just Part 1 or Part 2 as shown in the figure. Is that ...
1
vote
2answers
39 views

tracking number field in Woocommerce order [closed]

I am creating a custom field Tracking_ID on Woocommerce, where the admin will enter the tracking ID as value. How can i get the value of the created custom field and display it inside the customer-...
0
votes
1answer
21 views

Is it possible to use array_walk() to append terms to an array of posts?

I'm creating a masonry post grid of animals. I plan to filter the the visible posts by toggling classes. The classes would in turn would be the post's. I'm using an MVC theme and would like to get ...
0
votes
0answers
27 views

How to have multiple the_content() tags

I am designing a wordpress blog where you click on the title of the post and the content of the post opens up from the right side of the website. I was wondering if it was possible to have multiple ...
0
votes
1answer
15 views

Prevent publish status/date saved on transition_post_status hook

I'm using the transition_post_status to prevent a custom post type from being published based on a post meta field. It doesn't seem to work entirely, and that's where I need some help. Here is a ...
0
votes
1answer
22 views

Premature end of script headers: wp-mail.php?

I haven't edited wp-mail.php at all. I'm using the default WordPress file. I'm trying the whole submit post by email function that we know in settings (using gmail and pop3, if that's relevant). I ...
0
votes
1answer
34 views

Move Jquery.js to Footer

I want to move jquery.js from header to footer. I have tried following code: //Remove jQuery Default function replace_jquery() { if (!is_admin()) { wp_deregister_script('jquery'); } } ...
0
votes
0answers
23 views

403 Forbidden Wordpress Database Results

I have a website, hosted on Wordpress. I have created a custom table within the WPDB, with ARI Adminer, called 'people'. I have entered some entries for testing. I have created a test page with the ...
0
votes
0answers
14 views

Convert PHP/Javascript to Widget

I'm going to preface this by saying I am new to Wordpress development, and have never had to use AJAX or JQuery, which if what I have read is correct, this should be able to be accomplished with. The ...
0
votes
0answers
26 views

Posts in two different columns Bootstrap

I want the posts on the main page to be arranged in Bootstrap columns in this way: I have this code, but instead of the first two posts, only one is displayed. <?php get_header(); ?> <?php $...
0
votes
2answers
29 views

How can I fix the mixed content problems of the kk star ratings plugin?

I recently switched to ssl in order to provide a better and more secure website experience for my users. I nearly solved all of my mixed content issues, but the mixed content warnings of the ...
0
votes
1answer
20 views

How best to check if a user is from China and hide content?

To speed up my website in China I thought of hiding blocked services from Chinese users and wrote this and put it in functions.php $isInChina = false; $ip = $_SERVER['REMOTE_ADDR']; // This will ...
0
votes
1answer
18 views

Add HTML before a specific div?

I bought the "Woocommere Checkout Add-Ons" Plugin, which adds upsells to the checkout page - but it only allows to place text after the upsell checkbox. So I got the idea to add an image with some ...
1
vote
1answer
19 views

How to store post ID's in cookie or session to display the same posts later

I run a wp_query that fetches 4 posts from db with rand() and displays them in a grid to visitors. What I need is to display the exact same posts the query fetched the first time, a second time to ...
0
votes
0answers
21 views

Updating the database after parsing CSV document

Im trying to update the database based in a CSV document, if the first value in the CVS row is equal or greater than 300, it should update the database, and so on....but I cant get it to work, the ...
0
votes
0answers
22 views

Append query string to all URL's

A user will be directed from a website to a landing page that will have a query string in the URL i.e. www.sitename.com?foo=bar&bar=foo. What I want to do, is then append that query string to all ...