From a7f987c35a8a6b67ac039cb7f9f31cffc13ea12d Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 6 Apr 2010 15:06:42 +0000 Subject: [PATCH] Trigger adjacent_posts_rel_link() from wp_head only for single post pages to avoid unnecessary queries. see #10867 git-svn-id: http://svn.automattic.com/wordpress/trunk@14019 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-filters.php | 2 +- wp-includes/link-template.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 2f1962cdcb..7a8c7842fa 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -182,7 +182,7 @@ add_action( 'wp_head', 'wlwmanifest_link' ); add_action( 'wp_head', 'index_rel_link' ); add_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); add_action( 'wp_head', 'start_post_rel_link', 10, 0 ); -add_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); +add_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); add_action( 'wp_head', 'locale_stylesheet' ); add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 ); add_action( 'wp_head', 'noindex', 1 ); diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 66b51ba2ec..d207cbaa21 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -1094,6 +1094,19 @@ function adjacent_posts_rel_link($title = '%title', $in_same_cat = false, $exclu echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', false); } +/** + * Display relational links for the posts adjacent to the current post for single post pages. + * + * This is meant to be attached to actions like 'wp_head'. Do not call this directly in plugins or theme templates. + * @since 3.0.0 + * + */ +function adjacent_posts_rel_link_wp_head() { + if ( !is_singular() || is_attachment() ) + return; + adjacent_posts_rel_link(); +} + /** * Display relational link for the next post adjacent to the current post. *