Working with Posts: Categories & Tags

Video Transcript

Intro to Posts: All Post & Add New

Welcome to the first of a two part training within the Introduction Series dealing with posts. Posts are where WordPress began years ago as blog platform. Posts allow for the creation of content which can be static at first, but dynamic overtime as you may revise the content with updates. So let’s dive in.

The Posts section is located in the side menu and when you hover over it a list of options under posts will be displayed. These options are also displayed below the posts menu if you were to simply click posts, with the first we will cover here selected by default: All Posts.

All Posts

When you select All Posts, a list of all previously created posts will appear within the right section of the Posts area. Posts can have various published statuses, which are displayed across the top above the list of posts. Some of these statuses include All, Published and Draft. With the addition of plugins, additional statuses might be available.

Each of the posts listed with be displayed in a column format, with columns that show the post’s title, author, categories, tags, number of comments, and date the post was published or if unpublished, last modified. Hovering over a post title will present you with options for working with that post: dit, Quick Edit, Trash, and Preview / View. Let’s take a quick look at what each of these items can do for you.

Edit

The edit option will open the page in the admin area and allow for the post to be edited as you wish, provided your account has the ability to edit posts.

Quick Edit

The quick edit option allows for quickly changing items such as the post title, while hiding the post’s content.

Trash

The trash option allows for removing a post from being accessed on the site. Items in the trash can be permanently removed or restored, to allow access to view or make changes.

Preview / View

The preview option will allow for viewing an unpublished post. If the post has been published, a view option will allow for viewing the post as it is.

Now that we have looked at how to work with previously created post, let’s look at how to create a new post.

Add New

When you select Add New under the Posts area, you will be presented with an area to create a new post. For most users from WordPress 5.5 and newer, you will see the block editor Gutenberg. We dive deeper into Gutenberg in the Gutenberg training.

Prior to WordPress 5.5 or for those using the classic editor plugin, the visual editor might be the default editor you see. You can still choose to use Gutenberg within the post creation or enable this to be selected by the user. Doing this is discussed in the Classic Editor plugin training. Alternatively, you could be using a different visual editor entirely.

Wrap Up

This concludes the Introduction to Posts training for the All Posts and Add New sections. Additional training is available which covers Categories and Tags, along with how you might best work with these two types of organizational structure.

WooCommerce: Working with Products

WooCommerce provides a way to sell items, both physical and virtual. As a WordPress plugin, WooCommerce builds upon the structure of WordPress. This allows for integrating a store right inside your site. A WooCommerce overview is great for those who want to learn more before proceeding.

There is quite a bit to learn about with WooCommerce. In this training we will take a look at the types of products your store can offer. In addition, we will look at the virtual and downloadable options, to see when these are appropriate to use.

Product Data Types

WooCommerce offers 4 product data types to choose from and we will look at each of them.

Simple Product

This is the most common and simplest product data type. The simple product is great for items without options, such as sizes or colors, for the customer to choose from.

Group Product

Group product is an interesting product data type. A popular group product setup is music. Typically sites will offer the ability to choose which songs to purchase. Or to even purchase the entire album, all on the same page. When you wish to show a group of simple products together, the group product is a great choice.

External/Affiliate Product

External products is great if you have affiliate products you wish to add to your store. Unlike the simple or variable product option, the "purchase button" goes to the external site for completing the purchase.

Variable Product

Variable products are great for more complex products. One great example of a variable product would be articles of clothing. You could have different sizes, such as t-shirts. You can make variable products as complex as needed. For example, you could have size and color as options.

Virtual / Downloadable Options

The virtual and downloadable product options are amazing. Each has a distinction, so let's take a look.

Virtual products are non-physical products and are not items to ship. That is, selecting the virtual option hides the shipping section. One of the best examples of a virtual item is an e-card.

A downloadable product comes with a download option. The download can be from anywhere, either onsite or using an external service. One of the best examples of a downloadable item is stock photography. Downloadable products allow for setting a time limit for downloads, as well how many times overall a download is available.

5 Minute Guide to Install WordPress in Pictures

WordPress prides itself in offer a simple 5 minute installation. The first time I heard this several years ago I did not believe it. This is until I put it to test and was able to get my very first site installed within a five minute window. Ever since then, I have been working to get every client setup on WordPress.

Needed to Setup WordPress

Before we jump into the actual setup, you will need to have the following information handy:

  • FTP information (host name, ftp user name, ftp password)
  • Database information (database server name - typically localhost, database name, database username, database password)
  • WordPress, either as a zip or tar.gz - extracted

Next Do the Following

  • Upload the files and folders within the extracted WordPress folder (wp-admin, wp-content, wp-includes and loose files within the wordpress folder)
  • Set the main folder's permissions to 777

On to the Web Install

Visit example.com in your browser (replace example.com with your web site's address)

Understanding the htaccess File

Before we dive into how to use the .htaccess file, what is the htaccess file? It controls what happens in both the directory it is placed in, as well as any directories underneath and is for Apache-based web servers. WordPress, for example, creates it in the root directory for your website, which redirects all frontend access to the index.php file in the main folder. That index.php file then does all the magic behind WordPress.

What are the most common items found inside a .htaccess file?

A few of the more common items found include:

  • Manual redirects when something is not found
  • ErrorDocument directives (where to go when an error is detected)

But there are so many uses for it, such as:

  • Enabling compression for files on your site
  • Preventing direct linking (hotlinking) to files on your site
  • Setting files or directories from being accessed directly
  • Disallowing the listing of items with one or more directory

This is by no means an exhaustive list of what a .htaccess file can do for you. An upcoming training series will take a deeper look into what we can use this file to do for us.

Training in this series:

  • Compression - Enabling GZIP Compression for Your Files
  • Hotlinking - Prevent Direct Linking to Your Files
  • Redirection - Creating Manual Redirects
  • No Direct Access - Preventing Direct Access to the .htaccess File (or Other Files)

Build Array of Post Types

There may come a time where you will desired to build array of posts types. I needed such a thing to create checkboxes for the hide title feature of My Simple theme. So let's take a look at how this array is pulled together, starting with the code.

$post_types = get_post_types(
  array(
    "public" => true,
    "objects",
    "and"
  );

foreach( $post_types as $post_type ) {
   $post_names[$post_type->name] = $post_type->labels->menu_name;
}

The first line uses the get_post_types() function, which accepts three items: arguments, which in our case are post types marked as public, an output, objects in our case to give us an array of elements for each of the post types, and the operator, since we want all public post types we choose "and".

Choosing the output of objects allows us to pick an array value combination, the name for the key and the menu_name label for the value. Choosing to go this route will end up allows us to build an array like the following, thanks to the foreach loop cycling through all of the returned post types:

// List Post Types
$post_names = array(
  "post" => "Post",
  "page" => "Page",
  "media" => "Media"
);

This setup will allow us to have both a key and a value, so we can end up with the following for those checkboxes in the theme options panel, under both the Allow Hide Title option and Allow Sidebar Placement like this:

<div class="post-type-option">
<input id="my-simple-theme-post_types-post" class="checkbox of-input" name="my-simple-theme[post_types][post]" type="checkbox" />
<label for="my-simple-theme-post_types-post">Posts</label>
</div>

This is just to fancy it up a bit, but an array of post types can do so much more.

Working with Meta Boxes

Meta boxes are amazing for the WordPress world, whether you are creating them to integrate within a WordPress theme or a plugin. In this training, we will take an overlook of what you will need to do to create meta boxes for your site.

What is a Meta Box?

Meta Box Hooks

Meta boxes are creating using the add_meta_box() function, hooked in through the add_meta_boxes action like this.

add_action( 'add_meta_boxes', 'your_function_name' );

function your_function_name() {
   add_meta_box(
      'metabox-item-id', // ID
      __('Title', 'my-metabox' ),  // Title
      '', // Callback
      'custom_post_type', // Screen
      'normal', // Context ('normal', 'side', 'advanced')
      'default' // Priority (default, 'high', 'low')
   );
}

To ensure our meta boxes only show up where we would most likely wish them to show up, when adding or editing a post, we will amend that beginning add _action to fire only on those pages, like this:

/* Fire our meta box setup function on the post editor screen. */
add_action( 'load-post.php', 'post_meta_boxes_setup' );
add_action( 'load-post-new.php', 'post_meta_boxes_setup' );

function post_meta_boxes_setup () {
    add_action( 'add_meta_boxes', 'your_function_name' );
}