Over 50 Ready-To-Use WordPress Code Snippets, Tricks & Hacks

Save time and effort coding WordPress themes & plugins with these already coded programs that come with explanations.
4.5 (9 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
241 students enrolled
$19
$40
52% off
Take This Course
  • Lectures 56
  • Length 4 hours
  • Skill Level All Levels
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

Learn and practice real-world skills and achieve your goals.

About This Course

Published 3/2016 English

Course Description

This course helps any WordPress designer and developer save time by copying and pasting WordPress code into any theme or plugin. Video lectures explain how to customize the code to make your their own.

This course will constantly evolve with new "code snippets" on everything from shortcodes, custom post types, and manipulation of popular plugins including Contact Form 7.

This course is best for those who already know the basics of PHP and some WordPress development skills, but if you are just getting into WordPress theme or plugin development, the code resources will help you add more powerful functionality to your already-existing code.

In this WordPress cookbook course, code recipes are already available for:

  • post and page content manipulation
  • automatically creating new menu locations in themes
  • custom post types
  • displaying random posts on the fly
  • manipulation of the contact form 7 plugin
  • adding a popup to your home page
  • generating a tag cloud from your posts or plugins
  • and more

What are the requirements?

  • Some PHP
  • Some WordPress development skills

What am I going to get from this course?

  • save time by adding existing WordPress code and API snippets into your plugins and themes
  • manipulate content from posts and pages
  • create your own custom post types complete with their own taxonomies and custom fields
  • displaying random posts on the fly
  • white label WordPress and replace the WP logo and replace it with your own
  • change the popular plugin Contact Form 7 and make it do amazing things that are not available out of the box

What is the target audience?

  • PHP developers
  • Both intermediate and advanced WordPress developers who would like to save time coding.

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.

Curriculum

Section 1: Introduction and Green Screen Videos From The Instructor
03:07

I introduce the class and tell you how it is structured. Remember, almost every video has its own code recipe in the Resources section for that lecture.

02:07

A lot of students ask me how to add the code snippets from this course, so in this green screen video, I answer it. The uneven collars are intentional. Come on! This is a green screen video. We have to have fun and my uneven collar just keeps it from getting boring. Can you watch this without laughing at my collar?

Section 2: General WordPress Code Snippets
01:39

This code recipe will give you a way to add the date using simple PHP, but in a WordPress shortcode.

04:26

A WordPress multisite can save you work creating multiple websites and database space, but some people ask me how to create one. I show you in this video. Open up the script in the resources section and add the code to your wp-config file. Make sure to back it up first.

07:15

Some themes are very limited with the number of menu locations they offer. Maybe you want your theme to have a lot of theme locations. The code in this recipe creates 10 new locations for you. You can also create a plugin out of this to extend any theme you purchase or download from the WP themes repository.

In this video, I also show you how to place those menu locations anywhere in your theme.

02:23

I am often asked how to make a custom-developed theme compatible with the WooCommerce plugin. Maybe you want to add ecommerce to your theme and after you add the WooCommerce plugin, your theme needs to support it. This recipe shows does that for you.

Automatically Send Email Notification Everytime a Post Is Saved
03:47
03:35

A lot of people do not know what Woocommerce comes with its own set of hooks to change it in any way. Sometimes, you may want to change the short description of a product. I provide you the script on how to do just that. Watch the video for an explanation on how I did that for one particular client.

Section 3: Code Snippets For User management, User Interactions and More
07:32

This is a funny snippet. You can drive your admins crazy with this one by changing the name of all the user roles. How about renaming the administrator role to "Supreme Honcho"?

03:18

Sometimes, you just want to log in as another user. That can be done with this code recipe. All you need is the user ID of the user and simply pop it into the function as a parameter. Run the admin back end and the user will automatically be logged in, so you can see information about that user.

03:19

Maybe you want to create a mailing list of all your users. This code recipe will do just that.I also show you in this video how to display user's names in the same recipe.

01:23

I love this recipe. How would you like a quick code recipe to display the gravatars of your writing team? This code will do that. Think of it as being similar to your Facebook like boxes. I also show you how to change the gravatar size in this video.

04:37

Sometimes, a website looks nicer and more professional when it greets a user. This code will do just that for users after they log in.

07:14

When we enter a new page or post, there is a generic placeholder that says "Enter Title Here". What if you wanted to customize it for a custom post type. This script lets you do that.

Section 4: Admin / Administrative
03:28

This is a cool little script people who like to see everything decorated with different colors. In the back end admin, you can change the colors of posts depending different on their status (published, pending, etc). Why would we want to do this. Sometimes, you may not want to click the status links at the top. This way is quicker, much quicker. By changing the colors of the links depending on the status, you can quickly see the status without extra clicks.

04:07
On some websites, we may want to change the WordPress logo on the login form for these reasons:
  • We are tired of looking at the logo
  • We want to add our own logo for branding purposes or white labeling.

With this script, you can change the logo from any URL or image in your WordPress media library.

01:50

Maybe you have a post that needs people to log in before reading it, or a private post. Just load up this recipe and enter the shortcode in the video and your content will be protected.

04:53

Add links to your Facebook page, Twitter profile, etc. This code recipe works great if you have a lot of people logging into your WordPress administrative back end.

04:05

Show admin users who have access to the back end that you cared enough to greet them in the back end. This recipe will display a welcome message in a custom dashboard widget.

03:00

Sometimes, you just do not want a specific blogger to have access to blog. Maybe he abuse his privileges. With this code recipe, you can remove the links to the Posts and Pages as well as Media.

01:50

Sometimes, you may want to remove the WordPress logo from the admin bar, perhaps for white labeling. This recipe will do just that.

03:02

Sometimes, you just want to see what your home page looks like as a regular user, but you do NOT want to log out. This code will hide the admin bar from the front end while you are still logged in.

02:53

In the last video, we removed the WP logo. The WordPress logo is nice when you tell your clients that they are using WordPress, but maybe you want them to think the CMS was developed by you. This recipe will change the WordPress logo and let you add your own.

In this video, we replace the WordPress logo with the Superman logo.

03:02

Don't you hate it when the login form shakes back end forth just because you typed in the wrong password? Add this little recipe and prevent that from happening ever again.

Properly Adding Javascript and CSS to Any WordPress Theme or Plugin
06:13
Section 5: Code Snippets To Create and Enhance Custom Post Types
00:56

There are so many plugins that help developers create custom post types. Why should developers create their own? If you create a plugin or theme, you may want it to come with its own custom post type. WooCommerce comes with its own products post type. WP Job Manager comes with its own job listing post type. In this section, I give you the code recipes to create your own custom post types.

07:01

Custom Post Types are separate types of posts that help admins create different types of content instead of just the regular "posts" that may be used as blog posts. What if you have a list of addresses or locations? Would you necessarily make them a post? Probably not. A custom post type solves this dilemna.

08:14

Taxonomies are well-known among seasoned and veteran WordPress developers providing the ability to add categories and tags to posts. However, the normal "blog post" posts may have categories that simply do not work for your custom post type, so with this code, you can add your own taxonomies that are unique to your custom post type.

10:34

Every post needs fields and custom post types can have their own fields. In this recipe, I provide the code to add custom fields to your custom post type.

02:56

Sometimes, you want to just insert a new post from as custom post type. Here is the code to do it.

PROJECT: Create The Menu Items Custom Post Type
01:35
Section 6: Recipes for the Contact Form 7 Plugin
02:33

In Contact Form 7, sometimes adding all your custom fields can be a pain for long complex contact forms. This recipe will automate all of the fields being added to the email message body.

01:49

Sometimes, you just need to capture the IP address of the sender maybe for tracking purposes or just plain blocking of specific IP addresses. Contact Form 7 provides no way to do this, so we need to add some code to our plugins or themes. This recipe has the code you need.

04:20

Suppose on your contact form you have different categories which the user can select in a drop-down menu control. Maybe you want to prevent specific categories from getting onto your website and you do not care about certain selections.


With this recipe, you can simply tell Contact Form 7 not to send emails based on specific data selected by the user. It is very useful for controlling form submissions.

Contact Form 7: Dynamically Change The Recipient Based On Drop-Down Menu Values
03:52
01:09

I explain some of the code recipes in the Contact Form 7 section.

Section 7: Quick Post Content Loops
04:22

For websites that have a lot of blog posts, they can use this code for several benefits:

  • Show users a new post every time.
  • Maybe display different information for SEO purposes.
  • Random posts also look fresh and cool.

Use the code here to generate one with a shortcode.

07:17

With this recipe, you can display posts from any custom post type. The code example shows the custom post type for countries. In the video, I also touch upon another custom post type for rock bands and show you how to find the slug that needs to be plugged into the code.

04:42

Sometimes, you just want a random post. Well, this recipe has the code for just that. This recipe shows code to display a random post for post, pages, and custom post types.

05:21

Sometimes, you just want some quick code to loop through posts by a specific category. This recipe will do that for you. Watch this video on how to set that up.

04:19

Maybe you want to display posts by a specific author. This recipes calls for a new main ingredient. That is the user ID of the author. I show you how to enter it into the recipe in this video

Section 8: WordPress New Code Snippets Tricks (Part 1)
04:29

This code snippet gives you a complete section to enter social media addresses like Facebook, Twitter, etc and shows you how to extend it to add your own. The form is added to the WordPress customizer.

06:15

From the code snippet in the last video, we use this code to display the social media links in any template using WordPress' Theme Modification API.

05:29

The Hello Dolly plugin comes with every WordPress installation, but a lot of people do not know what Hello Dolly actually is. It is a popular song from the 1930's made popular by musician Louie Armstrong, but using this code snippet, you can create a new plugin that works exactly like Hello Dolly, only using the song lyrics of your choice. How about replacing it with Rock-n-Roll by Led Zeppelin or Young, Wild and Free by Snoop Dog? The choice is up to you!

07:14

We can also change Hello Dolly to generate announcements on the back end. We can use this to display random announcements to other admins, clients, or WordPress blog writers.

03:29

Sometimes, we need an automated way of wishing our website visitors and customers that they have a nice holiday. Do it with this code snippet!

07:09

RSS feeds are one of the most powerful, but under-utilized, internet marketing tools. NY Times has over 25 of them, so in this code snippet, I give you a plugin that I created which you can use that produces a shortcode for any blog post or page. We add the NY Times Real Estate and Sports feeds, but I show you how to add any RSS feed in the world!

04:24

We can add a tag cloud anywhere in our themes or plugins. This code snippet is ready to use and I show you in this video how to change its appearance using a simple PHP array.

03:16

I gave you the code in for the tag cloud in the last video, but in this video, I show you how to set it up as a shortcode. I also provide you with a complete plugin and show you how to add the shortcode to pages and posts.

Section 9: Create a Very Lightweight Popup Box On Your Home Page
02:14

All popup boxes need styling, so I provide you the CSS needed to create a centered popup box. You can add this CSS to your existing styles.css file.

03:40

We want to add a new <DIV> to the top of your Body tag without touching any theme files, so we create this jQuery file that will be loaded up.

02:08

We need to add this code to your functions.php file or your plugin file to call the wp_enqueue_script hook which is responsible for loading scripts and styles.

Section 10: Working with Blog Posts
07:55

Sometimes, you have blog posts that you want to delete, because they are too old. What you define as "too old" is up to you. That can be two months, two years, or even two days, but it does not matter, because with this video, you will learn how to delete blog posts of any age and keep your blog as clean as you would like. 

The code snippet here prevents the stress of having to delete each and every blog post separately or searching for the Move To Trash link.

08:58

This video starts the 3-part series on inserting blog posts from an external RSS feed. Have you ever wanted to insert a blog post from another RSS feed? Doing that is a great way to start a blog post that you can re-word later and get a quick blog post out. This code snippet is used on the Latest Blog Posts blog network that has over 2,000 blogs worldwide, so a reliable plugin to perform this function is important.


This code snippet is a complete plugin that can be installed and activated. I show you how to configure it in the video.

01:40

This code snippet shows you how to automatically assign a category to any blog post that gets imported through the RSS feed.

This video does not have a resource, because it is part of the video Import RSS Feed Items Into Your Own Blog Posts (importing Blog Posts Part 1).

05:30

This code snippet shows you how to automatically attach a featured image to any blog post that gets imported through the RSS feed.


This video does not have a resource, because it is part of the video Import RSS Feed Items Into Your Own Blog Posts (importing Blog Posts Part 1).

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Bruce Chamoff, Web Developer of 20 Years and Songwriter of Over 40 Years

CEO of the Web Designer Mall, a one-stop shop for all web designers and web developers.

I have designed and developed over 1,000 websites in the past 20 years for companies of all sizes from small businesses to major Fortune 500 corporations. Being the owner of a prestigious online mall for web developers, I have programmed everything from WordPress to Drupal to Joomla to simple HTML5.

Involved in the WordPress Community. I am also a speaker at WordCamps in the United States. 

The Music, The Songwriting

I love writing, recording, and producing music, mainly my own originals. I play sax and piano and have over 150 songs. Yes, I should have gone for that record deal, but I still enjoy the process of making music!

Ready to start learning?
Take This Course