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
2 views

WooCommerce get_price returning wrong price when used via ajax

I'm working on a site that uses the Events Tickets plugin, and I need to get the price of a ticket (Woo product) by ID. I'm using wc_get_product( $ticketID )->get_price(); to to do this. Adding the ...
0
votes
0answers
5 views

How can I adjust my function so the page editor still loads in the backend?

I have a live search function which fetches WooCommerce products in realtime. It works perfectly in the front end, however I notice there is a conflict which blocks my WordPress Editor plugin- Brizy ...
0
votes
0answers
8 views

How to set a parrent page to single-post

i have a custom post type called 'article', URL example: mysite/article/single-article And a have a page called all-posts how to set page all-posts as parent for the 'article' post type so the url ...
0
votes
0answers
19 views

How to solve undefined array key in php? [closed]

I am facing a problem in my try to create a JSON API for wp_users table. The error I am facing in register.php file is this: Warning: Undefined array key "user_login" in C:\xampp\htdocs\...
0
votes
0answers
12 views

How to display data from a google sheet in my Wordpress website

I have a google sheet, where there is a bunch of data stored, in multiple sheets. Now what I would like to do is, use that sheet, pull the data from it, query it and display it in my Wordpress site in ...
0
votes
0answers
13 views

Create plugin with custom page and template caused an error `Call to undefined function get_header()`

I've created a custom plugin that involves creating custom pages and each page should have its own custom template. These pages and templates are created programmatically. Every time I try to create a ...
0
votes
0answers
21 views

How to display posts that are store on a variable?

I have written some PHP code to read and display all the emails and those emails are stored in $emails. Now I want to display those emails as a post with a proper header and body. <?php $args = ...
0
votes
0answers
11 views

Reset filter on category archive in wordpress

I have a wordpress website with several posts divided in categories. On the frontpage I have links to the category archives which will go to url .../archives/specificcategory/. Let's name the ...
0
votes
0answers
19 views

Wordpress redirects to localhost

I have this wordpress website hosted on a subdomain, the url of the homepage is fine, but all other subpages are redirecting to "localhost/pageName", I already : • Updated the wp-config ...
0
votes
1answer
11 views

portfolio site - about this site section - is it safe to post some code

I am re-bulding my portfolio site using Underscores theme. I have an about page with the section "About this site". Since I plan to apply for web dev jobs in the near future, I think its a ...
0
votes
0answers
22 views

How to populate a Gutenberg select field SelectControl with option value from PHP array

For a gutenberg block, I need a select with a PHP array as options values. I'm not sure where to go. This array come from a CSV file To get array from this CSV i use this PHP code : /* Source File URL ...
0
votes
0answers
7 views

Woocommerce - Get Product's Child Category Name or ID [closed]

I am trying to get the child-category ID or Tag ID for products. The code below is able to get the parent ID only and not the child ID. I believe from the code below that '$order->get_items() '...
1
vote
1answer
19 views

can i fetch a custom metabox data in another page or post type?

I need to fitch a metabox field data in another page , $headabouttitle1 = get_post_meta(get_the_id(), 'head_title1', true); this is how i fetch it in the same page , I need to fitch it in another ...
0
votes
0answers
11 views

How to add custom plugin data to the cart in woocommerce using custom button on product page?

I am implementing the custom Buy Now button in my plugin. I had placed the Buy Now button on the product page using this hook add_action( 'woocommerce_after_add_to_cart_button', '...
0
votes
0answers
13 views

Pass a PHP function to javascript

I had a page view counter function in PHP that simply increments a single meta key value for each post upon visit. The problem I endured is that it doesn't work when the page is cached, of course. Is ...
0
votes
0answers
12 views

How do I edit the terms output args or array data?

This correctly prints the terms with images but the wrong order: <?php $terms = get_the_terms( $post->ID , 'wpsl_store_category' ); foreach ( $terms as $term ) { echo '<a href="'...
0
votes
1answer
9 views

Get the URL of the page from which an ajax request has been launched within ajax callback

I'm calling a server-side function written in PHP via wp-ajax. The server-side function eventually redirects to another page for an authentication step, and then redirects back to the initially shown ...
0
votes
1answer
33 views

How to send a php var to jQuery Ajax call with two different file

I need to send a private e-mail address from a php file (page.php) to an Ajax Call in an other jquery file (sender.js). This e-mail address must be invisible to user/or website until the user get an ...
0
votes
0answers
13 views

Gutenberg Blocks and get_option() for styling

I'm creating a Gutenberg block and I'm trying to customize a button's style (background color, text color, etc.) and it's inner text with hexcode set in an options menu. What's the best way to access ...
0
votes
0answers
24 views

WordPress jQuery Post - Amending Variable Value Within Function Command

I have a variable in Javascript which I am trying to pass to PHP. I have this working using jQuery.post. The issue is, the variable (linkforsharedURL) is declared within a multidimensional array and ...
0
votes
0answers
86 views

PHP Fatal error: Uncaught mysqli_sql_exception: Table doesn't exist in wordpress/wp-includes/wp-db.php

I am writing a plugin and want to create a database table when the user installs / activates it I have written the following into an install.php global $wpdb; $fm_db_version = '1.0.0'; $db_table_name ...
0
votes
0answers
32 views

Add a product category to a specific product via a button

I want to add a button to product page when those products are in the category"expire". This button has to add a category. I search on web a solution and I found a code. I modified this code ...
0
votes
1answer
30 views

Nested Queries of decreasing specificity

I have the goal of getting n custom posts from a query. I have 4 values stored in ACF. If I can find n posts where all these values are the same as the current post's, then I want to return those n. ...
0
votes
0answers
12 views

Filter to analyze WordPress template part with SEO Plugins (SEOPress example)

I have a question. I currently created my own theme and created some pages like the html of the homepage inside a template in the template-parts folder. Everything is fine, the theme runs, the pages ...
0
votes
0answers
17 views

How to Remove Theme Style CSS inside Custom Plugin?

I want to use bootstrap alert. I enqueue the bootstrap using this code: function wpbootstrap_enqueue_styles() { wp_enqueue_style( 'bootstrap', '//stackpath.bootstrapcdn.com/bootstrap/4.4.1/...
0
votes
0answers
17 views

Why is my custom post content only viewable when signed into Wordpress?

I've created a custom Post type called 'Data' to display content on a Wordpress site. The content works and is displayed if viewed when signed into Wordpress. Howevever, if you view the same URL when ...
0
votes
0answers
13 views

add_rewrite_rule to load different page, without changing URL in browser

I need a function(s) where I load to 1 specific page (index.php?p=49) whenever a URL is written with an all numeric slug/end. However, the written URL has to remain the same in the browser as it ...
0
votes
0answers
7 views

PHP ZipArchive not open in windows, but tcmd yes [closed]

i have this code, when upload file to form, after submit is file saving in ftp dir "doc/input_name/input_year/input_month/filename.zip" and create zip. But when i download .zip from FTP, and ...
0
votes
0answers
24 views

Wordpress can't use ZipArchive

Im currently developing a site where customers can download brand images like packshots. Ive made a custom cart where the client should be able to download all images added to the cart using ...
0
votes
0answers
25 views

How to setup the Email piping in WordPress plugin?

I am trying to Create a Ticket plugin that supports Email Piping but I am unable to set up the mail server through the plugin. If anyone knows how to set up the email server please help.
0
votes
0answers
23 views

remove values within an array user meta

hello I save the values as here: Add value to usermeta without removing previous values? $email_suscriptor = $_POST['cancelsus']; $dismissed = array_filter( explode( ',', (string) get_user_meta( $...
0
votes
0answers
24 views

get different meta-data of a complicated query at the same time

I have a function that generate a very complicated query with meta_query, tax_query etc. and now am using it in a filter page. i need to fill the filter page by some meta data, like number of paied, ...
0
votes
0answers
14 views

how to display recent post by category on home page

hi I m new in WordPress i want to display recent posts based on categories like this I found the following code but it seems not to work for me. here is the code function wpb_postsbycategory() { // ...
0
votes
0answers
23 views

Adding an Anchor Link to a wordpress menu using WPBakery Page Builder

I have a food ordering WordPress website that was built using WPBakery Page Builder. I read online on how I can add an anchor link that will take a user from the WordPress menu to a target section on ...
0
votes
0answers
13 views

Wrong pagination results, page counter resets when navigating

I have a custom loop that shows products according to a given criteria, e.g Products from a particular state, category or general product name search. This is in a page on my website. The problem is ...
1
vote
1answer
27 views

How to display Custom Post Type Post based on Tag with Shortcode Parameter?

I need to search in Custom Post Type 'Case Studies' based on tags which is specified in Shortcode Parameters like [casestudyhook tag="show-this-casestudy-onhome"] so image | title | link of ...
0
votes
0answers
15 views

count & sum the value of custom field of the author post in dynamic posts

I have seen some of the questions and answers here that similar to my case but I can't seem to understand where I should begin. What I have so far is the count each the authors post inside the loop. $...
0
votes
0answers
15 views

Date translation doesn't work

I would like to translate into French the month of the date I get with the function: get_the_date() I have done several searches and found several solutions but none of them worked so far. I have ...
1
vote
0answers
12 views

Ajax load more posts with multiple tax query

I am trying load my posts based on which tax query user is selecting in that moment. Currently it only works for my posts where it starts from offset = 0 and continue until has no more posts. The ...
0
votes
0answers
17 views

Providin exception to Wordpress wp_nav_menu Custom CSS Classes

I use below code to remove unusued menu classes. function clear_nav_menu_item_class($var) { return is_array($var) ? array_intersect($var, array('menu-item-has-children')) : ''; } add_filter( '...
0
votes
0answers
27 views

Wordpress SQL Prepare

i'm trying to adapt this code to also take in to account specific categories and custom post types, so it would give me select dropdown populated with unique custom field values, from a specific post ...
0
votes
0answers
15 views

How can I update WordPress plugins or WordPress itself in all server?

I have 3 application server on AWS. if I update WordPress or plugins in one server it will update in the rest of the servers too. How can i do that??
0
votes
0answers
12 views

Variation prices breakdown only for single product page

Hey I'm trying to display breakdown of selected variation price but only on product single page. I dont want to overwite the price but just to show it after the add-to-cat and buy now buttons.For ex ...
0
votes
1answer
28 views

Unexpected add action function in WP plugin

I'm trying to build out a plugin from a tutorial that will access my google calendar. So far I'm stuck on just trying to register the widget. Here is a link to the tutorial: https://code.tutsplus....
-1
votes
0answers
16 views

Localhost downloading zip file instead of installing

I want to work on a school management system. I am currently using Wamp server. After all correct procedure of creating the DB, my localhost downloads a zip file instead of going through the process ...
0
votes
0answers
21 views

Is it secure to use SMTP password in .php file in WordPress website?

Currently I am making feedback contact form without a plugin. Trying not to use plugins if possible. In action .php file there must be written server settings such as SMTP server, SMTP username etc. ...
0
votes
0answers
8 views

WooCommerce Query Product Titles

I am able to query and display a list of post titles using in AJAX, which works perfectly. However when I try to change to query product titles (WooCommerce) it does not work. How can I adjust my code ...
0
votes
0answers
5 views

implement custom roles in custom plugin

i am developing an Wordpress plugin which actually works quitte good ;-) But i have a requirement to implement user roles. So i am reading stuff about custom capabilities in wordpress. There is so ...
0
votes
0answers
9 views

Send an e-mail on address with the link with disliked post

I have an issue with sending an e-mail on address with the link with disliked post. So, when a guest click on "Dislike" button, link of the post must be submitted to a given e-mail address. ...
0
votes
0answers
6 views

PHPS source file - 403 Forbidden You don't have permission to access this resource [migrated]

Hi I am trying to view a .PHPS source file on Ubuntu 20.04.3 Apache 2.4.41 PHP 7 server but when I view the .phps file in the browser I get this message - 403 Forbidden You don't have permission to ...

1
2 3 4 5
197