jQuery is not defined in WordPress admin

If you have a WordPress install with many different plugins, you may experience that some jQuery functionality will be lost in the admin panel (i.e. you won’t be able to move the content blocks around your Dashboard).

When you open the console (press F12 in most browsers), you will see several errors that will read:

You may also see something like:

Here is how you fix both of these with two easy steps…

Continue Reading No Comments

Embed Google Map with several locations (GeoCode addresses and display “info window” for each marker)

1. Include javascript at the top of the page. It will create a map, get a string of addresses and their respective “project names” and “amount of images” from a form that we fill during the database fetching process (see Step #3 below).

The script will then geocode each address (get latitude and longitude) and place a marker on the map. By clicking on the marker you will get an “info-window” (in our example – with project name and the amount of photos for each project). We specify the image for the marker as well.

Continue Reading No Comments

Form-based paging with PHP and JavaScript

If you have a blog or news section on your custom website, which you want to separate by pages, use the steps below to implement a paging module. First, I usually create a file called pager.php in your /includes/ folder. The content of that file is below:

Continue Reading No Comments

Keep checkboxes checked with MySQL and PHP

Most of the time we have a website or a back-end solution, written in PHP, where we use check-boxes as “flags” (to activate a user or a product for example – 1=active, 0=inactive).

Below is the example that I will base on our fictional “products” page in the back-end solution, where we specify if a given product is active or inactive (in order to show or hide it on the front of the site).

Continue Reading No Comments