Blog Category: PHP

WordPress Function to Easily Include Files

July 6, 2014 Development, PHP, WordPress

WordPress Function to Easily Include Files

When building a website these days, include files are incredibly useful for the common pieces such as the header, footer and sidebar. In WordPress, I usually stick with the basic …

Read More

Stopping WordPress From Redirecting Matched Slugs

July 1, 2014 Development, PHP, WordPress

Stopping WordPress From Redirecting Matched Slugs

A friend of mine asked recently why an old link was redirecting to a similarly named page in WordPress. Even though the page had been deleted, the link was still …

Read More

How to Show HTML Special Characters in Textarea

June 15, 2014 Development, PHP

How to Show HTML Special Characters in Textarea

After adding Prism code highlighter to this blog, I quickly found out that all HTML opening angles, which look like <, need to be written in their special character form, …

Read More

Only Show Posts in WordPress Search Results

May 30, 2014 Development, PHP, WordPress

Only Show Posts in WordPress Search Results

By default, the WordPress search shows results from pages and posts. One client only wanted to search their blog posts and not the rest of the pages on the site. …

Read More

Using mysqli_data_seek() Function to Grab Random Row

July 31, 2013 Development, MySQL, PHP

Using mysqli_data_seek() Function to Grab Random Row

I wanted to use a set of database results twice on a page but didn’t want to run the database query again. Using the mysqli_data_seek() function, we can reset the …

Read More

How to Tell if a Variable is Odd or Even

July 17, 2013 Development, HTML, PHP

How to Tell if a Variable is Odd or Even

While creating divs for a recent project, I wanted to assign a class to the even containers so they would float right. Container #1 would float left, #2 would float …

Read More

Creating a Custom Excerpt with Two Paragraphs

July 17, 2013 Development, HTML, PHP

Creating a Custom Excerpt with Two Paragraphs

For my website, I have written a lot of news articles over the years and I wanted to print out an excerpt for each one. Instead of writing an excerpt …

Read More

How to Check if a Variable Includes a Number

July 17, 2013 Development, PHP

How to Check if a Variable Includes a Number

For spam checking in an email script, I wanted to see if the name field had any numbers in it. Spammers write code that automatically fills out contact forms and …

Read More

How to Implement the WordPress Featured Image

June 26, 2013 HTML, PHP, Plugins, WordPress

How to Implement the WordPress Featured Image

In WordPress, you’ll notice on the right side of the add/edit post screen a box that says featured image. Some themes take advantage of this area and this is how …

Read More

PHP Function to Grab WordPress Theme Location

June 25, 2013 Development, HTML, PHP, WordPress

PHP Function to Grab WordPress Theme Location

Sometimes when I look at WordPress code, especially on older sites, I’ll notice the following line of code: HTML <img src=”/wp-content/themes/my-theme/images/my-image.jpg” alt=”My Image” /> There are a couple reasons to …

Read More

Let's Talk About Your New Website

View Portfolio Contact Today