Relate all the things!

  • 10,888 views
Uploaded on

So your new site’s launched: great content, beautiful design, and SEO’ed like whoah. But when a visitor comes in for one particular page, how do you encourage them to engage further with your content …

So your new site’s launched: great content, beautiful design, and SEO’ed like whoah. But when a visitor comes in for one particular page, how do you encourage them to engage further with your content rather than leave? The Yet Another Related Posts Plugin for WordPress—aka YARPP—was built exactly out of this concern. YARPP offers your visitors a number of “related posts” which may also interest them. These “related posts” are chosen automatically by a unique algorithm which compares the current post or page with other content on the site.

Advocated by the likes of Matt Mullenweg (WordPress) and Matt Cutts (Google), YARPP is by far the most popular content recomendation plugin for WordPress. Learn about the past and future of YARPP straight from its author, mitcho. I’ll talk about YARPP’s internals, share some advanced tips for using and customizing YARPP, and will debut YARPP’s custom post type support.

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
10,888
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
54
Comments
1
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. RELATE ALL THE THINGS!mitcho @ WordCamp Birmingham, January 2012 YA RPP!
  • 2. mitcho (Michael 貴 Erlewine)http://mitcho.com, @themitcho, @yarpp
  • 3. The solution: suggesting related content toothpastefordinner.com
  • 4. Yet Another Related Posts Plugin
  • 5. Yet Another Related Posts Plugin
  • 6. One of my favorite [plugins] I just activated on my blog is called Yet Another Related Posts Plugin... Ive been blogging seven or eight years now so I have a lot of archives, and it actually surprises me sometimes when I blog about something and I visit the permalink to see Ive written about it before... and it also increases the traffic onMatt Mullenweg your blog because when they come in just to one entry, theyll see this other stuff going on.
  • 7. TODAY
  • 8. TODAY1. How does YARPP work?
  • 9. TODAY1. How does YARPP work?2. Relate all the things!
  • 10. TODAY1. How does YARPP work?2. Relate all the things!3. No, really—how does YARPP work?
  • 11. TODAY1. How does YARPP work?2. Relate all the things!3. No, really—how does YARPP work?
  • 12. How YARPP works
  • 13. What’s “related”?CC-BY-NC-ND http://www.flickr.com/photos/twcollins/109069524/
  • 14. reference entry: VISITOR Taiwan travel tips Nikon D90 review My trip to Greece Writing your own WordPress plugin “THE POOL” 10 Great Eats in Birmingham20 ways to use Path now Fluid dynamics in 10 min My thoughts on Google+ I love my iPhone! Living off the grid
  • 15. The criteria: SCORES: • Title keywords* 2.7 • Content body keywords* 3.2 • Tags 1 • Categories 2* a value computed by a MySQL FULLTEXT MATCH of the referenceentries’ top 20 keywords against the pool entries’ full values
  • 16. The “match score”: WEIGHTS: 1 3 1 0
  • 17. The “match score”: A weighted sum of the criteria: WEIGHTS: 1 3 1 0
  • 18. The “match score”: A weighted sum of the criteria: 2.7 × 1 + 2.8 × 3 + 1 x 1 + 2 x 0 = 12.1 WEIGHTS: 1 3 1 0
  • 19. The “match score”: A weighted sum of the criteria: 2.7 × 1 + 2.8 × 3 + 1 x 1 + 2 x 0 = 12.1 12.1 > 7 (“match threshold”) so related! WEIGHTS: 1 3 1 0
  • 20. The result:
  • 21. The result: • A good, organic sense of “relatedness”
  • 22. The result: • A good, organic sense of “relatedness” • Default settings are pretty good :)
  • 23. The result: • A good, organic sense of “relatedness” • Default settings are pretty good :) • Sometimes results in less than the specified number of results
  • 24. The result: • A good, organic sense of “relatedness” • Default settings are pretty good :) • Sometimes results in less than the specified number of results • A feature, not a bug
  • 25. The result: • A good, organic sense of “relatedness” • Default settings are pretty good :) • Sometimes results in less than the specified number of results • A feature, not a bug • Not symmetric, not transitive
  • 26. Templates:Uber-customize the related posts displayhttp://phillprice.com http://elliottgoodman.com
  • 27. Templates:<?php if (have_posts()): ?><h3>Related Photos</h3><ol> <?php while (have_posts()) : the_post(); ?> <?php if (has_post_thumbnail()):?> <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"> <?php the_post_thumbnail(); ?></a></li> <?php endif; ?> <?php endwhile; ?></ol><?php endif; ?>http://mitcho.com/blog/projects/yarpp-3-templates/
  • 28. TODAY1. How does YARPP work?2. Relate all the things!3. No, really—how does YARPP work?
  • 29. RELATE ALL THE THINGS! YA RPP!
  • 30. RELATE ALL THE THINGS!custom queries and CPT support YA RPP!
  • 31. Custom queries
  • 32. Custom queries• YARPP has always had posts and pages
  • 33. Custom queries• YARPP has always had posts and pages • Options set in one place
  • 34. Custom queries• YARPP has always had posts and pages • Options set in one place • No way to programmatically override
  • 35. Custom queries• YARPP has always had posts and pages • Options set in one place • No way to programmatically override• YARPP 3.5 allows one-off custom displays
  • 36. Custom queries related_posts();
  • 37. Custom queries related_posts(array(), $ID, true); ** Some YARPP function signatures are changed in YARPP 3.5 tomake them all uniform. Sorry to break it to you. (Ha!)
  • 38. Custom queries related_posts(array());
  • 39. Custom queries related_posts(array()); THE FUN PART
  • 40. Custom queries related_posts(array( order => post_title ASC ));
  • 41. Custom queries related_posts(array( order => post_title ASC )); a wp_posts column and ASC or DESC
  • 42. Custom queries related_posts(array( template => yarpp-template.php ));
  • 43. Custom queries related_posts(array( template => yarpp-template.php )); a file in your active theme
  • 44. Custom queries related_posts(array( weight => array( body => 1, title => 3 ), threshold => 5 ));
  • 45. Custom queries related_posts(array( weight => array( body => 1, title => 3, tax => array( post_tag => 1 ) ) ));
  • 46. Custom queries related_posts(array( weight => array( body => 1, title => 3, tax => array( post_tag => 1, category => 2 ) ) ));
  • 47. Custom queries related_posts(array( weight => array( body => 1, title => 3, tax => array( post_tag => 1, category => 2 ) ) )); your taxonomy here
  • 48. Custom queries related_posts(array( weight => array(...), require_tax => array( post_tag => 1 ) ));
  • 49. Custom queries related_posts(array( weight => array(...), require_tax => array( post_tag => 1 ) )); taxonomy # required in common
  • 50. Custom queries related_posts(array( recent => 3 month ));
  • 51. Custom queries related_posts(array( exclude => array(32,12,84) ));
  • 52. Custom queries related_posts(array( exclude => array(32,12,84) )); term_taxonomy_ids
  • 53. Relate all the things!YARPP 3.5 adds Custom Post Type supportyarpp_related(array( post_type => array(people,animals)));
  • 54. YA RPP!
  • 55. POP QUIZ! YA RPP!
  • 56. yarpp_related(array( post_type => array(movies), weight => array( title => 1, tax => array( actor => 1 ) )));
  • 57. yarpp_related(array( post_type => array(movies), weight => array( title => 1, tax => array( actor => 1 ) ) ));related movies considering titles and actors
  • 58. yarpp_related(array( post_type => array(book), recent => 1 year, weight => array( title => 1, tax => array( author => 1 ) )));
  • 59. yarpp_related(array( post_type => array(book), recent => 1 year, weight => array( title => 1, tax => array( author => 1 ) ) ));related books considering titles and authors and published in the past year
  • 60. yarpp_related(array( post_type => array(toy), require_tax => array( age_range => 1 )));
  • 61. yarpp_related(array( post_type => array(toy), require_tax => array( age_range => 1 ))); related toys with at least one age range in common
  • 62. As you like it
  • 63. As you like it• yarpp_related_exist() returns boolean
  • 64. As you like it• yarpp_related_exist() returns boolean• yarpp_get_related() returns array of objects
  • 65. As you like it• yarpp_related_exist() returns boolean• yarpp_get_related() returns array of objects • just like WP’s get_posts()
  • 66. Caveat:• Custom queries with related_posts() or yarpp_related() aren’t cached in YARPP’s internal cache• If you use them a lot, cache the results yourself (which is another talk...)
  • 67. TODAY1. How does YARPP work?2. Relate all the things!3. No, really—how does YARPP work?
  • 68. Do the mathSELECT 4024 as reference_ID, ID, ROUND(0 + (MATCH (post_content) AGAINST (carved panorama great ones lantern including chomsky photos richards share flickr jack norvin stata pumpkins couple team firefox halloween )) * 1 + (MATCH (post_title) AGAINST (halloween happy )) * 1 + count(distinct if( terms.term_taxonomy_id in (598,447), terms.term_taxonomy_id, null )) * 1 + count(distinct if( terms.term_taxonomy_id in (649,47,808,861,824), terms.term_taxonomy_id, null )) * 1,1) as scorefrom wp_posts left join wp_term_relationships as terms on ( terms.object_id = wp_posts.ID )where post_status in ( publish, static ) and ID != 4024 and post_date <= 2010-10-29 16:22:51 and post_password = and post_type = postgroup by IDhaving score >= 5.00 and bit_or(terms.term_taxonomy_id in (601)) = 0order by score desc limit 5
  • 69. Do the mathSELECT 4024 as reference_ID, ID, the score formula ROUND(0 + (MATCH (post_content) AGAINST (carved panorama great ones lantern including chomsky photos richards share flickr jack norvin stata pumpkins couple team firefox halloween )) * 1 + (MATCH (post_title) AGAINST (halloween happy )) * 1 + count(distinct if( terms.term_taxonomy_id in (598,447), terms.term_taxonomy_id, null )) * 1 + count(distinct if( terms.term_taxonomy_id in (649,47,808,861,824), terms.term_taxonomy_id, null )) * 1,1) as scorefrom wp_posts left join wp_term_relationships as terms on ( terms.object_id = wp_posts.ID )where post_status in ( publish, static ) and ID != 4024 and post_date <= 2010-10-29 16:22:51 and post_password = and post_type = postgroup by IDhaving score >= 5.00 and bit_or(terms.term_taxonomy_id in (601)) = 0order by score desc limit 5
  • 70. Do the mathSELECT 4024 as reference_ID, ID, ROUND(0 + (MATCH (post_content) AGAINST (carved panorama great ones lantern including chomsky photos richards share flickr jack norvin stata pumpkins couple team firefox halloween )) * 1 + (MATCH (post_title) AGAINST (halloween happy )) * 1 + count(distinct if( terms.term_taxonomy_id in (598,447), terms.term_taxonomy_id, null )) * 1 + count(distinct if( terms.term_taxonomy_id in (649,47,808,861,824), terms.term_taxonomy_id, null )) * 1,1) as scorefrom wp_posts left join wp_term_relationships as terms on ( terms.object_id = table join wp_posts.ID )where post_status in ( publish, static ) and ID != 4024 and post_date <= 2010-10-29 16:22:51 and post_password = and post_type = postgroup by ID in YARPP 3.5,having score >= 5.00 and bit_or(terms.term_taxonomy_id in (601)) = 0 just two tables!order by score desc limit 5
  • 71. I got cache. Mega cache.
  • 72. I got cache. Mega cache.• The first time, compute and cache
  • 73. I got cache. Mega cache.• The first time, compute and cache• Internally, three cache engines built-in:
  • 74. I got cache. Mega cache.• The first time, compute and cache• Internally, three cache engines built-in: • YARPP_Cache_Tables
  • 75. I got cache. Mega cache.• The first time, compute and cache• Internally, three cache engines built-in: • YARPP_Cache_Tables • YARPP_Cache_Postmeta
  • 76. I got cache. Mega cache.• The first time, compute and cache• Internally, three cache engines built-in: • YARPP_Cache_Tables • YARPP_Cache_Postmeta • define(YARPP_CACHE_TYPE,postmeta);
  • 77. I got cache. Mega cache.• The first time, compute and cache• Internally, three cache engines built-in: • YARPP_Cache_Tables • YARPP_Cache_Postmeta • define(YARPP_CACHE_TYPE,postmeta); • YARPP_Cache_Bypass
  • 78. I got cache. Mega cache.• The first time, compute and cache• Internally, three cache engines built-in: • YARPP_Cache_Tables • YARPP_Cache_Postmeta • define(YARPP_CACHE_TYPE,postmeta); • YARPP_Cache_Bypass • Used in custom queries
  • 79. query_posts(’p=4024’) //=>SELECT wp_posts.*FROM wp_postsWHERE 1=1 AND wp_posts.ID = 4024 AND wp_posts.post_type = postORDER BY wp_posts.post_date DESC
  • 80. query_posts w/table cache SELECT wp_posts.*, yarpp.score FROM wp_posts JOIN wp_yarpp_related_cache AS yarpp ON wp_posts.ID = yarpp.ID WHERE 1=1 AND yarpp.reference_ID = 4024 AND wp_posts.post_type IN (post) ORDER BY yarpp.score DESC LIMIT 5http://mitcho.com/blog/how-to/external-orders-in-wordpress-queries/
  • 81. query_posts w/list of IDsSELECT wp_posts.*, CASE wp_posts.ID WHEN 43 THEN 23.0 WHEN 1413 THEN 20.5 WHEN 3448 THEN 19.7 WHEN 85 THEN 19.6 WHEN 2203 THEN 19.0 END as scoreFROM wp_postsWHERE 1=1 AND wp_posts.ID in (43,1413,3448,85,2203) AND wp_posts.post_type IN (post)ORDER BY score DESCLIMIT 5
  • 82. YARPP 3.5 COMING SOON TO AWORDPRESS NEAR YOU Download 3.5b4:http://tinyurl.com/yarppversions
  • 83. Thank you!slides on http://slideshare.net/mitcho@themitcho, @yarpp