wordpress snippets last updated   : January 28, 2015
we now have 645 snippets
category functions.php

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

Link keywords or replace text in all blog posts

wordpress snippet

Adding this to the functions.php of your wordpress theme will let you replace text within your blog post. This is a great option for linking multiple pages in your blog with keywords. Don’t forget to change the “TEXT_TO_REPLACE” and the “TEXT_YOU_WANT_TO_REPLACE_WITH” lines in the above code add new lines for more items.

Note: Extensive use of this method may cause performance issues, use sparingly.

read more