5

I'd like to add a new area on a WordPress 3.0 site that contains a new video from YouTube each day. This video would be manually picked, and manually added each day. I'm not sure how to properly set this up though.

My current thought-process is that I would create a category called "videos," and then add a new post in that category each day placing the embed code as the post-body. This seems like ugly hackery though, so I'm open to a better and more leaner solution. Ideally I would have a simple admin-side form where I would put in a title, and the link to the YouTube video (converting the link to an embed code on my own programmatically).

Does WordPress 3.0 accomodate odd post types like this pretty well? What should I read to gain a better understanding of how I would accomplish things like "video of the day", and "daily cartoons"?

0

2 Answers 2

3

I'd recommend using a custom post type to handle this. You can add the custom post type and set it to only accept the YouTube url as content. Then you can display the "most recent" post from this setup with a custom loop on your home page.

Here are a couple other good resources to start with:

3

Hi @Jonathan Sampson:

@EAMann is spot-on, Custom Post Types are the way to go.

Here's code you can toss in your theme's functions.php file to implement the Custom Post Type you need (note I included a helper function make_post_type_labels() I like to use that reduces the complexity of defining Custom Post Types):

register_post_type('daily-video',
  array(
    'labels'          => make_post_type_labels('Daily Video'),
    'public'          => true,
    'show_ui'         => true,
    'query_var'       => 'daily-video',
    'rewrite'         => array('slug' => 'daily-videos'),
    'hierarchical'    => true,
    'supports'        => array('title','editor',
  )
);
function make_post_type_labels($singular,$plural=false,$args=array()) {
  if ($plural===false)
    $plural = $singular . 's';
  elseif ($plural===true)
    $plural = $singular;
  $defaults = array(
    'name'               =>_x($plural,'post type general name'),
    'singular_name'      =>_x($singular,'post type singular name'),
    'add_new'            =>_x('Add New',$singular),
    'add_new_item'       =>__("Add New $singular"),
    'edit_item'          =>__("Edit $singular"),
    'new_item'           =>__("New $singular"),
    'view_item'          =>__("View $singular"),
    'search_items'       =>__("Search $plural"),
    'not_found'          =>__("No $plural Found"),
    'not_found_in_trash' =>__("No $plural Found in Trash"),
    'parent_item_colon'  =>'',
  );
  return wp_parse_args($args,$defaults);
}

Also you might find these two answers to be helpful as well:

1
  • Excellent information, Mike. I'll consult this when I begin this solution.
    – Sampson
    Commented Aug 23, 2010 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.