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

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
7 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
19 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
8 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
28 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
24 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
28 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
15 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
14 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
12 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
23 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
23 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
20 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
24 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 ...
0
votes
0answers
7 views

How to add active class for current item and ancestor in new WooCommerce Product Categories List Block widget? [closed]

I am using a Product Categories List Block to list all product categories in sidebar in shop and category pages (like filters). I am listing categories in my site by using a wordpress Widget. ...
-1
votes
1answer
10 views

Undefined Variable on Responsive Announcments [closed]

I was looking for help as I have a "Undefined Variable" on line 168. Any help would be greatly appreciated. <?php /* Plugin Name: Responsive News & Announcements Plugin URI: http://...
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
26 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
14 views

Disabling a custom function on a specific cart item [closed]

We use Woocommerce Subscriptions and offer a 10% incentive for signing up - if we're running a sitewide sale (via Woo Discount Rules), we want the subscription price to only reduce the full product ...
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
11 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 ...
0
votes
1answer
20 views

Please help! I have a problem with getting wordpress databas

The file path is: wordpress/​wp-content/​themes/​neve/​index.php "index.php" content is: <?php global $wpdb; $result = $wpdb->get_results ( "SELECT * FROM users WHERE username = '...
0
votes
0answers
18 views

Unable to display multiple parameters from url by javascript through shortcodes

From our CRM I can generate URL's for customers that includes parameters. I want to use the information stored in this parameters to show dynamic content to the customers. Example: www.example.com/...
0
votes
0answers
11 views

In PHP how do I make my navigation bar show certain links to admins only?

My admin panel on my nav bar only shows to accounts with the username 'admin' as the moment, I would like it to search my USERS database and only show the link to userswith a user_level of 1. My DB ...
0
votes
0answers
18 views

List sub categories and corresponding posts of a parent category

I'm looking to list my subcategories and related posts under a parent category page. For reference, I have 3 parent categories: Baby, Toddler and Preschool. The 'baby' category page WORKS with the ...
0
votes
0answers
27 views

Removing "There is no account with that username or email address." error message in "/wp-login.php?action=lostpassword"

Would like to find out if there is any way I could customize the wp_login page to remove the "There is no account with that username or email address." validation (show below) and any email/...
0
votes
0answers
19 views

Give ID to divs inside the loop

I'm trying to make this code work on my WordPress site: https://codepen.io/eksch/pen/xwdOeK It is a simple code so that each menu item receives the active class when the user scrolls through the page, ...
0
votes
0answers
26 views

Change wordpress' database data using ajax - how to get current user id?

I want to update a wordpress' database using ajax. I've created php file and included both wp-includes/user.php' wp-includes/pluggable.php' and when I call $current_user = wp_get_current_user(); $...
1
vote
0answers
7 views

$wpdb->update with multiple parameters gives error

can this be simplified into one query using $wpdb->update? global $wpdb; $wpdb->update( $wpdb->users, array('user_login' => $new_user_email), array('ID' => $user_id) ); //...
0
votes
0answers
12 views

Woocommerce My acount page

I writen template for woocommerce. I have 2 languages polish and englisch. I would like to set the link for language polish "localhost/domain/moje-konto/" and for language englisch "...
0
votes
1answer
11 views

Rewrite with pagination /foo/page/2/ to posts of a given category, page 2

This add_action('init', function() { add_rewrite_rule('^foo', 'index.php?category_name=category1', 'top'); }); works and allows example.com/foo/ to display all the posts from category1. But then ...
0
votes
1answer
30 views

Add css class to string

I'm trying to add css classes, so that each status (active, pending, canceled) has its own css class on the frontend. Please help. function rcp_get_status_label( $status = '' ) { static $labels = ...

1
2 3 4 5
196