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

learn more… | top users | synonyms

2
votes
2answers
36 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 ...
1
vote
0answers
28 views

Time table for users

I'm working on a WordPress theme and creating a time table which will be easy to complete by users. In the back-office, there are a checkbox for each days: ...
1
vote
1answer
24 views

Multiple Wordpress metaboxes in fewer different functions

Is it possible to call multiple metaboxes in Wordpress with less duplicate functions? For instance, these are my current metaboxes (3 of them, one is a checkbox and two others are text input fields): ...
1
vote
1answer
41 views

Interface injection and common functionality between classes

I'm trying to get my head around the OOP principles and coding my own classes. As a means to learn, I have decided to convert a couple of functions I have written in Wordpress to OOP classes. These ...
2
votes
1answer
30 views

Reading and Converting XML File to Array

I'm using WordPress ( PHP Based Platform ) and I'm trying to read an external XML File, convert it into a usable array, then compare two arrays - one from the xml file and another from an options ...
6
votes
2answers
192 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 ...
0
votes
1answer
41 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
2answers
147 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 ...
0
votes
0answers
27 views

apply_filters for validation function

I am using the function below to validate my color options, but I am not 100% sure if I am doing it right, particularly this bit of code: ...
0
votes
0answers
208 views

jQuery Scroll to ID on Next Page Loading and Back to Top Anchor

I'm no jQuery fundi and I kinda hacked this together, it does work. I just want to know if there's a better smoother more code compliant way of doing it? ...
1
vote
1answer
63 views

Button to follow / unfollow a user

As a beginner in coding, I have just written this code. The code should Add a form with a button to each user profile, it named Follow or Unfollow. It updates the user meta named "following" for the ...
2
votes
2answers
61 views

WordPress: multiple loops

I have two loops on my page - each with their own category. It works, but I don't know if this is the best practice as I'm pretty new to this stuff. ...
1
vote
1answer
44 views

Navigating calendar by week

I started actually learning a little programming last year, as opposed to just hacking away at libraries and found fragments. For a WordPress plugin I needed to navigate through weeks, which I ...
2
votes
1answer
121 views

Removing stray brackets from in between shortcodes

I was wondering if someone could point me in the right direction for cleaning up this code. WordPress uses shortcodes in the form [shortcode] to add extended functionality to posts and pages. What ...
4
votes
2answers
67 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? ...
2
votes
1answer
26 views

Sorting of nested categories inside a Common Table Expression

I have a PostgreSQL database which contains (among other things) the following table definition: ...
1
vote
1answer
81 views

Automatic password security test for WordPress

I was bored the other day and wrote the following little script to attempt to find insecure passwords for WordPress blog owners so they could be notified of how easy it would be to crack their WP ...
6
votes
3answers
3k views

Foreach within Foreach loop - is this code poor form?

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, ...
1
vote
0answers
43 views

Displaying site posts in a layout based on image

This basically shows the posts of the site in a layout like, 1 row image + text, and the next row text + image, but when there is no image, it only displays text in the entire row. I want to know a ...
0
votes
0answers
76 views

Foreach with the aim of removing the need for a $global

Below is a function (part of a procedurally written Wordpress plugin) which iterates through a multi dimensional array of regions, adding them to a custom hierarchical taxonomy. In the spirit of ...
6
votes
3answers
570 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; ...
2
votes
1answer
61 views

DB security and efficiency in WordPress plugins

I recently wrote my first WordPress plugin, which was also my first PHP project. After I was done, I didn't care for the code at all, so I have spent the past couple of days refactoring it. I'm trying ...
2
votes
0answers
103 views

Plugin that grabs the coordinates of all the cities in our database

I have a plugin that grabs the coordinates of all the cities in our database working in WordPress here. ...
3
votes
1answer
132 views

Social Share count

I am creating a social sharing counter plugin for my WordPress blog. I want to fetch the counts of number of likes, shares, Facebook comments (I am using Facebook comment box), twitter tweet counts ...
10
votes
2answers
239 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 ...
6
votes
2answers
337 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 ...
2
votes
0answers
137 views

Automatic submenu

The goal here is to create a Top Level Menu that automatically pulls child pages without the need to manually add them to said menu. I didn't know any other way to accomplish this without a walker, of ...
1
vote
2answers
101 views

How do I refactor this responsive background images code?

In my latest project I am using fullscreen background images for each page. I decided to write some code to fetch the different thumbnail sizes and then use it as a background for the appropriate ...
2
votes
0answers
36 views

Is this the correct usage of filters in WordPress? [closed]

I am building a plugin and I'm getting doubts whether the code I am using is the correct way of doing things with regards to WordPress hooks and filters. The scenario is that the code at a particular ...
2
votes
1answer
93 views

Wordpress filter post by metavalue

I am making a filter to get posts by status that are saved by post metavalue in a Wordpress plugin. It is a question and answer system, where the question and answer are post objects. ...
6
votes
3answers
230 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. ...
5
votes
1answer
131 views

Is this a good WP Post Type template script?

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 ...
3
votes
1answer
327 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
1answer
357 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
135 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 ...
2
votes
3answers
143 views

Displaying fields in a sidebar of a custom page template

I'm beginning with PHP programming and would appreciate a critique on my code and how I could make it more efficient, rather than repeating the if statements. What ...
2
votes
1answer
294 views

simple theme options in array

I have created a wordpress theme options using array, and it is working. There are 5 type of input text,textarea,checkbox,select and upload. Kindly check this ...
6
votes
3answers
222 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 ...
1
vote
1answer
93 views

Wordpress $wpdb->row Query Check

Looking at $wpdb class, I found get_row, and I am unsure if the function automatically prepares the query. I believe it does not ...
3
votes
1answer
230 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 ...
4
votes
2answers
221 views

Confusing and weird indentation problems in this Wordpress file (single.php)

I think there are some confusing and weird indentation problems in this Wordpress file (single.php). Any suggestions to fix indenting and readability? ...
6
votes
2answers
539 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: ...