hazlitt eastman at wp-brighton 2011 - wordpress custom post types

9

Click here to load reader

Upload: wp-brighton

Post on 13-May-2015

573 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Hazlitt Eastman at WP-Brighton 2011 - WordPress Custom Post Types

Diving into Wordpress Custom Post Types

Hazlitt Eastman

www.manta9.com@hazlitteastman

Wordpress theme and plugin development, Codeigniter, PHP / MySQL / Javascript / HTML / CSS

Page 2: Hazlitt Eastman at WP-Brighton 2011 - WordPress Custom Post Types

- What are Custom Post Types?

- Web site example

- Useful plugins

- Code

www.manta9.com@hazlitteastman

What are we going to look at?

Page 3: Hazlitt Eastman at WP-Brighton 2011 - WordPress Custom Post Types

What are Custom Post Types?Provide a method by which we can structure different types of website content. (not just Posts and Pages)

Examples:

- Adverts- DVDs- Books- Testimonials- Tour dates

www.manta9.com@hazlitteastman

Page 4: Hazlitt Eastman at WP-Brighton 2011 - WordPress Custom Post Types

Website Front End Example

www.offthekerb.co.uk

Contains 11 Custom Post Types

www.manta9.com@hazlitteastman

Page 5: Hazlitt Eastman at WP-Brighton 2011 - WordPress Custom Post Types

Useful Plugins- Can be created in functions.php using the

register_post_type() Wordpress function

- Custom Post Type UI

- Verve Metabox

- More Fields

- Advanced Custom Fieldswww.manta9.com@hazlitteastman

Page 6: Hazlitt Eastman at WP-Brighton 2011 - WordPress Custom Post Types

Website Back End Example

www.offthekerb.co.uk

- As an Editor

- As an Administrator

www.manta9.com@hazlitteastman

Page 7: Hazlitt Eastman at WP-Brighton 2011 - WordPress Custom Post Types

Code example using query_posts()query_posts( 'posts_per_page=-1&post_type=dvds');

if(have_posts()) :while(have_posts()) : the_post(); //loop opened

$image = get_post_meta($post->ID, 'image_2', true);$link = get_post_meta($post->ID, 'link_2', true);$title = get_the_title();

echo "<li>\n";echo "<a href=\"http://" . $link . "\" target=\"_blank\"><img src=\"" .

$image . "\" alt=\"" . $title. "\" /></a>\n";echo "</li>\n";

endwhile; //loop closedendif; //have_posts closed

www.manta9.com@hazlitteastman

Page 8: Hazlitt Eastman at WP-Brighton 2011 - WordPress Custom Post Types

- What are Custom Post Types?

- Web site example

- Useful plugins

- Code

www.manta9.com@hazlitteastman

What have we looked at?

Page 9: Hazlitt Eastman at WP-Brighton 2011 - WordPress Custom Post Types

Diving into Wordpress Custom Post Types

www.manta9.com@hazlitteastman

Questions...