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

developing a wordpress plugin, have a few PHP Woocommerce related coding questions

Background: I hired a programmer to create a schema markup plugin for me, the job was done but a few things have left that need to be added. We added a separate code where it adds fields such as "...
0
votes
1answer
12 views

Should I set a page as “No-index” if I include it's content within the front-Page.php via this method?

So I set my home page to "Your latest posts", and included this bit of code to get the info from a pre-defined page so that I can edit my home page, and get access to a "recent posts" grid with ...
0
votes
0answers
9 views

CMB2 toolkit: Compare 2 Dates and validate the Time

Hello i am using the CMB2-toolkit for Wordpress: https://github.com/CMB2/CMB2/wiki/Field-Types I have a Problem where i have 2 Datetimes, where one is the Starting-Time and the other is the Ending ...
0
votes
1answer
12 views

Have CSS Class Added with `is_page()` WP function

I have a nav <li> item where I add a page_active CSS class when a submenu page is visited. This works all OK when one of the pages is visited, but I can't get it to add the class when the second ...
0
votes
0answers
5 views

Undefined offset in media.php

Recently debug.log (WP 5.3.2) grew to 17GB because of tons of entries like this: [17-Jan-2020 16:29:01 UTC] PHP Notice: Undefined offset: 1 in /wp-includes/media.php on line 790 [17-Jan-2020 ...
0
votes
1answer
17 views

Trying to get pagination working on WP_Query() post grid

So I've been developing my own theme as a learning experience, and I'm at a loss regarding how to get pagination working. I've tried several things before getting to this point and asking, I just seem ...
0
votes
2answers
21 views

write custom woocommerce templates and forms

I've started to customize the woocommerce default templates by using the hooks as is suggested on the documentations. I have two question about this aspect, I want to understand if I can write my ...
0
votes
0answers
26 views

How to extract alt attached image in a shorter way?

I am currently extracting the post attachment image (note: NOT the featured image, but a simple attachment img) this way: (functions.php file) function haruki($post_id) { global $post; $...
0
votes
0answers
17 views

Word press and PHP error caused these errors [duplicate]

Warning: Declaration of Thesis_Comment::start_lvl(&$output, $depth, $args) should be compatible with Walker::start_lvl(&$output, $depth = 0, $args = Array) in /data/25/0/30/26/30678/user/...
0
votes
0answers
19 views

Issue updating categories

When post is saved (not real time toggling). The list of locations category isn't displayed correctly function assign_parent_terms($post_id, $post) { $temp_taxonomies = get_post_taxonomies($post);...
0
votes
1answer
27 views

WooCommerce pages looks unstyled

I'm playing with woocommerce to customize the store aspect. I've noticed that If I open a product link, the page looks unstyled. I need to integrate the shop with my bootstrap 4 based theme. After ...
0
votes
1answer
10 views

Get x numbers of a woocommerce category products using Wp_Query

Is possible to show some woocommerce products inside a swiper slider? I want to create a slider that will show some "featured" products on the home page. For now I have a cpt that is achieving this, ...
2
votes
2answers
103 views

Wordpress-site can be reached on x.x.x.x/index.php - but not directly on the IP without index.php

Brand new WordPress install with Avade Theme installed on RPi 4 - works fine when I access it on http://203.0.113.111/index.php from an external connection, but if I remove the index.php I get nothing ...
1
vote
1answer
19 views

How to pick the default selected value in wordpress dropdown?

First of I am pretty new to this so sorry if this has been asked before but I could not find the right answer for me. I have this dropdown on my website from compare-tech(.)fr I am trying to remove ...
0
votes
1answer
12 views

alternate left - right content inside the loop

I'm not sure if this were asked before. I want to obtain a similar effect where the contents and the images are alternated for each post, one time the image is on the left and the text on the right ...
0
votes
1answer
14 views

Download Featured Image Link in Post Shortcode

I came across this post which nearly does exactly what I need. But I am using a page builder and inserting into the template produces undesirable results. I have been trying to get this snippet into ...
0
votes
0answers
14 views

How does Permalink work with the AMP plugin after Removing Parent Permalink Catalog from Posts

I have found some solutions, but they are not perfect with the AMP plugin. For example, I found that this code is completely true for posts that are not amp, but when viewed by url with amp, it ...
0
votes
0answers
10 views

Why is one phpunit test throwing an error on one class when all other classes are similar without error?

I'm working on the Liquid Messages plugin. There are some basic PHPUnit tests existing for it and when I run phpunit all pass except for one. It errors out: There was 1 error: 1) GCS_Async_Test::...
0
votes
1answer
17 views

Accessing post's meta data based on user's click of a post

I am displaying a gallery of custom post types. When the user clicks a post, instead of redirecting to a single template, I want it to redirect to another page (too easy just change the link since all ...
0
votes
2answers
17 views

customize woocommerce templates and display store on home

I'm making some changes to a custom template for a website that wants to add the woocommerce support to create a little shop. I've followed the instruction to add the theme support to the theme, in ...
0
votes
1answer
23 views

Wordpress Stock Update Programatically

I'm trying to develop a plugin that would update the stock quantity of products to 0 (Out of stock) that are older than X days. The logic that I'm using is: Select products who's modofied date is ...
0
votes
1answer
12 views

Using id to show item

Im working on a project where i upload a gpx file and use the path of gpx to put in a shortcode plugin i use the post id the get a filled in shortcode i use this code to get me the piece of info for ...
0
votes
1answer
21 views

How to override theme's public static function inside of a trait?

I use a theme which has a public static function to display a part of a page like: trait SomeTrait { public static function some_function() { ?> <div class="some_class">Some ...
0
votes
1answer
27 views

List taxonomy term slugs within shortcode (do_shortcode)

I'd like to list the taxonomy terms within my shortcode. This is how I get the list of terms (separated by commas): <?php $terms = get_the_terms( $post->ID , array( 'shoptype' ) ); ...
0
votes
1answer
9 views

Add content after the first post in WP Loop

I want to display a list of categories after the first post in the Loop of index.php (this is the template my WP theme uses to display posts). I've searched around on the web and found some code (see ...
0
votes
0answers
19 views

Apply discount to woocommerce booking total

I'm trying to find a solution to add a discount to the total price on the booking window. The WooCommerce Bookings changes the values with jQuery and I tried these hooks with no luck. WooCommerce Add-...
0
votes
0answers
9 views

pass datetime using wp_localize_script to frontend from settings page

Is possible to use the wp_localize_script fom the front-end? I'vecreated a JS countdown timer that will take an input data from a settings page fom backend. The script that will display the countdown ...
0
votes
0answers
14 views

Add extra cost to shipping method itself in woocommerce

I found the following code from this link: https://stackoverflow.com/questions/52138784/add-a-fee-based-on-shipping-method-and-payment-method-in-woocommerce The code works great if you want to add ...
0
votes
1answer
24 views

Add value to new attribute inside Wordpress menu <li> items

I have this code in my functions.php to add new attribute data-content="" to all my <li> items in the wordpress menu. The value of each data-content has to be different: I would like that each ...
0
votes
0answers
16 views

Minimum purchase amount sorted by categories (Problem: Variation Products)

I have a Problem with a custom code. I want to display an error message if the order amount is smaller than € 15. But i also want to exclude specific product categories from that minimum amount. It ...
0
votes
0answers
12 views

register_setting not save checkbox

To understand the Settings API I'm creating a custom settings page for a custom plugin. I have some trouble to save the settings, I have a single checkbox to test if the code works well, but if I ...
0
votes
0answers
21 views

How can I build my own job posting plugin?

I'm looking for a way to create my own job posting plugin where someone can add, remove or edit jobs on the back-end of a Wordpress-website. I also need the ability to store the entries somewhere in ...
0
votes
1answer
19 views

Custom array from a query only write the last row of the query

Looking for some input on this one. I am writing a custom array but having a strange issue. It seems to be cycling through the loop and dropping previous values and only storing the last row of the ...
0
votes
1answer
21 views

Advanced Custom Forms PHP formatting for do_shortcode

Hi i am trying to build a simple wordpress template template and want to introduce a pdf viewer into the page that pull's it file from an ACF field I am pulling my hair out with the syntax on the ...
0
votes
0answers
10 views

Integrate options to maintenance screen plugin

I have a simple custom plugin to show a maintenance screen to non admin users. I want to integrate some options to it like a countdown and a selectable background image or color and a custom logo. I ...
0
votes
1answer
28 views

Infinite loop when logging out using custom login form

I have a child theme that I'm using based on a parent theme I created. The parent theme uses the standard wp_login_form while this child theme uses a username only option (the site itself is local - ...
0
votes
0answers
23 views

WooCommerce without checkout shortcode

I'm coming from laravel(cool php framework) origin. I understand wordpress flow to some extend. What do I mean? Like in the page that output product detail, I use $product = wc_get_product(); $...
0
votes
1answer
23 views

I have a lot of JavaScript erorrs after SSL someone can help me?

I have a lot of JavaScript errors after SSL. Can someone help me? (https://validator.w3.org/nu/?doc=https%3A%2F%2Ffashionbymichal.com%2Fhe%2F) Also in the console: https://prnt.sc/qmnnzh
0
votes
1answer
25 views

how to remove colon and white space in a string by php

How can to remove colon's and white space's in a string by php. .e.g: The Godfather: Part II
0
votes
2answers
33 views

Why is my form going to frontend on html form submission present on the php files inside my custom plugin?

I'm creating my first Wordpress plugin. It's goal is to update information from admin user about the book stock using sku only. There are 2 forms in update-stock.php page. First form takes sku input ...
0
votes
1answer
17 views

Do I always need to call wp_get_current_user() before accessing $current_user?

I'm writing a simple plugin that runs when a user logs in and logs out. (I'm a PHP n00b and this is purely educational) It references $current_user (defined as global in the function). And it all ...
0
votes
0answers
14 views

create custom page builder

I want to create a custom and simple page builder as an exercise to improve my wordpress coding skills. I want to integrate bootstrap 4 inside it, and as tutorial I was reading this article. It's very ...
0
votes
1answer
19 views

How to declare a variable at the bottom of the page and use its value at the top?

It maybe easy to do but I am new to php. I really need to know how to solve it. $first = $second; $second = 4; I need to pass the value of $second to $first dynamically whenever it changes. please ...
0
votes
1answer
17 views

add custom metabox to media library custom widget

I'm implementing a custom widget to create a logos slider. The initial code works well, but when I have added a metabox to the attachment screen to let the user add an external link to the images, I ...
0
votes
2answers
25 views

using filter and hook inside class

I'm going deep with oop to create wordpress plugins. I've found an interesting article about the hooks and how to use them inside a class. After reading I have some doubt: is correct to use the hooks ...
0
votes
2answers
14 views

How to add locations input to user profile?

I want to display user's locations which they travelled on author box so how can I add this kind of input area to users profile? To more explain, If a user add "Londra,Paris" to own profile, these ...
0
votes
0answers
9 views

Fetch debug information from WPML in $.ajax results in 403 forbidden

I am trying to fetch debug information from a piece of javascript, to make it easier to copy the debug information code (if find my self often doing this). However, when I send a request to a page, ...
0
votes
1answer
11 views

Get original value in save_post action hooka

I'd like to get the original value of the $post on the save_post action. This way I can detect changes, and only do specific actions if the post content/title was changed. Is this possible?
-1
votes
0answers
11 views

How to Receive and Process Paypal IPN on a WordPress Page

I have created a WordPress Page template(listener.php) and then created a WP page using that template.The Page url is like: mysite.com/thank-you. Here is the code i have place in the template(listener....
0
votes
0answers
14 views

why not selecting multiple rows of same standard_id using SQL query from database?

i have invested much more time in simple query ,i was trying to select different rows of same standard_id and in my database is two such rows which have same standard_id but from them i only getting ...