wordpress snippets last updated   : January 29, 2015
we now have 646 snippets
category functions.php

Display post views within admin post columns

wordpress snippet

I posted a cool snippet yesterday to (track post views using post meta) I wanted to add a little to that today. Adding this snippet to the functions.php of your wordpress theme will display the post views next to each post in the wordpress admin.

read more

Track post views without a plugin using post meta

wordpress snippet

Use the following snippet to track post views on your wordpress blog. The first thing you want to do is add this snippet to the functions.php of your wordpress theme. Follow step 1. and step 2. to track and display the number of views for each post.

read more

Add custom media_buttons for shortcode selection

wordpress snippet

I was looking for a simple way to create a menu for my shortcode items and although you can create tinymce plugins I found it to be a pain. So I decided to create a simplified select menu that would require me to change a little HTML to add new items. Adding this wordpress snippet to the functions.php of your wordpress theme will add a new select menu beside the add media icon. Edit the value= to change the inserted text.

read more

Add category selection to custom post type

wordpress snippet

Adding this wordpress snippet to the functions.php will enable category selection within the editor for your custom post type. Don’t forget to change the CUSTOM_POST_TYPE to the name of the custom post type you created.

read more

Add styles select button / menu in editor

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will enable a styles menu in the visual wordpress editor with the following default styles. wp-oembed, wpGallery, wp-caption-dd, wp-caption, alighright, alignleft, aligncenter

read more

Replace keywords in the_content and the_excerpt

wordpress snippet

This is an updated version of the post from a few days ago (Link keywords or replace text in all blog posts) overall this is a better solution if you have a large list of keywords. Adding this PHP snippet to the functions.php of your wordpress theme will allow you to replace keywords within the_content and the_excerpt using an associative array.

read more