Build a basic component

(Note: click here to download the exercise files referenced in this video.)

In this video, we will walk you through building a basic component that exposes a template function we can use to pull in some content. We’ll create a component folder and file; then, you’ll see where and how to pull and build from existing components in WP Rig, so you are not rebuilding the wheel from scratch.

What we need to start is a *different* component that does something *similar* to what we want to do. And there are several options available here. We’ll be using the Comments component, because it does the two things that will be useful for you to see and learn:

-First, it exposes a function, so it creates a new template tag that is used somewhere else in the theme.

-Second, it enqueues a script: in action_enqueue_comment_reply_script(), it enqueues a script. (Because the functionality is going to be Javascript-based, we need to be able to enqueue a script.)

Watch and follow along as we get started building a basic related posts component.

More from this course: