Week 4 – Exploring Custom Post Types

This week’s assignment:

If you got to this point you call honestly call yourself a self-learner. Most folks have quitted or fallen behind. If you’re still with us, congratulations, you are part of the top. However, before you can call your status you’ll have two final assignments. This week and the final next week. For this week assignment read on…

Client Y loved your work and asked if you could provide a full site, based on WordPress,  besides a blog. This would involve having a WordPress installation with a blog page (where blog posts will go) but also a page where photos will appear with some  information. He would like the ability to enter photo information via the admin panel.

Suppose he wants to add a photo. He should have the admin panel option ‘New Photo’. Within this menu he can add:

– Photo’s Title
– Photo’s Description

And as extra fields:

– Location where the photo was taken
– Year the photo was taken
– Camera used

The photo itself will be added via the ‘Featured Image’ metabox.

Can you do it?

Hint: Custom Post Types are ideal for this kind of job.

Stuff that can help:

– Provide a link to my e-mail for approval on this assignment with the subject: “your_p2pu_user/assignment4”. Results will be posted on-line afterwords.
Update: For your changes to take effect on the frontend, meaning in the appearance of your site, you will need also to update the theme files in order to retrieve the extra fields and display them.
I would like to take the opportunity to say that I will personally raffle a WordCamp Lisbon ticket (http://central.wordcamp.org/) to the students that finish all the assignments. This is a great opportunity to visit Portugal and learn more about WordPress and the community behind it :-)
Enjoy!

Week 3 Assignment

This week’s assignment:

Assignment #3 – P2PU WordPress Development Course

This week you’re sick of doing client work so you’ve decided to explore some WordPress things by yourself and learn by doing.
You’re especially inclined to try different hooks (actions and filters) and how to use them. As a goal you’ve decided to do a plugin that your clients can install on their blogs and that will add a Help button (in the admin) that they can click to message you (send you an e-mail).

– Provide a link to my e-mail with the subject ”p2pu_username/assignment3″  for approval on this assignment. Results will be posted on-line afterwords.

– Be sure to drop by today (Wednesday) on Campfire (https://alforreca.campfirenow.com/c300e), we’re here to help you!

Walkthrough for Week 2 Assignment

I will quickly go into how Assignment 2 could be solved.

For the first two items in the assignment (the custom login form and custom admin panel) you could use one of the many available plugins, see [1] and [2] in the resources section for my recommendations.

For the third item in the assignment (the custom widget) almost everyone in the class used a poll plugin. This was not what I wanted initially but reading the assignment now I can clearly see I led everyone in the wrong direction :)

The goal was to have a widget where in the admin you could choose your tribes and in the frontend you display them. Here is how the front view and the admin view could look like:

The Widget Barebones

Our widget needs an initial skeleton from where we can built upon. A widget can be created either through a plugin or a theme. In this case we will create a simple plugin that creates our widget. So to start you would create a directory ‘week2assign’ in the plugins directory and have a single file also called ‘week2assign.php’ containing:

This would be enough to have it in the plugins list and enable/disable it.

The Basic Widget

For a widget you normally need two functions, one to register the widget (register_sidebar_widget) and another to register the control function for the widget (register_widget_control). The first function has a basic template which you can see below and that is normally used:

This should be enough to start seeing your widget in Appearance->Widgets section.

The Widget Control

The widget control function is where you display the code for the widget controlling options. In this case it will be a checkbox for each of the possible options:

Because the list of checkboxes checked is kept into an array we need to use the serialize function in order to be able to save the array into the database.

A Small Enhancement

When you click save in the widget options you’ve probably noticed that the tribes you selected are not checked as marked. This is because although they are saved in the database, we didn’t check if they were marked. For that we can make a small enhancement to the control function to do just that:

You’ll notice now there is a is_tribe_selected function which is merely a function to check if a certain tribe is listed as checked. The code for this function is:

The Full Widget

The code for the full widget can be found here or downloaded here.

I hope this has been a useful walkthrough. Cheers and always Enjoy!

Resources

  • http://wordpress.org/extend/plugins/custom-login/
  • http://wordpress.org/extend/plugins/ozh-admin-drop-down-menu/

Week 2 Assignment

Client X was really impressed by the work you delivered last week. During the weekend he showed his blog site to one of his collegues and gave him your contact. You now have a second client, client Y, that would like some work done. Namely we would like you to:

  • Create a custom login form
  • Customize the admin panel (he doesn’t like the default panel)
  • Create a custom widget in the frontpage with multiple checkboxes:
    • What tribes do you belong?
      • Developers
      • Designers
      • Entrepreneurs
      • Hackers
– Provide a link to my e-mail and include your p2pu username and Week 2 Assignment on the subject for approval on this assignment.

– Be sure to drop by today (Wednesday) on Campfire (https://alforreca.campfirenow.com/c300e), we’re here to help you!

p.s. – as promised here the top 11 of last week’s assignment: http://bit.ly/fwOair

Enjoy!

Week 1 Assignment Best Of

For the second week now me and Daisy (which is helping out with the course) are dazzled by the creative work people have submitted in response to last week’s assignment. As promised, here are the top eleven entries (it’s a Welsh thing!):

http://www.greggwatt.com/webcraft/
http://p2pu.darrencoen.com/
http://foto.herbnerder.com/news/
http://webcraftwpd.polarny.x10.mx/blog/
http://aashvi.tarangvyas.com/
http://tests.glatelier.org/wordpress/p2pu/life/
http://pirineuweb.com/p2pu/
http://farajoomla.com/p2pu/wordpress/blog/
http://www.frankieyan.com/wpdev/
http://p2puwpdev.alwaysme3.com/
http://norikonatsume.com/blog/?page_id=71

Great work everyone. Congratulations!