Questions tagged [wordpress]

WordPress is a free and open source blogging tool and a content-management system (CMS) based on PHP and MySQL.

Filter by
Sorted by
Tagged with
1 vote
0 answers
45 views

Force free shipping for WooCommerce Subscription recurring orders only

I'm using WooCommerce Subscriptions and here's what I want to do: Use free shipping for all recurring orders even if the minimum isn’t met. Get rid of any other free shipping choices (like free ...
David's user avatar
  • 11
0 votes
1 answer
170 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 ...
KermitTheFrog's user avatar
2 votes
1 answer
138 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 ...
Markus's user avatar
  • 21
0 votes
2 answers
280 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 ...
O. Jones's user avatar
  • 299
1 vote
2 answers
92 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 ...
protagonist's user avatar
0 votes
1 answer
163 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. ...
mrmadhat's user avatar
  • 148
0 votes
2 answers
105 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? ...
cRiSs rOcCa's user avatar
4 votes
2 answers
178 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 ...
JLW's user avatar
  • 43
2 votes
2 answers
178 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 ...
Torsten's user avatar
  • 21
3 votes
2 answers
101 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 ...
Andrew Fair's user avatar
1 vote
1 answer
46 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 ...
RowanBlub's user avatar
2 votes
0 answers
32 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 ...
db151's user avatar
  • 21
1 vote
1 answer
59 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 ...
Bagseye's user avatar
  • 401
3 votes
4 answers
150 views

Order a table by column and get row number

In my database, I have table wp_postmeta, example: ...
Henrik Petterson's user avatar
-1 votes
2 answers
104 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? ...
codescaptain's user avatar
0 votes
2 answers
72 views

Optimizing large WP Query [closed]

I have WP Query like this: ...
Olsz4k's user avatar
  • 3
2 votes
0 answers
43 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. ...
Marc's user avatar
  • 121
3 votes
1 answer
51 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, ...
ddk's user avatar
  • 31
3 votes
1 answer
72 views

I need a better way to add css per 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 ...
maneroto's user avatar
2 votes
0 answers
25 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 ...
JLT's user avatar
  • 21
3 votes
2 answers
127 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 ...
techn9ne's user avatar
1 vote
2 answers
368 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 ...
dicomp's user avatar
  • 41
4 votes
1 answer
105 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 ...
thenomadicmann's user avatar
5 votes
1 answer
117 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. ...
Sniffles's user avatar
1 vote
2 answers
109 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 ...
Sniffles's user avatar
2 votes
2 answers
65 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 ...
James's user avatar
  • 195
2 votes
1 answer
62 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 ...
Bagseye's user avatar
  • 401
3 votes
1 answer
48 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 ...
Max Hartwig's user avatar
4 votes
1 answer
31 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 ...
Eval Knievel's user avatar
2 votes
1 answer
533 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. ...
Engkus Kusnadi's user avatar
1 vote
1 answer
45 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 ...
sammax's user avatar
  • 43
3 votes
1 answer
60 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 ...
Lieutenant Dan's user avatar
3 votes
0 answers
504 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-...
Alex Vasilyev's user avatar
2 votes
1 answer
680 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 ...
rpm192's user avatar
  • 153
3 votes
1 answer
55 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 -...
techn9ne's user avatar
2 votes
0 answers
154 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 ...
nzt's user avatar
  • 121
1 vote
2 answers
719 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'...
ok34332's user avatar
  • 11
1 vote
1 answer
74 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 ...
Wasteland's user avatar
  • 547
1 vote
0 answers
653 views

Load more and filtering - WordPress AJAX

In my WordPress theme I have built a function that uses Isotope Layout by Metafizzy to accomplish filtering and sorting. I have used a mix of AJAX and JQuery to accomplish this, however I feel the ...
Jesse Orange's user avatar
2 votes
0 answers
283 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 ...
Dan's user avatar
  • 183
2 votes
1 answer
128 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 ...
TobiasM's user avatar
  • 123
2 votes
0 answers
30 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 ...
cag8f's user avatar
  • 121
3 votes
3 answers
257 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 ...
Second2None's user avatar
2 votes
0 answers
41 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, ...
Lucas Bustamante's user avatar
0 votes
1 answer
175 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: ...
mrmadhat's user avatar
  • 148
5 votes
1 answer
645 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 ...
user avatar
3 votes
1 answer
134 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 ...
Dima Vizelka's user avatar
1 vote
2 answers
62 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 "...
Arcticooling's user avatar
2 votes
0 answers
48 views

Creating an object handler that loads objects in an array in PHP

I am creating tooltips that I will use throughout my site. Each individual tooltip is created as an object, all of these tooltips need to be ingested with these rules: I should be able to hold an ...
Josh Collins's user avatar
1 vote
1 answer
48 views

Nginx-WordPress conf

This is how I create am Nginx virtual host for a WordPress webapp. I did best to keep it as minimal as I can while having a working webapp. Please review it: ...
Arcticooling's user avatar