Questions tagged [wordpress]
WordPress is a free and open source blogging tool and a content-management system (CMS) based on PHP and MySQL.
140 questions
2
votes
0
answers
33
views
Plugin to enforce individual-use coupon validation in WooCommerce admin
I'm working on a custom WordPress plugin that ensures individual-use WooCommerce coupons are properly validated when applied via the admin order editor.
By default, WooCommerce only enforces this ...
3
votes
1
answer
70
views
Wordpress custom registration form with additional fields
I work on plugin for custom auth pages for WordPress and I try to create a custom registration form with additional fields. it has a shortcode in Beaver Builder. Is this the correct approach, and ...
2
votes
0
answers
133
views
Add a Custom Billing Field to WooCommerce Checkout, Order Meta, and User Meta
I have implemented a custom WooCommerce checkout field to collect a Tax Exempt Number in the billing section. This field's value is stored in the user meta upon checkout to facilitate future orders.
...
1
vote
2
answers
252
views
PHP WordPress Code - Pricelist Template
I've been working on a WordPress pricing page template and would appreciate feedback on the code structure, organization, and any potential improvements. The template is used to display a pricing list ...
0
votes
1
answer
322
views
WordPress Plugin for WebP/AVIF Image Conversion
I'm looking for feedback on a WordPress plugin I developed for automatically converting images to WebP and AVIF formats. The goal is to optimize image loading performance.
The plugin has the following ...
2
votes
1
answer
267
views
Display WordPress Custom Post Types with ACF-Fields on a Google map
I am currently working on my first WordPress plugin. I display custom post types on a google map with pins. The custom post types also have additional information by ACF fields which are displayed in ...
0
votes
2
answers
634
views
Configuring SQLite3 for best efficiency as a persistent cache
I'm using SQLite3, via php's extension module, to create a persistent object cache for WordPress. It's intended for use on modestly sized sites that don't have access to redis or memcached. Why use ...
1
vote
2
answers
155
views
PHP function that checks if user should have access based on button click and yearly quarter
I have a function that has a few and/or operators in it. I'm sure there is a better way to write this but can't seem to figure it out. I thought I could use arrays but ran into an issue with having ...
1
vote
1
answer
291
views
Default to array when value is null or false
I'm working with ACF in WP which provides a get_field() function. The function can return an array of values, null or false. ...
0
votes
2
answers
153
views
Search between dates in a WP Query
In the posts I have a date field and a start and end date range. I need to query if it matches date or if it matches between the dates in the range. This Query works, but how can I optimize?
...
4
votes
2
answers
222
views
Modify a WordPress loop to show posts of certain categories, based on user roles
I've got some code that works as intended, but I have a feeling that it's messy. This code is modifying a wordpress loop and the goal is to check the roles of the current user and show posts of ...
2
votes
2
answers
239
views
Optimize PHP code for Wordpress shortcode (Star-Rating)
I am using WP with the Avada theme and the built in Star Rating element as well as ACF Pro.
Unfortunately I found out that the Star-Rating element adds a rating scheme to the footer of the website ...
3
votes
2
answers
140
views
Custom Block with ACF in WordPress
I'm learning and want to improve as much as possible. In doing so I have written this custom block that has an image on one side and an inner block on the other. It's using ACF to get the variables ...
1
vote
1
answer
74
views
Instantiating classes in WordPress plugin
the last couple of weeks i have been working on my own WordPress plugin. I am trying to do a class based codebase.
My plugin works correctly, but i don't really know if this is the correct way to ...
2
votes
0
answers
48
views
Added custom woocommerce product page hook
I inserted this code snippet in the functions.php of my child theme, to create the woocommerce single product page in the hook woocommerce_after_single_variation of the custom icons in line centered ...
1
vote
1
answer
85
views
Building a pre-loader for performance gains in Wordpress
As the title states, I am building a pre-loader for Wordpress running on PHP 7.3.5+ that will deliver performance boosts in loading, as well as metrics such as Google Page Speed.
This is something ...
3
votes
4
answers
237
views
Order a table by column and get row number
In my database, I have table wp_postmeta, example:
...
0
votes
2
answers
151
views
Woocommerce order change status
This code can woocommerce order change status. But as you can see, this code is hard to read. How can I make it cleaner?
...
0
votes
2
answers
108
views
Optimizing large WP Query [closed]
I have WP Query like this:
...
2
votes
0
answers
56
views
Copy the reply button to each comment thread in WordPress. Converted from jQuery to JavaScript
I converted an old Wordpress Plugin of mine from jQuery to plain JavaScript using a cheat sheet. I was very surprised that it seems to work right out of the box on my first try.
...
3
votes
1
answer
77
views
Query WordPress database, returning an array of rows
This is one of my first attempts at querying the WordPress database for data, and some my first PHP code ever, so please bear that in mind when commenting.
It is supposed find data between two dates, ...
4
votes
1
answer
119
views
Adding CSS to each page on WordPress
I just started to use WordPress to start building a website, but as I need to use the get_header() function to retrieve the ...
2
votes
0
answers
35
views
wordpress slow query shown in query monitor
I have a slow query on a wordpress site. How can I rewrite this to make it faster? I'm not having much luck. The query takes about 0.900 seconds I have both the query and the explain below, my goal is ...
3
votes
2
answers
174
views
Wordpress Ajax Custom Query - High CPU LOAD
I'm developing a fully AJAX community WP theme that comes with a lot of custom queries.
Everything is fine, there is no bug but recently but I had a few clients that have a huge database and my theme ...
1
vote
2
answers
445
views
Dynamic Accordion in WordPress
I used the Bootstrap v4.0.0 accordion to display my business services. Further, I created a custom post type "service" for my services (Each service is a post).
To display my services ...
4
votes
1
answer
147
views
Efficiently use array values and variables in a WordPress template
Is it better to validate and put an array value into a variable at the top of a file or to check the array value directly right before output in the file?
I work at a WordPress shop and we have a ...
5
votes
1
answer
146
views
Wordpress single post content class customization with if-else function
I have the following code, which displays the content for my custom page template "landingpage.php" and for single posts. The site uses Bootstrap 4.
...
1
vote
2
answers
205
views
Shorten and optimize php custom code for wordpress page template and use shortcodes
I'm pretty new to php coding, but i know wordpress for a long time. Also experimenting with bootstrap. I created a new Page Template and modified it a bit. What I'm looking for is to optimize this php ...
2
votes
2
answers
100
views
Function for iterating out an unordered list of custom taxonomy terms
I've created a function that generates an <ul> of my wordpress custom taxonomy terms, displaying ...
2
votes
1
answer
88
views
Display content if form field is filled - Do not display if field is empty
I am using the following code within the footer of my test site. I am using WordPress and Advanced Custom Fields
The intention is:
To display the HTML container ...
3
votes
1
answer
89
views
Performance of WordPress Plugin is currently very bad and needs to be improved
I have written the following Plugin, which adds fields to the Media/Attachment Entries and returns all information in one Shortcode. This solution works, however, is pretty slow the more entries ...
4
votes
1
answer
51
views
Simple Bespoke WordPress Integration Plugin
I am in the process of setting up WordPress with WooCommerce, one of the requirements is a bit of integration that takes a person from another website directly to a specific product. I have set the ...
2
votes
1
answer
699
views
Replace anchor tags and force create new tag with custom attributes
I'm just use the add_filter('the_content', function($content){}); for filtering anchor tags in a post.
Basically, I want filter anchor tags to appropriate format. ...
1
vote
1
answer
73
views
Improved the output of the related posts in WordPress
I made a simple code to improve the results for WordPress related posts area and it works fine , but because my experience in coding is low , my code is very long and i believe that there is a way to ...
3
votes
1
answer
86
views
WP/PHP getting API data and using hook
Below are the two things I'm trying to solve, logically. This is just a proof of concept; and I'm not implementing this on real data nor via full plugin at this time. Just looking at logic and syntax ...
3
votes
0
answers
520
views
Product Filters wordpress plugin: implement single responsibility principle for elements classes
Plugin is a small editor that allows to create a filter such as a price slider, checkboxes of "brands", a drop-down of "seasons".
An example of how plugin work can be seen on page: http://demo-...
2
votes
1
answer
746
views
Prefixing prices of certain product categories with text in Woocommerce
I had the need to prefix the price for certain product categories on only the shop page (because the price can be higher depending on extras that the customer might want).
These were my requirements ...
3
votes
1
answer
78
views
Filtering wordpress comments by votes
I have a website that, based on a user's comments, filters comments by "most liked first, most disliked first" etc...
I have a custom table for comments scoring system and system working with +1 and -...
2
votes
0
answers
169
views
WordPress rest api basic auth with IP check
I'd like to use basic auth with the WordPress API, but restrict the capability to a single IP address. I've updated the existing code from here: https://github.com/WP-API/Basic-Auth accordingly.
It ...
1
vote
2
answers
787
views
PHP subscription workflow
I've creating a working subscription workflow for my webpage, which heavily utilizes a set of functions I've created for this purpose.
However, after doing some testing (functionality works fine), I'...
1
vote
1
answer
84
views
Feeding PHP variables to a number of HTML elements
The following code works fine, however, I'm trying to simplify it. I wrote it but I'm a beginner PHP coder. I can see that most probably the use of a function or class would be better... or anything ...
2
votes
0
answers
313
views
Generating two Woocommerce Order CSV files based off url query
I wrote this code about one year ago. I'm looking to refactor it to be solid SOLID and secure, as this is being generated off a custom endpoint. The script is to read parameters from a query and ...
1
vote
1
answer
167
views
Checking if a shipping method exists
I am trying to create a custom WordPress/WooCommerce function in PHP. I am a newbie and would really appreciate some feedback on my code and how to improve the code! Right now it feels like there is a ...
2
votes
0
answers
40
views
Create a new WordPress admin page, and add an admin table to it
I completed this WordPress coding task as part of an interview. I'm hoping someone can review my work and comment on everything, especially my general approach to the task, and the sanitization of ...
3
votes
3
answers
335
views
Check if a postcode is in a list
I'm looking for improvement / advice / reviews on how I can improve this code. I feel like there is a better way or more efficient way of doing this and I am over looking it.
The Plugin I made is ...
2
votes
0
answers
52
views
WordPress plugin for shipping calculation
I am writing a WordPress plugin that allows shipping calculation on the product page. Originally, shipping calculation is only available in the cart.
To calculate shipping costs on product page, ...
0
votes
1
answer
214
views
Formatting fractions found in a given string to html fraction
I'm working on a site running woocommerce and wp where the user will add/has added a dimension attribute.
The dimension string will take the following format originally:
Ht: 30 1⁄2" W: 22 1⁄2" D: ...
4
votes
1
answer
696
views
JavaScript responsive menu (dropdown/dropup)
I have the following front-end code for a responsive navigation menu which I thought using in my WordPress website.
Clicking the .burger element should cause ...
3
votes
1
answer
167
views
Conditionally displaying a notice about free shipping in Woocommerce
I wrote PHP code to display a Woocommerce notice - "free shipping for $40 & under" only once on shop page and once on cart page, but also in cart should not be more than 40$. The code works, but ...
1
vote
2
answers
83
views
chmod all .htaccess files under all website dirs under public_html dir
This is my code to chmod all .htaccess files under all website dirs under public_html dir.
The reason I use this code is to make sure WordPress plugins won't "...