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

Passing a value from an input field to a php function in Wordpress?

When I select the category from the dropdown menu, it updates correctly in the input field. Ideally, it should update the recipe filter in recipeIndex.php. I've tried wrapping the input in a form with ...
0
votes
0answers
17 views

How do I remove archive loop in WordPress (custom taxonomy)

OK, it might seem a bit odd to want to do this but I do have a good reason which would take a while to explain! Is this possible? I am assuming the easy way is to hide some HTML via CSS but there must ...
0
votes
0answers
18 views

How to use wp_create_nonce() to get user ID in WordPress Rest Api

I know a lot of questions have been asked about this topic but I have had no luck implementing their code. I want to be able to use get_current_user_id() inside my WordPress Rest Api. This is what I ...
0
votes
0answers
17 views

How to use WordPress header function and footer function and not load word press database

I am no longer able to access my database after including WordPress functions in my index.php file. I used the following WordPress functions to access the WordPress header and footer <?php @...
-1
votes
0answers
15 views

Facing 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration.'

How to fix this error? Error: An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums. ...
0
votes
1answer
18 views

Shortcode to embed Edit Account form not working

I'm creating a short code that shows both first and last name of the user if he's logged in, or, if he's logged in, but hasn't configured any name, it will return a random name with a message telling ...
0
votes
1answer
10 views

How to assign a specific service to a specific provider based on location

I’m looking for a way to assign a specific service to a specific provider based on location. I’m currently developing a website with various service providers providing the same service. Do we have a ...
0
votes
0answers
23 views

How do you output custom code before a subset of posts in the loop?

I am trying to put a header before past posts and after future posts. I'm using get_posts() in a function to output the posts using a foreach loop for a custom post type ordered by date (meta key). If ...
0
votes
1answer
16 views

Redirecting to a custom forgot password page

I have created a custom login and registration page with the plugin 'User Registration' and they both work perfectly fine, however, on the login page if I click on the ‘Forgot password’ link, it takes ...
0
votes
0answers
12 views

Wordpress polylang wp_set_object_terms sets category to linked product [closed]

I am using this function in order to set a product to a category. But instead of setting the $new_product's category it adds the category to its linked product translation... wp_set_object_terms( $...
0
votes
0answers
7 views

I would like content on the checkout page for Check Payments to also appear on the Order Received Page

I have created a checkout page with two payment options, Check Payments and Pay with Bitcoin. For the check payments option, I have added the "Pay to" name and address and it appears on the ...
0
votes
0answers
11 views

Precheck fields when I add a new post

Precheck fields (like categery or custom fields) in new post based on user id. Its possible to make this?
0
votes
1answer
21 views

Rename a folder via HTML POST request

I am trying to rename a folder in the uploads folder if an HTML form is submitted (used to edit entry names). This following code is what I have so far but it isn't working. if(isset($_POST['...
0
votes
0answers
14 views

Can I load the same composer package twice without conflict?

So, I'm running mrclay/minify library on my theme on WordPress to minify all the CSS and js files to boost performance. On the website, I use the W3 Total Cache plugin so it takes care of everything ...
0
votes
0answers
16 views

Hide Approved status for certain users in users list

In the list of all users in wp-admin, i would like to hide the “Approved” status for certain users. These users only need to see “Pending” status to accept them. I didn’t find any plugin to make this, ...
0
votes
1answer
29 views

Trying to add some custom text into Wordpress Post title via function.php

I need to add a custom text in wordpress Post title dynamically which I'm trying to add via this code in function.php Following code is not working add_filter('the_title', 'new_title', 10, 2); ...
1
vote
0answers
21 views

Add a CSS class based on categroy id to archive pages

How can I add a css class based on categroy id in archive pages body in wordpress? I want to style each category page different
0
votes
1answer
31 views

Display a custom name when the user has no name settle in his account

I'm creating a code that shows the First Name for logged in users, using a shortcode, but I noticed that if the user has no name settle, it will display a blank space. How can I set a custom name to ...
0
votes
0answers
11 views

Set a numeric range for post ID generation based on post type?

I'm wondering if there's any way to configure WordPress to assign post IDs like so: Pages ID range: 10000 to 19999 Posts ID range: 20000 to 29999 Custom post type 'A' ID range: 30000 - 39999 Custom ...
0
votes
1answer
14 views

Why can't I connect to the wordpress install page with Nginx?

I'm a newbie of WordPress. My environment is Ubuntu 18 + Nginx + PHP 7. Following the tutorial(https://www.myfreax.com/how-to-install-wordpress-with-nginx-on-ubuntu-18-04/), the wordpress directory ...
0
votes
0answers
10 views

How to change $defaults in Genesis' genesis_register_widget_area? [closed]

I'm looking to edit the defaults in the following Genesis Framework widgetize.php code. Specifically I'm changing the before and after title html. function genesis_register_widget_area( $args ) { ...
0
votes
0answers
20 views

wp_update_post gives 500 internal error

i'm editing a wordpress plugin and im trying to call a function within the thank you page, and in that function it has wp_update_post function to change the status in the database, the function works ...
0
votes
1answer
20 views

Having trouble creating two shortcodes, one for logged in user and one for visitors

So I'm trying to create a code (in functions.php) that displays a widget content, from shortcode, based on whether the user is logged in or logged out (visitor). I am successful in displaying content ...
-1
votes
0answers
15 views

HOW TO FIX Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE), [closed]

Here's my code <?php $sql = "SELECT * FROM categories WHERE parent = 0"; $pquery = $db->query($sql); ?> <nav class="navbar navbar-default navbar-fixed-top" id="...
0
votes
0answers
14 views

How can I add state based on shipping charge without using zipcode/postalcode?

I have a woocommerce website in UAE.This want to show state select in billing and shipping when customer checkout page show shipping price. It means duabi- 20aed and abu dhabi 30. My current website ...
0
votes
0answers
11 views

Pages from admin dasboard missing after site migration

i migrated a site which was hosted on wp-engine to my local machine, after the migration in the admin dashboard i saw most of the pages are missing. on the wp-engine server, there are 59 pages, but ...
0
votes
1answer
15 views

Display all categories including sub categories under a list ul

This code is displaying only categories, how can I change to also include subcategories. Thanks Thanks, with this code is listing all together, I want that shows like this Category 1 ...
0
votes
2answers
23 views

How to replace file_get_contents() with a Wordpress Filesystem call

I'm using the PHP file_get_contents() function to retrieve and echo the contents of an SVG-file. <?php echo file_get_contents( get_stylesheet_directory_uri() . '/assets/images/Search_Glyph.svg' ); ?...
-1
votes
0answers
16 views

Can we use multiple message fields in wp_mail() function?

I have a code that is not working for wp_mail() . I tried to debug it but was not successful. Here is my full ode in PHP <?php /** * Template Name: Order Form Page * * @...
0
votes
1answer
18 views

Notify the user by e-mail after the creation of a post

I've a button, where the user create a post after click it. I want to notify him just after 10 min. I don't know the best way to do this with PHP. I know how to send the email, what I don't know is ...
0
votes
0answers
26 views

is_user_logged_in returns false when I access certain pages

I'm working on a single page application built with WordPress and Vue.js, I used add_rewrite_rule to redirect all sub-pages of projects/ to index.php. Only logged-in users can access the application. ...
0
votes
1answer
11 views

Woocommerce - get_items() returns empty array

I am trying to write a function that will allow me to add product meta tags as additional order notes. Unfortunately, nothing works. After a few hours I decided to bring the function to the simplest ...
0
votes
0answers
28 views

How to set img attributes directly on the database instead of on the fly

How to set the attributes with proper dimensions directly on the database instead of on the fly using a this filter Insert width & height attributes to all images displayed on each page My ...
0
votes
0answers
12 views

add_post_meta - datas remains stored in the database [closed]

I use Formidable Form plugin. I need to get last name and first name author from single page to display these datas in form with Formidable Form plugin. To display these datas in my form I can use the ...
0
votes
2answers
20 views

WP Hook Before a post is created

I want to create a new user when a post is created from the back end. Is there a WP Hook that calls before a post is created. Thanks
-1
votes
0answers
21 views

How to do a contact form plugin for wordpress [closed]

How to include my contactform files right in my php plugin code.
0
votes
0answers
12 views

Site cannot access external connection

my WordPress site cannot access external connection (e.g. cannot browse/update plugins using dashboard - manual zip install only). The site is can be access from the outside world (via domain name) ...
0
votes
0answers
18 views

Get posts that are parents which don't have any children with WP_Query

I have a hierarchical custom post type which has posts with no children and also posts that have one or multiple direct children (only up to a depth of 1, i.e no children of children). For example: ...
0
votes
1answer
16 views

Show data obtained from a function and place it in a shortocode function

I'm new I need to put a value obtained from a function and put it in my shortocode function if you can help me thanks $a=4; // value obtained from another function my_function($a); function ...
1
vote
0answers
21 views

Automatically create child pages and grandchild pages when saving a (parent) page

I have a bit of a tricky one... I have a hierarchical Custom Post Type ('shows') that represents events. Is it possible for the user to create a new page (ie show), save the page and for Wordpress to ...
0
votes
0answers
16 views

PHP Warning: A non-numeric value encountered in

I am currently getting the "PHP Warning: A non-numeric value encountered in" on two lines of a Wordpress plugin I am using... Here is the code from the plugin that is causing the issue ...
0
votes
0answers
14 views

MyListing + WCFM - Change path on click (redirect?) [closed]

Im attemptng to tweak MyListing and WCFM so they can play nicely together but im having some trouble. The main issue is that when a user has registered and created a listing it creates the url domain....
0
votes
0answers
16 views

Call WP Rest-Api to GET /users/me returned NOTHING in console

I am trying to get the login details of my wordpress account via WP Rest-Api with Cookies Auth in the logged-in wordpress condition. However, when I run it through a web browser I do not get anything ...
1
vote
1answer
20 views

How to implement Google Tag Manager?

Trying to use google tag manager. It requires code in the . I tried editing the theme for our website but its returning a white screen see the below code before I add Tag Manager echo '<body ...
0
votes
0answers
16 views

how can I restrict one (product category) so it can only be purchased with partial payment i.e mycred + PayPal [closed]

how can I restrict one (product category) so it can only be purchased with partial payment i.e mycred points + PayPal (70% points + 30% currency ), rest of the product categories can be paid by 100% ...
0
votes
1answer
17 views

Plugin use of ajax/jquery depending dropdown

i am looking for an example on which implements two depending dropdowns. There are a zillion examples on the internet but they are not working within wordpress plugin. So this is what if have In the ...
0
votes
0answers
12 views

WordPress Pagination Issue, displaying first page only

I have searched and can't find a solution that is working. I have this exact code on another site and it works. Not sure why it's not working here. All it's doing is ever showing the first page of ...
0
votes
1answer
12 views

How to pass a variable to get_template_part that's updated every time the template part is called?

I have a loop and in that loop I use a get_template_part to call the HTMl for the post to display. I also have a variable (number) to which +1 is added every time the loop runs. In this way I can ...
0
votes
0answers
12 views

How to add linked product to cart via AJAX in woocommerce? [closed]

I have eCommerce website. And I'm using this code example to add products to cart with ajax:https://stackoverflow.com/questions/33656739/woocommerce-ajax-add-to-cart-programmatically Everything is ...
1
vote
1answer
23 views

Replace word in “the_content” only for index.php

I have some posts with video tag that contains autoplay (they should autoplay when you access the post page). I am using the the_content to show these videos on index page. The problem is that when ...

1
2 3 4 5
179