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.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
15 views

Capture the ip with a click inside the `<div id='click'>Click here</div>`? [closed]

Capture the ip with a click inside the <div id='click'>Click here</div> ? And capture the ip putting it in here $ip_array = array("xxx.xxx.xxx.xx");? <?php $ip = $_SERVER[&...
user avatar
0 votes
0 answers
14 views

Filter wordpress query by numerical order arguments

I have some programs that go according to the day but I want it to be filtered by custom field such as menu_order, that is, by numerical position through ordernum that I can give it This doesn't show ...
user avatar
0 votes
0 answers
40 views

orderby meta_value_num is not working, giving default order

I am trying to order my posts by a meta value so that I can show the most popular posts. But it is returning the latest posts instead. //WordPress loop for the custom post type $popular_args = ...
user avatar
0 votes
2 answers
30 views

wp_mail vs mail functions and header arrays

I've been having issues using wp_mail and mail functions in an application when specifying header elements in the function. I usually set up the header as an associative array, as in $mailheader = ...
user avatar
0 votes
1 answer
45 views

Custom map_meta_cap filter does not return ['do_not_allow']

I have created a custom role that only has access to certain pages and their children/parents. I have used map_meta_cap filter to solve this. However even though it goes through my function correctly ...
user avatar
  • 3
0 votes
0 answers
12 views

Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)

I'm making a certificate that's supposed to autogenerate and involves the need for multiple dynamic fields. I have everything else finished but I have difficulty trying to create 3 dynamic fields. ...
user avatar
-1 votes
0 answers
6 views

Search for products [closed]

I made a search. If I enter the whole name it shows me the product page, but if I enter something like "adssadsaqweas" it shows product-archive.php how I can achieve if I enter the name of ...
user avatar
  • 1
0 votes
0 answers
8 views

How to show upcoming events according to start date field

I am trying to show upcoming events. I have created a custom post type "event" in wordpress. and by using ACF plugin i have created date field for every event. now i want to show upcoming ...
user avatar
0 votes
1 answer
25 views

Understanding webhooks

I'm kinda new to this part of programming, and I find it really confusing. I have a script that makes some contact with a third party api. It basically adds a customer to their data. What I heard is ...
user avatar
0 votes
0 answers
23 views

PHP: $_SESSION destroyed after page reload for my custom session

I have develop a plugin for customer portal. For check login I have use custom session. Few month ago I have face this issue which create for session_start() function and I have already fix this. Now ...
user avatar
0 votes
0 answers
20 views

Some problems in custom widget

I made a custom widget for my template, which has an image upload section For the first time, I upload an image, it displays correctly, without any problem, but when I want to change the image, it ...
user avatar
  • 1
0 votes
0 answers
20 views

Searching a tab/space delimited text file based upon form criteria and returning a 'record' into a word press results page

This is my first foray into turning a current perl (.pl) script into a bit of code within WordPress. We're looking to migrate this process/page which resides on an old web server into WordPress. ...
user avatar
  • 1
-1 votes
0 answers
38 views

in_array function problem in wordpress [closed]

I am facing a problem that I cannot find a solution. The problem is this in below code: $ilikiaki_omada = get_terms( array( 'taxonomy' => 'pa_ilikia', 'hide_empty' => false ) ); $omages = array(...
user avatar
0 votes
1 answer
10 views

if custom field doesn't exist, use post thumbnail instead, as image background

I am trying to modify a code in my theme, but I only partially succeed. I need a working condition, if a custom field is not present, to use the post thumbnail instead, as the background image. if the ...
user avatar
  • 167
0 votes
0 answers
18 views

Call a function in functions.php from within <script> tags (JS)

I have a pretty simple problem (I think) which I can't find an answer to. The setup is pretty basic. I have a function which is in functions.php: function function_A($variable) { return $variable +...
user avatar
  • 111
0 votes
0 answers
12 views

Restrict post to current user in postmeta

i hope someone can help, i'm have not php skill, try with some sample without success. i have a CPT with metafield "email" where stored user email . does its possible to restrict post url ...
user avatar
  • 1
0 votes
1 answer
27 views

Wp Query : Order by distance lat,lon

I'm new to this forum, sorry in advance :) I have a problem with my display of my posts Let me explain ^^ I want to perform an orderby => '$distance' and display the posts accordingly. $lat2 and $...
user avatar
0 votes
1 answer
32 views

Displaying images outside the content

I am trying to achieve to following design: This is what I got so far: I'd like to have the bottom images as in my design example. This is, how my single.php looks like. I just can't find a solution ...
user avatar
  • 1
-6 votes
0 answers
30 views

Why is there a white space at header on load? [closed]

Can anyone tell me why that when my friends website loads it has a white space on load, that then disappears? He asked me for help but it has me stumped as to why it is doing it https://...
user avatar
0 votes
1 answer
26 views

how to Update 15k products on plugin activation with meta_option

We need to update about 15.000 products with a meta_option after a plugin gets activated or after a plugin gets installed. However, our code does not execute on all products, though the plugin ...
user avatar
  • 149
0 votes
0 answers
15 views

WordPress Conditional / Multiple Taxonomy Query

I am trying to create a custom WordPress taxonomy query with multiple but conditional statements. However I am having issues when more than one taxonomy query is added to the statement. $tax_query = ...
user avatar
  • 1
0 votes
1 answer
10 views

change the default order of posts only for specific categories

I want to change the default ordering for posts, to last modified date, but only for certain categories pages (when visiting certain category pages) I have this function code, which is working, but I ...
user avatar
  • 167
0 votes
1 answer
21 views

Admin submenu issue with PHP not detecting two strings as equal

I am adding a submenu page as follows: add_submenu_page( $slug, __('Categories','acs'), __('Categories','acs'), $cap, 'edit-tags.php?taxonomy=acs-field-group-category&post_type=acs-field-group' ); ...
user avatar
0 votes
0 answers
13 views

How can I modify this code to make the search box include tags and meta

How can I modify this code to make the search box include tags and meta I would like the search in same box if($_GET['s'] && !empty($_GET['s'])) { $text = $_GET['s']; } if($_GET['type'] &...
user avatar
0 votes
0 answers
14 views

Validating an email input from form field before submit using JQuery, AJAX, and PHP

I have a form and one of the fields is an email with id email and after the user inputs their email and clicks outside the field, I wish to get the value of the email and then use ajax to pass that ...
user avatar
  • 1
1 vote
0 answers
12 views

Output: "Array"

I added a table in the database which collects names through a form. I want to output the latest entered name on a different page than the one which contains the form. In order to print the data I ...
user avatar
  • 11
0 votes
0 answers
16 views

Create condition for Author bio Social Links

I made Social Links for Author bio Now, I want to make a condition that whenever Social is added, the <ul class="social-area social-area-2"> </ul> class should be created. If no ...
user avatar
  • 1
0 votes
0 answers
22 views

show different content by using parameter

i want show different content for users by using get parameter. So i check payment and add or not . $payment comparing userid and courseid from db and gives true or false. In page template i have ...
user avatar
0 votes
2 answers
61 views

Broken kses.php function "wp_kses_named_entities" crashes WordPress

To clarify -- these files in the error were NOT edited at the time of the error, I checked twice. And I checked again by doing a diff with a fresh WordPress install. I had to remove the broken line -- ...
user avatar
  • 431
2 votes
2 answers
52 views

iframe not showing in content on blog page

On the post editor field, I have added an iframe code. But on the frontend, it is not showing the content with the iframe code. I have added the below code to print the excerpt on the blog page: <?...
user avatar
  • 31
0 votes
0 answers
14 views

Is it a connection or relationship between 2 custom post types?

im working on it now for two days and no outcome. I have woo products and custom post types called "lankytinos", what I need to do: You open product and there are the list of "...
user avatar
  • 1
0 votes
0 answers
39 views

Why does PHP called with Jquery AJAX not allow additional php code to be added?

I wrote a plugin a few years ago that successfully uses AJAX and then recently I tried to add more of the same functionality but it fails. In the PHP files, I localized admin-ajax into the JQuery ...
user avatar
0 votes
0 answers
19 views

Add class to ul and li in wp_na

I want to add class to ul and li using wp_nav_menu , I have checked documentation and I found this : wp_nav_menu(array('theme_location'=>'primary','menu_class'=>'navbar-nav')); but the class is ...
user avatar
0 votes
0 answers
21 views

How to sort posts by active category in Wordpress?

I want to sort posts by active category, can you tell me how it can be done?
user avatar
  • 1
0 votes
0 answers
17 views

Infinite Loop in Wordpress Installation

I've installed NginX with PHP 8.1, MadriaDB and Wordpress on Debian 10. I can reach the wordpress installation page. When i insert the details for the database and username it goes forward, but when i ...
user avatar
0 votes
0 answers
17 views

How can i programmatically change the SKU of a product based on product variation?

In cart page I have added a button for each line to be able to add a variation (gift package) to the products. Now I need to add a SKU suffix displayed on the order page in the backend if this ...
user avatar
0 votes
1 answer
22 views

send popup after wp_redirect()

Hello Wordpress Developer, I want to ask about how to send popup after wp_redirect(); I'm sending link to user for verify. I just want to let user know that the verify process is done. Here is the ...
user avatar
  • 5
0 votes
0 answers
17 views

Validate search against a list of codes in wordpress

Hello I have a wordpress website and I need an input field where I need to enter a code and validate against a list of codes. If the entered code is in the list I need to redirect to one page and if ...
user avatar
0 votes
0 answers
19 views

wordprees multi-site in user panel add filter

I want to add new custom filter in WordPress network admin restrict_manage_users for network admin in the user panel I want a custom filter option not a custom column, i just want to add one filter ...
user avatar
1 vote
1 answer
46 views

How to render a block from php template

forgive me a question that may seem stupid, but has been keeping me busy for hours: I'm trying to insert a gutenberg block into a category php template, but neither the render_block () function nor ...
user avatar
0 votes
0 answers
24 views

Export post data with xml to other site using php soap

At one non-wordpress site, I have to show dynamic posts (depends on chosen result), it`s thumbnail, header and short description. Before, I have to fetch these data from other wordpress site. Can I do ...
user avatar
0 votes
0 answers
22 views

Remove role of user after X days

I have issues getting this code to work. I want to BUGSexpdate which has a set date to remove a role when the date is reached as I want to "rent" out movies. This code I found on a similar ...
user avatar
0 votes
0 answers
5 views

How to change this Download Page Redirector URL Changle Method to using Button Id?

/* Set endpoint of url */ add_rewrite_endpoint('download', EP_PERMALINK); function pixabin_download() { add_rewrite_endpoint('download', EP_PERMALINK); } add_action('init', 'pixabin_download'); ...
user avatar
  • 1
0 votes
1 answer
26 views

dynamic page using php from sql database

The Problem I am really struggling to get wordpress to generate a page dynamically based on the content of a database. The Context I have a sql database which contains unique slugs and Ids, and I am ...
user avatar
0 votes
0 answers
19 views

Execute PHP code only with specific user role

I have a WordPress website with woocommerce and I want to set a minimum order quantity for products. I have found code online which does exactly what I need it to do and it works perfectly.(the code ...
user avatar
0 votes
2 answers
27 views

Upload non-featured image to image field

I'm trying to upload some associated media to a custom post type. Using file_put_contents() I'm uploading an image and trying to set an ACF image field to be the path to that file. But reading the ...
user avatar
  • 126
1 vote
2 answers
324 views

Why does this code snippet create a critical error on my site? [closed]

This snippet used to work fine but with the update to PHP 8.0 it now breaks the site when a WC order is switched to this custom status //Add custom bulk action in dropdown add_filter( 'bulk_actions-...
user avatar
  • 113
0 votes
1 answer
37 views

Wordpress - Get Posts with Category data

i have a question about improving my solution. For my task i build a Gutenberg block which shows the latest 5 Posts. This Posts show also the Category Name in the Frontend part which have different ...
user avatar
  • 1
0 votes
2 answers
46 views

Usage of call back function of add_meta_box()

I am learning WordPress Plugin Development. My Code is like below. class Admin { public function __construct() { add_action( 'admin_menu', [$this,'news_meta_boxes'] ); ...
user avatar
  • 387
0 votes
0 answers
13 views

Repeat a function with 24hrs gap for n number of days

I have a function like this: $points = $this->get_fixed_points_to_earn(); that is fetching the value of get_fixed_points_to_earn. I have another function for this: $days = $this->...
user avatar
  • 31

1
2 3 4 5
202