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

PHP call_user_func_array() error

I am getting this error can not find this php file anywhere. call_user_func_array() expects parameter 1 to be a valid callback, function 'ms_whitespace_fix' not found or invalid function name in /...
-1
votes
1answer
46 views

wordpress select multiple options and illegal string offset 'timeslot' [closed]

<form method="POST"> <select name="timeslot[]" multiple="multiple" size = 4 required> <option value="1">1</option> <option value="1">1</option> <...
0
votes
1answer
172 views

How to auto-generate random numbers in username?

I have a public-viewed community site. I am able to insert First & Last Name fields in WooCommerce Registration form, and auto-generate username based on the combination of First+Last Name. But ...
0
votes
0answers
12 views

Shortcode inside another shortcode / Post page to Woocommerce

Good morning, I made a shortcode [block id="tt2"] in a post, which included another shortcode to insert php in brackets [insert_php] phpcode [/ insert_php] but then, when inserting the first shortcode ...
0
votes
1answer
32 views

get href content [closed]

I have this code <div data-slide-id="zoom" class="overview active" data-lazy-background="" style="background-image: url(&quot;https://dy9ihb9itgy3g.cloudfront.net/products/1183/d8066/...
0
votes
0answers
19 views

Redirect after login depending on the URL

I am having issue with this part of my function: The idea here is to set the URL to ?login=true if the user logs in via wp-login.php. But if the user visits a restricted front end page which contains ?...
1
vote
1answer
52 views

Remove the first 5 characters of the_title and orderby that

I have a custom post type where all titles are dates (in this format: YYYY-MM-DD). I need to order them by month then day, but not at all by year. So I imagine I need a filter to 'look' 5 characters ...
0
votes
1answer
33 views

Windows Setup: Error establishing a database connection

I have MySQL 8.0.12, PHP v7.3.2 64Bit and Apache 2.4.38 64Bit installed. In theory I have everything that is needed to run WordPress locally. Through MySQL Workbench, I have tried the Host, Port, ...
1
vote
1answer
31 views

Using a variable in is_page(array())

Similarly to this topic I need to extract some page IDs from user input (a theme options admin page), store them in a variable, and then filter using the is_page() filter. The input consists of ...
0
votes
2answers
19 views

Function returns text instead of html [closed]

I use this function to add prices to my WooCommerce variation dropdown menu. I am trying to wrap the price with a span tag but it's displaying the tags as text. add_filter( '...
0
votes
2answers
42 views

Searching a custom WP table and displaying results in an HTML table

I have a custom table in the WP database called wp_products. It has columns titled ID, SKU, Details and Page. I'm trying to search this table via the default search box, so I've replaced my search.php ...
0
votes
1answer
28 views

get_current_site() is undefined

I get the error Fatal error: Uncaught Error: Call to undefined function get_current_site() in XXXXXXXX Why is this happening? Do I need to load something before I can use that function? Is my ...
0
votes
1answer
30 views

Make textarea required. Help [closed]

i cant make textarea purchase note required in woocomerce dokan can i use purchase note for selling keys and soft? Its safely?
0
votes
1answer
26 views

Create form which redirects to site in network?

Just created a page in my multisite network where the user can input a sitename and be redirected to the site. This works very well, but if there is a typo or if they enter a site that doesn't exist ...
0
votes
1answer
20 views

How to make a “page-option” in WordPress

I had made a WordPress website with my own theme. I have a navigation menu on the top of my website with dropdowns. Then you click on a page in this menu, I want you to navigate to a page, where ...
0
votes
0answers
10 views

Display random posts, favoring posts published close to todays date regardless of year

I would like my start page to display random posts, but put posts published close to today’s date first and posts published far from today’s date last - but regardless of what year the posts were ...
2
votes
1answer
42 views

WP showing “warning: call_user_func_array()”, What to do?

I am currently working on designing my blog and am almost done but when I updated to 5.1 WordPress version in XAMPP, it started showing up this error message: Warning: call_user_func_array() expects ...
0
votes
1answer
19 views

How to echo a PHP Code After the Content

i wanted to execute a code after the Content of each blog post. I just want it to be on posts and not on pages. I could execute simple html by the method but could not put the following content. ...
1
vote
1answer
13 views

Can one create multiple Custom Post Types with a for loop?

I am trying to use a for loop to create multiple custom post types in a plugin. The plugin options page allows users to set the number of custom post types along with the singular and plural names for ...
0
votes
1answer
12 views

Redirect user role to a specific page on login in a multisite network?

I have been working on this for some time now. I want to redirect a specific user role to a specific page in the backend on a Multisite install. I have been able to do this finally, but I get an error ...
1
vote
1answer
27 views

Remove a div from RSS feed

If someone can help to remove a div from my RSS feed. I want to remove below code from my RSS feed. <div class="well"> <a class="btn" href="foo.com">foo</a></div> Thanks in ...
0
votes
0answers
29 views

Woocommerce check out fields to display in printed receipt

I'm trying to show on my order printed receipt some checkout fields and extras from the products. The website is www.prontoitaliano.co.uk/shop What needs to appear on the receipt are all the extras ...
0
votes
0answers
10 views

How to display the last keywords used during 1 day (1 per post)

I want display the last keywords used during 1 day but 1 keyword per post. Like this: It's like the topics of the day. You can check the example in https://www.latercera.com/ <ul id="footer-tags"&...
0
votes
1answer
13 views

How do I create a new post upon registration with the users first and last name as title

I've been working at this for some time and for the life of me I cannot figure this out. Here is my code as of now. add_action('user_register','create_new_user_profile', 999); function ...
0
votes
0answers
20 views

I need to put WooCommerce Featured image in Download page

Can you guys help me because I'm stuck with this? I need to have a product image in front of the name of the product in Download page in Woocommerce. Something like on this screenshot This is the ...
0
votes
0answers
10 views

Embed Phantomjs alternative inside plugin

I use phantomjs inside plugin in order to render a page with a custom shortcode and capture the generated output as an image. So i use php-Casper (which relies on PhantomJs) in order to capture the ...
4
votes
1answer
216 views

cURL 28 error after switch from to brew php 7.2 on localhost

I've been running into trouble with all my localhost install of Wordpress reporting cURL error 28 (timeout) since (I believe!)I've switched my PHP version from 7.0 to 7.2 with brew on my local Mac OS ...
0
votes
0answers
22 views

Handling form actions in Wordpress

A non wordpress PHP file has this kind of code: <form class="someclass" action="page-contact.php" method="post"> But when in WordPress it doesn’t work. suppose we are here(a WordPress page or ...
0
votes
0answers
31 views

spl_autoload_register is slow for WordPress sites

I have an existential doubt, I know that the tendency now of PHP 5 and PHP 7 is to load the classes dynamically with the function spl_autoload_register + namespace PHP projects such as invoice system, ...
0
votes
0answers
28 views

Load Search Results in Div

I would like to have my search results load into a div that could appear across all pages of my site, rather than into a completely separate page labeled "Search Results". I have reviewed a similar ...
0
votes
1answer
18 views

Why does a header location on admin_head remove the query var I'm setting in the location?

I have the following code which I thought would load the location with a query var of saved=1. public function __construct() { add_action( 'admin_head', array( $this, 'test' ) ); } public ...
0
votes
0answers
8 views

How to update the stock of a variable product by attributes

I'm designing an intranet of internal orders where I choose the product list by means of php code and woocomerce functions, all good but as they are variable products and each attribute has a stock, ...
0
votes
1answer
14 views

Replacing entire tag with shortcode - JavaScript [duplicate]

I'm trying to replace a whole tag with a shortcode, if the tag text equals a value. I'm placing this script into the footer of the page. Here's what I'm trying: var stockcounter = document....
0
votes
0answers
19 views

Create a custom User Role within a Child Theme

I want to make a very custom user role; i.e. a 'sub admin' if you will. Some things I'd like to do would be to disable the 'html abilities' from within the 'edit page or edit post' mode for this user (...
0
votes
2answers
34 views

Multiple do_shortcode($content) within one shortcode

TLDR; How can I run a shortcode with multiple shortcodes inside of it? I'm trying to run a shortcode with multiple shortcodes inside of it. I can successfully run a shortcode with one shortcode ...
0
votes
0answers
12 views

File Upload with JS and CSS

Whats wrong with the below code, it does not show the file I choose to upload: // PHP Code: $form .= '<script class="jsbin" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">&...
0
votes
1answer
24 views

Guttenburg and Classic Editor - How to use the custom guttenburg block in classic editor?

I am making a theme, in that I have created some custom blocks for guttenburg but the problem is how the user can use the guttenburg blocks if he/she switches to classic editor. For an example, Let ...
0
votes
0answers
12 views

Wordpress Edit options

<html> <body> <?php if(isset($_GET['id'])) { global $wpdb; global $wp; $id = $_GET['id']; $fname = $_GET['fname']; $lname = $_GET['lname']; $result = $wpdb->...
0
votes
1answer
28 views

How do I visualize the author's post from the front end?

Currently posts are created automatically with an importer and I want the user to be able to see their own post. I already have the code to display the personalized post and the button to modify it. ...
0
votes
1answer
42 views

How to trash multiple post/product programmatically

I need help with figuring out how to trash multiple product at once. I'm trying to trash all products in a category is its order is successfully created. I.e when i buy 2 or more products from machine ...
0
votes
1answer
45 views

wpdb Cannot Update column in Database

In the custom table, I try to update a specific column with using $wpdb->update class and using HTML form for updating one column that has same id (in here dlname Is ID of data ). The problem is this ...
0
votes
0answers
22 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 ...
1
vote
1answer
17 views

How to display a value from a radio button in the options menu in wordpress

I'm a little stumped on this one. I'm not very experienced when it comes to PHP, but I have figured out how to display a value inputted from a text box. I'm now trying to do the same with a radio ...
0
votes
1answer
27 views

When echo follow Ajax button inside Ajax pagination template not working?

Ok, I will try to be more clear this time, and i really need your help guys. I'm using an plugin that working with Ajax for creating a follow button to make our users following each other. I putting ...
0
votes
1answer
27 views

PHP Error in Wordpress Theme

So I'm having some issues with an AWS multisite hosting of wordpress. Every couple of weeks my entire instance of websites goes down. The first time it happened I was getting 500 errors so I just ...
0
votes
0answers
27 views

How to add a full working piece of website already coded, to a large scale Website design project?

I've written 5 PHP files each of which are dependant of each other and contains one style.css also. This whole project works fine when executed alone and includes home.php which includes HTML code for ...
0
votes
0answers
14 views

Integrating Amazon & eBay orders into Woocommerce on WP Multisite

I am trying to integrate Amazon & eBay store orders into Woocommerce which is on a WP multisite and can't seem to get anything working even third party plugins such as Codisto LINQ don't want to ...
0
votes
0answers
17 views

Filtering Date from JSON Snippet Output in PHP

Been struggling for two days now, please help. WP Product Review Lite generates Schema through JSON code. The code is constructed through the class 'WPPR_Review_Model' with a function called '...
0
votes
0answers
62 views

Contactform7: display results from CURL

I am stuck into a problem. I sent contact form data through curl and I get a response from an API. How is it possible to display there results on my page? Ideally through AJAX and in my own custom ...
0
votes
1answer
59 views

Display Data in Table from External Database in WP using Shortcodes

I have successfully coded a secondary database connection for my wordpress site in the functions.php file in wordpress. I have used the following to create shortcode and run the data to my table where ...