WP-Mix

A fresh mix of code snippets and tutorials

Popular Posts

All posts ordered by popularity

Page 32 of 33

Redirect Attacker to Special Message

If you are using Apache server, you can stop an attack by getting the IP address of the attacker and then using it to block or redirect all of their requests. Normally I just block the requests using either Deny or Require directives (depending on Apache version), but sometimes it’s fun to redirect the attacker […]

Disable WordPress Automatic Updates

In case you haven’t noticed, WordPress auto-updates its core files by default. Neat but not always desired. Here is how to disable auto-updates with a few lines of code.

WordPress Change Excerpt Length

This code snippet is SO easy.. check it out if you want to change the default number of words included by default in WordPress excerpts.

Free Up Server Disk Space

Recently I spent some time clearing up more free space on my server. Here are some notes on things to check when doing so.

PHP Stringify Formatted Text

This code snippet takes a string of text and removes all carriage returns, new lines, and tabs, replacing any matches with a simple blank space. An ideal way to “stringify” a potentially formatted lump of alphanumeric text.

WordPress Disable Self Pings

Depending on your WordPress configuration, plugins, and so forth, your site may be suffering from “self-pings”. Self-pings are pingbacks from your own domain, which are not necessary and look kind of silly displayed alongside other, actual pingbacks. If your site is haunted by self-pings, here is a quick code snippet to stop them.

JavaScript & jQuery: Add Style to Fragment Identifier

It’s easy to style a <div></div> by targeting its ID. But what if you only want to add style when a specific fragment identifier is targeted via the URL? So for example, your page at /about/ has a table with all the data. When visitors arrive directly at /about/, no extra styles are added. But […]

PHP Error Log Tricks

Super useful trick for customizing error logs when working with PHP.

WordPress Change Default Number of Displayed Posts

By default, WordPress displays the same number of posts for the home page (when it is set to display posts) and all types of archive views. To change the default number of posts displayed for any specific view, you can add this simple function to your theme’s functions.php file.

WordPress Post Navigation Enlightenment

For some reason, I am fascinated by how post navigation is handled by WordPress and others CMSs. For example, what is the correct order of the “previous” and “next” post-navigation links? Is it different for single posts versus archive views? Should the arrow point right or left? And so forth. After pondering these questions periodically […]

Dealing with translation spam

How I respond to “translation spam”, which happens when greasy organizations ask permission to translate your script, extension, plugin, etc.

Truncate Database Table

Quick SQL code snippet that enables you to truncate any MySQL database table.