Appearance Customize example code

Appearance Customize – WordPress theme Quick Start

David Nash code, wordpress 0 Comments

There’s a lot of detailed information on how to add settings under the WordPress Appearance Customize menu. It’s far too detailed if you just want to add a couple of settings. In this example I just wanted to add some simple fields. One for the company title, which differs from the site title. And another for their logo which appears in the WordPress header. Modifying Appearance Customize with functions.php

Once you add this, check under Appearance > Customize. If all is well you’ll see your logo and title field. If you’re really adventurous you could create an array of …

FacetWP: How to automatically get proximity location in Listify

David Nash wordpress 6 Comments

This issue happened for me in Listify, but it should apply to any FacetWP form you don’t want to refresh. We wanted to display the FacetWP form on the home page, and have it automatically geolocate the user. This can be done simply with this jQuery code, with a click event on the .locate-me element. I found code on the Listify site that should do this, but it causes the form to reload repeatedly. I contacted them but they say they didn’t have that issue. The problem with this is that when the location gets set, the form reloads, causing it to …

Listify

Listify: How to display default images based on category

David Nash wordpress 4 Comments

You use Listify, the popular directory listing WordPress theme, but want to set default images on a category basis. Here’s how! To customise Listify, it’s best to use a child theme. Listify supplies a skeleton for you to do this. In the child theme’s functions.php, add this:

How this relates to Listify Listify has its own categories for listings. Don’t confuse them with WordPress post categories. Listify calls them job_listings because it’s based on a Jobify. Some of this terminology has carried across. When you create a listing category in Listify, you’ll get a category slug. In the child theme’s …

Create an auto-complete field in WordPress

David Nash wordpress 67 Comments

I’m working on a project that has a large database – about 14,000 business listings. It also has a page for a user to sign up and select which business they work at. 14,000 is way too many options for a SELECT (drop-down) field and I don’t want to put that much load on the MySQL database either. My solution: an auto-complete text field that reads from the WordPress database. I take it one step at a time, and make sure each step works correctly before starting the next step. Here are the steps I took to do it. Front-end JavaScript …

Listify and FacetWP: How to order results by rating

David Nash wordpress 6 Comments

Listify is a WordPress directory listing theme. It allows users to submit listings (of businesses, for example) and also allows users to rate those listings. It uses the WP Job Manager plugin to manage the listings. For some reason, it’s not currently possible to order the search results by user rating. The theme developers have told me that feature is planned for future releases. If you purchase the FacetWP plugin, it becomes possible for the user to order the results, but rating is now included. It took a little digging but here’s the solution, which I think is fairly elegant. Simply copy …

Linux for WordPress Developers – Part 2

David Nash mysql, wordpress 0 Comments

In Part 1 of Linux for WordPress developers I covered the Apache web server, domain names, .htaccess and .htpasswd files, and extracting the WordPress files. WordPress uses the MySQL database, which can be a little daunting if you’ve never set one up before. I use Ubuntu and I find the easiest way is to use phpMyAdmin, which if you’ve used cpanel as a WordPress developer you’ve probably used this to import the MySQL dump file. You can install it on Ubuntu by following the phpMyAdmin community docs. Creating a database for WordPress Once you’ve installed phpMyAdmin just visit http://localhost/phpmyadmin/index.php and log …

Linux for WordPress Developers – Part 1

David Nash wordpress 0 Comments

I’ve used Linux for years, and I think it’s perfect for any WordPress developer. When the site is live, chances are it’ll be running on a Linux server. So it makes sense to do your WordPress development on the same system that will be running your finished site. Not only does it cut down on nasty last-minute surprises, it also means that when those surprises do arise, you’ll know what to do when they do occur. I’ve run Ubuntu for a while and think it’s pretty good. I use it for the same reason I develop with WordPress – Ubuntu has …

WordPress REST API now in core WordPress 4.4

David Nash wordpress 0 Comments

Oh no, Acronyms! Or as I like to say, ON,A! What is REST? It’s a contract of REpresentational State Transfer. What is an API? An Application Programming Interface. So what does all this mean? It means that you can use HTTP to send and receive data to web servers. HTTP is HyperText Transfer Protocol, but let’s keep this simple. Usually when you access websites, your browser sends GET requests to the web server. If you fill out a form it will often be a POST requst (because you’re posting data to it). “But WordPress is has always been a web-based system” I …

WordPress powers a quarter of all websites

David Nash wordpress 0 Comments

W3Techs collect statistics on web servers, and recently reported that WordPress now runs on 25% of all web servers. On hearing this news, Matt Mullenweg said “Only 75% to go”. And that’s not all. They say “We have indicators that show that WordPress is likely to grow even further. In October, 29.5% of new sites used WordPress. New sites usually show the way where the whole market is heading to.” Why is this important? With so many people using WordPress, it’s likely that whatever unique thing you’d like to do has already been done before. There’s a good chance that …

Tracking Contact Form 7 events with Yoast and Google Analytics

David Nash wordpress 1 Comment

I discovered this while setting up Google Analytics when I recently re-launched my site. I’m using the very popular WordPress plugin Contact Form 7 for a nice AJAX contact form. I’m also using the equally popular Google Analytics by Yoast (GAbY) WordPress plugin. Google Analytics shows which pages users are viewing. I want to drive users to contact me, and I’d like to get information on how many people are doing that. But because it’s an AJAX form (ie, submits the data via Javascript), Google Analytics doesn’t register an additional page view. You have to “tell” it to do that. At first I …