Category Archives: WordPress

My First WordCamp Talk

On Saturday I had the great pleasure of speaking at WordCamp Vancouver. It was my first time speaking at a WordCamp, and my first time ever really speaking about anything at length. I really, really didn’t want to bomb this, because the idea of talking WordPress and geek in general with a bunch of likeminded folks is awesome and I wanted to kind of mitigate the possibility of a discouraging first experience.

So I picked the brain of friend, coworker and amazing speaker, Zack Tollman, and got a few tips.

The biggest takeaways were preparedness and practice.

  • Really researching and knowing the material rather than winging it.
  • Actually going through your talk a few times so that you know where your problem areas are before you get to them.

He also recommended Confessions of a Public Speaker [Scott Burkun], which turned out to be a fantastic read. Because of Zack’s advice and the added info from Scott, I actually ended up doing a bunch of mental preparation about the approach I wanted to take before I finally dove in on the presentation itself.

When I did dive into the presentation, I decided to try and get as many of my thoughts down and organized before worrying about a slide. For this I used an outlining tool, WorkFlowy, and ended up creating the entire talk this way. It did become difficult to transfer this data in the way I wanted for my article and slides after the talk, but other than that it was perfect. I may explore different outline options directly in WordPress for the next one.

After completing a decent draft of the talk, I then gave it a few practice runs to make sure things were feeling right. At this point I was able to remove material that didn’t flow and sharpen a few points that were getting lost. Once I started to feel satisfied that the stuff was working, I dove into Keynote land to create the slides.

Keynote ended up working out so much more awesome than I thought it would. I think next time I’ll leave myself with a lot more time to create the slides as I think I could have been more efficient and creative at the same time. Being able to use my iPhone as a Keynote remote was an added benefit, though the presenter notes ended up being a bit of a crutch.

I went through the full presentation a couple more times after the slides were created. This enabled me to figure out where I needed notes and to take out some stuff that was still feeling forced. I ended up not doing a full run through in the morning before my talk in favor of an extra hour of sleep, but I think that was one of those good decisions.

At first I wasn’t sure about being first on the schedule, but I think that played to my benefit. I was able to sneak into the room alone, walk around and kind of get a feel for how people saw the front and how it felt to say a few words. The tech setup was great, so I really didn’t have much to worry about.

The talk itself went well. I was less nervous than expected, though any time I lost track of my thoughts and tried to cheat with the presenter notes I felt it. The reaction from everybody throughout the talk was wonderful and I was surprised many times at how well less obvious humor got across. Everything went super fast and I was on the last set of slides before I knew it. I only forgot a few things, but nothing that hurt any of the points I was making. And the Q&A session went perfect. We had some really good questions and I find a lot of comfort in that back and forth discussion.

My overall thought on the next talk is to move prep time back by at least a week. I’d love to be in a place where the last week is less about slide prep or content creation and more about practicing the talk itself. I think I’ll try to find an alternative to the presenter notes in Keynote Remote. The iPhone was a perfect slide switcher, but the small screen is too distracting when you want to take a quick look. Depending on the room, a piece of paper with a few notes would have probably turned out better.

And that’s it. Eating my own dog food and documenting myself.

Anybody that was there – thanks a ton for sharing that experience with me and for the positive reaction throughout. I had a blast.

And now, a bunch of tweets from awesome people! Thanks, #wcyvr!

Continue reading

Filters In Youtube Favorite Video Posts

Today’s update of Youtube Favorite Video Posts includes a couple filters that can be used to modify the post title and content whenever new items are saved. Here are a few snippets that show the filters in action. These can be added to your theme’s functions.php file, or, as is often applicable, to the child theme you have created from your primary theme of choice.

Youtube Favorite Video Posts can be downloaded through the WordPress plugin repository. More info can be found through the overall project status page.

Exploring Intention When Registering Custom Post Types In WordPress

I’ve often found myself confused when trying to determine the intent of the optional arguments available to the WordPress function register_post_type(). While many are fairly obvious, there were a few that needed some better definition. I set off this weekend to update the register_post_type() Codex article as well as the associated inline docs in post.php.

As part of that refresh, I’m hoping to use this write up as a way to further explore what’s actually going on behind the scenes.

To serve as a very brief guide, here is an example use of register_post_type(). After, I’ll dive into a few of the arguments to expand on the intent involved with each.:

‘public’

Implies overall intent for the post type.

The word public in this case should not be confused with front-end. There is no hard definition, and a post type can be public while remaining hidden from any front-end view. The setting for public is used for admin, front-end and XML-RPC requests and should not be underestimated.

If no additional arguments are set, the value for public also helps to trigger values for publicly_queryable, exclude_from_search, show_ui, and show_in_nav_menus as such:

Any easy assumption to make here is that public only triggers other arguments. That is not correct. While other arguments can inherit its value, public is very much an argument on its own.

How ‘public’ is used in WordPress (as of 3.4)

  • Checked for as ‘true’ during redirect_guess_404_permalink() in canonical.php if the ‘name’ query var exists without a request for ‘post_type’.
  • Checked for as ‘true’ during wp_link_query() in class-wp-editor.php to provide the list of possible internal links when using WP Editor.
  • Checked for as ‘true’ during _get_last_post_time() in post.php to query for the last posted post object.
  • Checked for as ‘false’ when looking for lost attachments in upload.php to help exclude post types (in addition to attachments) that attachments cannont be attached to.
  • Checked for as ‘true’ during find_posts_div() in template.php to help find posts that attachments can be attached to.
  • Depended on when using _prepare_post_type() and wp_getPostTypes() in class-wp-xmlrpc-server.php to provide the post type’s ‘public’ status to XML-RPC requests.
  • Checked for as true during wp_admin_bar_edit_menu() in wp-includes/admin-bar.php to display the ‘View Item’ link in the admin bar.
    • The show_ui argument is used for this on the front end.
  • Checked for as true during redirect_canonical() in canonical.php when trying to redirect based on a valid page, post or attachment ID passed via query_var.
  • Checked for as false during _update_blog_date_on_post_publish()  and _update_blog_date_on_post_delete() in ms-blogs.php to help decide whether or noth to update a site’s last updated time in a multisite environment.
  • Used during edit-form-advanced.php when determining whether to show a sample permalink and the associated Edit, View Post and Get Shortlink buttons.
  • Used when displaying single rows in class-wp-posts-list-table.php to determine if preview/view links should be shown .
  • list still in progress, feel free to chip in…

‘publicly_queryable’

Should the post type be queried for on the front-end via parse_request()?

This is very much related to what can be seen by a user on the front-end of a WordPress installation. Most URLs associated with a post type will cause a related query_var to be available during parse_request() in order to handle the direction of the page load.

In fact, the only use of publicly_queryable in core code outside of register_post_type() is in class-wp.php as part of parse_request() when the post_type is set as a query var.

  • If $query_var['post_type'] is a string and matches a post_type that is publicly_queryable, it continues.
  • If $query_var['post_type'] is a string and does not match a publicly_queryable post_type, the $query_var['post_type'] is unset entirely.
  • If $query_var['post_type'] is an array, it is matched with an array of post types that have publicly_queryable set to true.

If not explicitly defined, publicly_queryable inherits the public setting, which is false by default.

‘exclude_from_search’

Should the post type be available to front-end search requests?

This argument is checked for during get_posts() in query.php only if the post_type of the query is set to ‘any’. A check is done then for all post types that have ‘exclude_from_search’ set to false.

For any of the other conditions, whether multiple post types or single post types are specified, no check is done to see if should be exluded from search. This results in slightly unexpected search behavior, as seen in this document of test results.

If not explicitly defined, exclude_from_search inherits the opposite of the public setting, which results in ‘true’ by default.

‘query_var’

What should be used as the query_var key in parse_request()?

This helps control the query_var used when a URL is loaded to be processed by parse_request().

  • If true, a post loaded at site/?{post_type_key}={post-slug} will be successful, as the query_var is set to the post_type key.
  • If false, a post loaded at site/?{post_type_key}={post-slug} will not be successful, as the query_var is not registered for use.
  • If a string, such as ‘my-cpt-slug’, is set, a post loaded at site/?my-cpt-slug={post-slug} will be successful.

By default, query_var is set to true and the key used to register the post type becomes the query_var string.

In Progress….

This is very much a work in progress, especially with the settings for public, as its value is used far more in WordPress core than I’ve been able to find so far. I’ll be updating this document as I find more examples, and would be happy to include any input. While exploring, I’ve compiled a horribly formatted document (saved as a Gist here) that attempts to provide examples for each combination of some relative arguments.

Fire away!

Filters In Automatic Featured Image Posts

A feature requested multiple times for Automatic Featured Image Posts is the ability to insert the new image into post content in addition to assigning it as the featured image for the post.

I tried a few things to make this work, but there are two primary issues:

  1. I hook into the ‘add_attachment’ hook in WordPress. This runs immediately after an image is uploaded and the attachment data is added to the database. I can grab this data immediately, but only for the full size version of the new image. The thumbnails are crunched in the background and I haven’t yet found the right way to grab a smaller image for display. This works fine at times, but your site could quickly become bogged down with multiple 2MB files loading on your home page.
  2. If I was able to solve the first issue, it would still be hard to determine what the new post content should look like. Should I only use the medium image? Should it be center aligned? The varieties are fairly endless, where as using the featured image makes the display very flexible. [what are WordPress Post Thumbnails/Featured Images?]

So with those in mind, while this request stretches the bounds of the primary purpose for the plugin, it is easy enough to provide filters to allow content to be handled on a custom basis.

With today’s update for Automatic Featured Image Posts, I’m adding 3 filters that allow you to easily set the new post title, categories, and content as you upload images. The new image will continue to be attached as the featured image for the post, but this will allow more flexibility for those who want it.

Here are a few snippets that show the filters in action. These can be added to your theme’s functions.php file, or, as is often applicable, to the child theme you have created from your primary theme of choice.

Automatic Featured Image Posts can be downloaded through the WordPress repository. More info can be found through the overall project status page.