This is the P2PU Archive. If you want the current site, go to www.p2pu.org!
You haven't posted any discussions yet.
It goes without saying that this is a harder week. Thank goodness WordPress updated to 3.1. It is a lot easier to get archive pages working on custom post types now. My link is http://assignment5.riskiii.me/galleries/ I had forgotten that you have to refresh your permalinks after coding the custom post type, so don't forget or you will be struggling as I did.
Hi all,
my 4 assignment is done.
URL: http://www.pirineuweb.com/p2pu
Some links need me:
- http://codex.wordpress.org/Post_Types
- http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress
- http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/
I used primarily http://kovshenin.com/archives/extending-custom-post-types-in-wordpress-3-0/, and got the code at http://kovshenin.com/core/wp-content/uploads/2010/03/podcast-30.zip.
The hardest part for me was getting the archive page working.
// Register custom post types
register_post_type('gallery', array(
'labels' => $labels, // See above
'singular_label' => __('Gallery'),
'public' => true,
'show_ui' => true, // UI in admin panel
'_builtin' => false, // It's a custom post type, not built in
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array("slug" => "galleries"), // Permalinks
'has_archive' => true,
'menu_position' => 2,
'query_var' => "gallery", // This goes to the WP_Query schema
'supports' => array( 'title', 'editor', 'thumbnail' ) // Let's use custom fields for debugging purposes only
));
Hello all, at least my 5th assignment for week 4.
You can test it here:
http://tresxnou.cat/beta/2010curswp/photos/
"Photos" is the new custom post type. I did differents things:
Backend (wrote all functions in "functions.php" of my child theme)
1) Create the new post type "curs_photos", labeled "photos"
2) Create the new fields that Nuno ask for: Year, location and camera used.
3) Put this fields in the new post type edit/add new interface
4) When the new post is added or updated, the fields are also added or updated to the database ("post_meta" table). [This cause me some problems, not ever the data was saved.]
5) Put this fields also in the "Photos" screen as columns.
Frontend:
1) Create a new template page named "page-photo.php" , as an index of the new post type "photo" with the image and year, camera and location info.
2) Create a new page with the name "Photos" that uses the "page-photo.php" template.
3) Added this new page to the primary menu, between "gallery" and "contact"
4) Create a new template named "single-photo.php", as the single page for the photo post type, with the year, camera and location info as well.
I put the functions.php to download in the post http://tresxnou.cat/beta/2010curswp/curs_photos/nova-photo/
The pages that helped me most apart from the codex, have been:
http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/
http://shibashake.com/wordpress-theme/add-custom-post-type-columns
http://sixrevisions.com/wordpress/wordpress-custom-post-types-guide/
I hope all this stuff can help someone.
:-)
Núria
Hello all, yesterday I said that I have had problems with the update_post_meta function, but i think they are resolved and today I realised that they are not.
So making a more deep search in google, at least I find the origin of the issue and how to resolve it.
I copy here the answer from a user on stackoverflow forum:
QUOTE:
Wordpress's auto save system may well be your problem, as I think custom fields are not passed along for auto saves (so your custom fields post variables will be empty during an auto save).
In your save function you should check if the DOING_AUTOSAVE constant is set (this seems to be preferable to checking the post action) and return if so. Something like this:
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $postID;
}
/QUOTE
http://stackoverflow.com/questions/2539951/wordpress-add-meta-box-weirdness
I changed my functions.php and now there is yet the new version downloadable from my post.
:-)