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
0 votes
0 answers
11 views

Limit entry to a WordPress page

How can I make a page so that only some body that bout a certain product can enter the page in WordPress ? I tried to find a plugin but I couldn't find one
1 vote
0 answers
20 views

How do you create a front end form that enables the editing of member-specific custom fields in WordPress?

I would greatly appreciate any help you can provide regarding the creation of a front end form to allow members to edit custom posts that I have created in their admin panel. I have successfully ...
2 votes
0 answers
77 views

AJAX returning blank result

I'm using ajax to filter a list. The filter works as it should most of the time, but for some queries it returns a blank result. When this happens, the error in the console is: PHP Errors in Ajax ...
1 vote
0 answers
12 views

How to create a "Most Popular" & "Latest" TAB in Wordpress

On my gaming website, I upload videos to the website, which is on the homepage of the website. The problem is, that I need to add a "Most Popular" tab & "Latest Videos" tab, ...
0 votes
0 answers
14 views

Sort posts by Date (DESC) and by ACF: active_inactive (ASC)

I am trying this but does not seems to work. I can make them work individual, but together i am not able to sort the posts by post created date and ACF field active_inactive. function ...
0 votes
0 answers
15 views

Customize create table SQL statement in any WordPress plugin

I'm working on a project (WordPress) that using a custom data directory to store any_table.ibd (InnoDB files) files (mandatory requirement from customer). So my requirement is, need to add DATA ...
  • 101
0 votes
2 answers
42 views

I want to show image from custom field image on my custom page template

I have created a taxonomy and in that taxonomy i have created custom field for image. Now I want to show that custom field image on my custom page template with category name. I have tried much it is ...
0 votes
1 answer
41 views

Why does WordPress not send the user the email to add a password?

I want to achieve that when the user registers on my website, I send him to a specific page, and without automatically logging in. When we do not register on a WordPress site, we are registered and ...
0 votes
1 answer
43 views

Woocommerce - Include custom user meta in order 'filter by registered customer' Ajax search

I am trying to include a users custom meta named 'sageaccountnumber' within the 'filter by registered customer' section of the WooCommerce orders list as shown below: I already have the custom meta ...
  • 1
1 vote
1 answer
64 views

Custom plugin with shortcode not working

I have a long-term client with a ton of custom shortcodes and functions for miscellaneous purposes we've accrued over the years and I decided to re-home them into a custom plugin so I didn't have to ...
0 votes
0 answers
20 views

Slick slider not working on wordpress

I added all slick files and enequed them in my fuctions.php- console is clean there are no error messages for that now. I initialized slick in my custom js file and called the class slider from my ...
  • 3
0 votes
1 answer
18 views

get_query_vars always retruns empty value

I try to get this example running: function themeslug_query_vars( $qvars ) { $qvars[] = 'custom_query_var'; return $qvars; } add_filter( 'query_vars', 'themeslug_query_vars' ); $testvar ...
  • 3
0 votes
0 answers
20 views

WordPress Custom Page Blog Template Pagination Problem (Pagination Not Displaying)

My website doesn't display pagination no matter what I do or try. Can you help me, please? Tried a lot of different codes and Plugins but no dice. Here is the code for test template: <?php /* ...
  • 25
0 votes
1 answer
48 views

links Slick jS library using wp_enqueue_scripts not pulling

I added the following to my fuctions.php in my active child(wp 2022) theme in wordpress to eneque files from js slick slider library. However I'm getting the 'fail to load resource' error message on ...
  • 3
0 votes
0 answers
16 views

How to get the ID of the WordPress user

I'm having a lot of trouble with the PHP script below that I need to run on a .php page of my WordPress website which hosts a set of wpForo forums. I need to obtain the field wa_wpforo_profiles.userid ...
0 votes
0 answers
21 views

How do I remove the filter from the orders and add custom status in Dokan?

I would like to remove the filters in the orders tab from dokan dashboard. Here: [![filters][1]][1] I want to remove these status in the dokan dashboard: [![status][2]][2] Someone can tell me where ...
1 vote
0 answers
18 views

Displaying generated HTML within a Wordpress site

So I already have a WordPress site, that has a theme and everything (don't need tutorial on theme creation, it is done). It has been up for awhile. I want to integrate into it some HTML pages that a ...
0 votes
1 answer
19 views

How call WordPress shortcode inside function file

I am trying to add shortcode to a new WooCommerce tab in the account section that I created in the functions file. add_action( 'woocommerce_account_new-item_endpoint', 'add_new_item_content' ); /** *...
  • 1
1 vote
1 answer
77 views

Sorting a custom post type in pre_get_posts

I have a custom posttype "Talks" which have a custom field name start_date. The posts start_dates are the the past and in the future. I need the future posts to come first with the ...
  • 11
0 votes
0 answers
22 views

transition_post_status hook, works - but not if the post is new

I have no idea whats going wrong. My transition_post_status function works if the post is saved as a draft or another status first, then saved again as the 'transferring' custom post status, which it ...
0 votes
0 answers
17 views

Increase Upload Size with htaccess | MAMP

I want to increase the upload size of my WP installation. It works on my host, the live version of the page. But I can't reproduce it locally. I run it with MAMP. I did: php_value upload_max_filesize ...
  • 105
-1 votes
1 answer
49 views

Adding date and time to the same request

I would like to call the get_the_date and get_the_time in the same request. Is this possible? This what I'm doing now. <?php $header = array( //Home "15" => array( &...
0 votes
0 answers
14 views

How to run site locally after downloading database

It has been 7 years since I touched on wordpress but I remember a way of downloading database copy and running wp setup and using the live website database downloaded you can repopulate the website on ...
  • 484
0 votes
1 answer
50 views

I have an error WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version

Hello im new to WPDB and this is my error WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use ...
0 votes
0 answers
42 views

How to override plugin function in code snippets Wordpress

I want to override the PHP function of the plugin file in code snippets Does anyone have any idea how to do that?
1 vote
1 answer
67 views

getJSON response to PHP

I am working on a project where i must call a 3rd party API from client-side then process the response in PHP before displaying it in on the front end. So i planned it in my head like this: use ...
  • 31
0 votes
0 answers
10 views

How to change shipping method title based on cart amount?

I applied a 5% discount to the Woocommerce cart, based on cart amount and shipping method, which seems to be working fine. But I cannot manage to change the shipping method title when the rule applies,...
  • 1
0 votes
0 answers
45 views

Deprecated: stripos(): Error in Wordpress After Updating to php 8.1

Showing this error msg after upgrading to php 8.1 in wordpress Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /public_html/wp-includes/functions.wp-...
0 votes
0 answers
15 views

How to disable page create for custom post type, but allow a page with the post types slug to be created?

I have a custom post type called integrations, which I have registered like this: register_post_type( 'Integrations', theme_build_post_args( // $slug, $singular, $plural 'integrations', '...
  • 145
0 votes
0 answers
34 views

How can I display all these movies in DESC order by modified?

This is the wprdpress script theme i want to display the movies list in DESC order by Modified like when i update any post/movie manully and than the movie show in first page on 1st position <?php ...
0 votes
1 answer
29 views

Count custom posts type and filter by tag

I'm using this code to count the number of posts of a specific custom post type that have also a specific tag: <?php //Array $args = array( 'post_type' => 'cars', '...
0 votes
0 answers
69 views

Change WooCommerce Order status from frontend form submitted data

I want to have a form on the front end of the site asking for the WooCommerce Order Number and phone number. Once the user submitted the details, it'll check for orders and if the data matched then it'...
  • 31
0 votes
0 answers
31 views

WooCommerce Modal Fly cart on add to cart - With AJAX

I am trying to make a custom Flycart that can provide same functionality as the plugin 'WPC Fly Cart' Currently I have a modal div html element in my header.php, but how can I correctly trigger it and ...
  • 1
0 votes
0 answers
33 views

/page/2/ redirect to 404

I make a filter form in the category page and get parameters with get_query_var, my problem is in the Pagination when the user filters a parameter and wants to go to page 2, it redirects it to 404 ...
0 votes
1 answer
18 views

How to put a class in the p tag automatically added by the_content() in the wordpress loop?

I tried with this code <?php $args = array( 'post_type' => 'testimonials' ); $query = new WP_Query($args); echo '<section id="depoimentos" class="...
0 votes
1 answer
129 views

How to group by column a and sum column b and c in a php array

I got the following array: [0] => Array ( [kanel] => 5 [peber] => 0 [shipping] => A ) [1] => Array ( [kanel] => 25 [peber] => ...
1 vote
0 answers
17 views

Get category name of current post (CPT UI)

I used CPT UI to create custom post types "Job Offers" which has a taxonomy with slug "job_offers_categories". In the CPT Categories I have 4 categories: Exchange Programme Job ...
0 votes
0 answers
15 views

How to make a Template page to show the information of different things Shop and Product page?

Is there a way to make a page with multiple items (Like a Shop or products page) and a Single information page / Details page? I want to make a Custom template of a Single Details page that will open ...
0 votes
0 answers
13 views

Remove /Page/ from slug when we're visiting 2nd and other inner pages of the blog page

I want my site shows all WordPress pages, including archives and categories, without URL/page/ slug. Examples: www.mysite.com/page/03/ -> www.mysite.com/03/ www.mysite.com/blog/page/2/ -> www....
  • 723
0 votes
1 answer
134 views

Error with PHP 8

Hi i use a widget with php code on php7.4 everything ok with php 8 i have an error.... Warning: Undefined variable $post in /xxxxxxx/wp-content/plugins/php-code-widget/execphp.php(27) : eval()'d code ...
0 votes
0 answers
28 views

Replace block content with an array

I'm using GenerateBlocks and Metabox, and specifically relevant for this post, MB Relationships. I have a query loop created with GenerateBlocks that displays a list of Events (CPT). I have another ...
  • 17
0 votes
0 answers
13 views

How can I change the location where the custom field is displayed in the Quick Edit tab in WordPress

That's my situation right now: I want to display my "Artist" custom field under the "Slug" field, with the same HTML structure. But how? Example: The following code may help: // ...
  • 1
0 votes
0 answers
91 views

Show Login Errors In Wordpress/Elementor (Code "works", but breaks site)

I customized my WordPress/Woocommerce account pages using Elementor and now they don't show error messages when users enter the wrong password, etc. I found this tutorial online that worked nearly ...
4 votes
1 answer
205 views

How to enable REST API on custom post type without Gutenberg?

I understand that you have to enable the REST API in order to use the Gutenberg block editor, because Gutenberg relies on it; however, I want to use the Classic Editor for a custom post type and still ...
0 votes
0 answers
14 views

How do I organize posts based on their taxonomy?

I have a huge assortment of posts. They each belong to a taxonomy (let's say Taxonomy 1, Taxonomy 2, Taxonomy 3, and Taxonomy 4). On the page where they are displayed - I wanted them to be displayed ...
  • 1
0 votes
1 answer
186 views

Use of undefined constant issue

I have the following warning notice from my functions.php file: Warning: Use of undefined constant ENVIRONMENT - assumed 'ENVIRONMENT' (this will throw an Error in a future version of PHP) This is ...
0 votes
0 answers
26 views

How can I trim /page/ URL with PHP in Wordpress

Let me explain the situation to the best of my abilities. I'm using "?orderby=date&order=ASC" and "?orderby=date&order=DESC" which works fine. If the user is in domain.com/...
  • 25
0 votes
1 answer
27 views

How to sort wordpress posts by selecting a year from a drop down?

First of all, know that I'm just a beginner. Now that we got that out of the way... I've created something like this: <li class="dropdown"> <...
  • 25
0 votes
2 answers
111 views

How do i set global variable in a function in wordpress functions.php

Please vet this code and help me with how to declare '.($a['link']).' variable such that i can echo its content in single.php function mp3_download_link_att($atts, $content = null) { $default = ...
0 votes
1 answer
158 views

Convert custom field date format to "Wordpress default"

Hello ladies and gents, I'm using F j, Y (e.g. December 28, 2022) as default date format on my site (set in the admin settings). I have an event custom post type with an event_start_date custom field. ...
  • 17