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
12
votes
2answers
368 views

First attempt - Wordpress PHP Settings API wrapper

I've been working on what is essentially my first proper attempt at making a useful PHP wrapper class for the Wordpress Settings API. It works great so far and I plan to add more methods as I go so ...
10
votes
1answer
98 views

Automating a WordPress install

I do not have a whole lot to do over winter break, so I wrote this little script to automate a Wordpress install (currently can only install once instance) on a fresh Debian server (tested, working ...
7
votes
2answers
119 views

Recursive download articles and dump to MongoDB

This is simple code that recursively downloads articles from the public WordPress API: ...
6
votes
3answers
6k views

Listing WordPress posts with thumbnail images

I am using the following code poor form. I am interested in how I can optimise this and use the correct methods. I understand the DRY concept and will look to employ that throughout my code. However, ...
6
votes
3answers
879 views

Check efficiency of PHP code that will query over 8500 orders

I am querying all orders from a WordPress database that uses the WooCommerce Bookings plugin. I want to display upcoming bookings, and there is a potential to have every hour within 2015 to be booked; ...
6
votes
3answers
423 views

Evaluate a Contact Form CSS

I am a total novice to web development, but I am trying to be a WordPress developer and have been actively at it for some weeks now. All self-taught with the world's best tool as my aid: the internet. ...
6
votes
3answers
258 views

First Wordpress plugin for saving a post

This is my first Wordpress plugin. I would love some input from the WP/PHP/JavaScript gurus out there. It's a simple plugin that saves a post using ctrl-Q and opens a preview in a new or current ...
6
votes
2answers
2k views

Trim string of words based on character count

I needed a simple way to trim a string of words based on a max character count. I also needed to cut in-between words. Using WordPress, here is what I came up with, but I feel like it could be more ...
6
votes
2answers
1k views

Checking for existence of URL parameters

I'm busy rewriting some from my spaghetti code into OOP classes. I'm still learning OOP and very new to the concept. From help from this answer from @EliasVanOotegemto on a previous question I've ...
6
votes
1answer
49 views

Determine value in range, inject to HTML to be used in CSS

I want to show users what package they are, based on how many items they have in their cart. The code works, but I'm wondering if anything can be improved. ...
6
votes
2answers
559 views

modify custom loops to improve readability and efficiency for Wordpress?

The following code retrieve custom post types with their custom taxonomy. I'm just a beginner in PHP and I would like to know tips in order to improve readability and perhaps efficiency. home.php: <...
6
votes
2answers
183 views

WordPress Post Type template

I have created this class for my WP theme. It allows you to create templates for a meta box which relates directly to a custom frontend template to have better control of the content displayed on the ...
5
votes
2answers
263 views

Displaying all single posts

I think there are some confusing and weird indentation problems in this WordPress file (single.php). Any suggestions on improving indentation and readability? ...
5
votes
1answer
147 views

Related links for WordPress posts

I have written the following class which is part of a pagination system in Wordpress. The class works as expected and also works as expected when used in the system. Just as background, the class ...
5
votes
2answers
78 views

First WordPress template

I wrote my first template, but didn't include any styling. What do you think? What's good what's bad? ...
5
votes
1answer
517 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 ...
5
votes
1answer
93 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 is based on Bootstrap 4. ...
4
votes
1answer
154 views

Add user profile fields

I have this PHP function that adds custom user profile fields to WordPress. It saves the field through the WooCommerce form-edit-my-account.php file. I have a lot of repeated code, and would like to ...
4
votes
1answer
51 views

Adding Wordpress Meta boxes

I am adding two custom metaboxes to the WordPress post page from a plugin. I am currently doing it with two separate instances of add_meta_boxes but this feels very ...
4
votes
1answer
27 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 ...
4
votes
1answer
72 views

Custom WordPress Menu for posts

I have recently delved into the world of OOP programming with PHP. I wanted to add my own custom menu to the WordPress Admin area, and came across a tutorial, which I have followed, and the code is ...
4
votes
1answer
46 views

Looking for meta data which matches certain criteria and was created after a certain date

I've got the below SQL statement which runs in MySQL on a WordPress installation. I'm looking for meta data that matches certain criteria and was created after a certain date. However, WordPress ...
4
votes
0answers
74 views

WordPress contact form plugin PHP and WP_REST improvements

TL;DR This month I wanted to improve my WordPress knowledge and create a simple form that wasn't bloated with features but was secure. I wanted to make sure this plugin improved my knowledge of: ...
3
votes
3answers
757 views

jQuery animation and rotation effects for a WordPress site

What is the best way to tidy up JavaScript code I have written? It seems very long winded, any suggestions to shorten it? Note: I'm running it on Wordpress which runs jQuery in nonconflict mode, ...
3
votes
2answers
406 views

Correctly coding an OOP object

I have a couple of functions in WordPress that I'm rewriting to OOP. All these functions are interlinked in some way and also reuse code from other functions. This is an example of the first class I'...
3
votes
3answers
168 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 ...
3
votes
1answer
124 views

cron daily and weekly scripts for a minimal Nginx server environment

I've created the following cron for daily and weekly scripts for a minimal Nginx server environment (as part of my larger script). The daily cronjob updates WordPress and brings back original ...
3
votes
2answers
139 views

Inserting a name into a database table

I want to ask you if my PHP code is safe enough. I don't know if I should escape special characters in string after regex validation: ...
3
votes
2answers
7k views

PHP function (in WordPress) echoing HTML

I'm really new to PHP, and a little less so in WordPress. I've created a working function that spits out some static HTML into a page template in WordPress. I'd like to know if there is a best ...
3
votes
1answer
443 views

WordPress Functions.php file

I am making a WordPress "framework" for myself. Looking at the functions.php file file, is there redundant or bad code that could be changed or some code that could be good to add? The functions.php ...
3
votes
2answers
99 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 ...
3
votes
1answer
104 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 ...
3
votes
1answer
83 views

Create a WordPress site data with Nginx app data automatically

The following script is aimed for Ubuntu >=16.04 LEMP environments with PHP-FPM >=7.0, MySQL, WP-CLI, Certbot, and ...
3
votes
1answer
76 views

Importing and deleting product data in WordPress

I am interested in how to handle errors/exceptions/returned data correctly. For example, I have a script which creates, updates and deletes products data. Here is method that receives data from an ...
3
votes
1answer
2k views

Displaying a price quote depending on the selected number of rooms

I've written a WordPress plugin that displays a price quote based on what options are chosen in the settings and then what the user chooses with HTML <select> ...
3
votes
1answer
158 views

PHP function which filters content from Wordpress database (wp_posts table)

I worked on a hybrid mobile application for a newspaper company. They had a Wordpress website with news content (in a wp_posts table) which they wanted to be displayed in the application. I built the ...
3
votes
1answer
44 views

Moving WordPress database and files to new host

I've written a script in an attempt to try to automate moving hosts from old hosts to our new docker containers. All feedback and input appreciated! ...
3
votes
1answer
350 views

Singleton Class for WordPress Plugin

I'm developing a WordPress plugin using the singleton pattern with the following requirements: There should ever exist one instance of the plugin Another instance of the object should never be ...
3
votes
1answer
872 views

Bootstrap WordPress Carousel Recent Posts

This works, but I would like suggestions to improve it. For one I think the get posts shouldn't have to be repeated twice, but it only pulls the first two posts if I don't do it this way. Also, I ...
3
votes
1answer
76 views

Making a grid of videos

In my single-work.php I have some code with slight variations that I feel could be more DRY. When there are only slight variations like this is it ok to repeat part ...
3
votes
1answer
38 views

Bash Compress Managed Directory Ignoring .git, bower_components, node_modules, etc

Fairly easy way to compress a wordpress plugin (or similar) as a zip file without including all the dependencies used to create and manage the development, but which don't belong in the final product. ...
3
votes
2answers
501 views

Sort by a custom date field

I've got this code to work, but being really new to PHP, I don't know if this is proper. I've sorted a CPT loop by a custom date. I'm displaying items from most recent (or future date) to oldest if ...
3
votes
1answer
545 views

Plugin for WordPress and Foundation Reveal

I figure that someone here probably knows a much better way to do this. I'm still figuring out AJAX and jQuery, so I consider that I still need to master quite a bit of knowledge. My function ...
3
votes
1answer
221 views

Exporting data in a WordPress widget

I have some custom tables in a Wordpress database that I need to export to CSV. I created a dashboard widget to help with this based on some assistance given to me on on one of my SO questions. It ...
3
votes
1answer
248 views

Function from WordPress VoteItUp function [closed]

This code comes from a Wordpress plugin's forum called Vote it Up. It sort posts by vote. A lotof people say that there is more code than is needed. So I was wondering if someone have any idea about ...
3
votes
1answer
64 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 ...
3
votes
1answer
38 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 ...
3
votes
1answer
56 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
1answer
51 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 -...
3
votes
1answer
52 views

User generated filter and content

I am writing a (multi) filter that is created when the user enters in the data through wordpress. There can be anywhere between 2 - 10 filters so I need this to be as dynamic as possible. My first ...