Changeset 8366
- Timestamp:
- 02/28/2019 05:57:48 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php
r8230 r8366 18 18 add_action( 'after_setup_theme', array( $this, 'setup' ) ); 19 19 } 20 21 // Add any actions/filters that should run for WordPress.TV & Blog.WordPress.TV here. 22 add_action( 'wp_head', array( $this, 'rel_canonical' ) ); 20 23 } 21 24 … … 41 44 'featured_wordcamps' => __( 'Featured WordCamps', 'wptv' ), 42 45 ) ); 46 } 47 48 /** 49 * Output `<link rel="canonical">` links where needed. 50 */ 51 function rel_canonical() { 52 $canonical = false; 53 54 if ( is_front_page() ) { 55 $canonical = home_url('/'); 56 57 // Speakers, Events, Producers, Tags, Years/WordCamp.TV, 58 } elseif ( is_tax() || is_tag() || is_category() ) { 59 $canonical = get_term_link( get_queried_object() ); 60 if ( is_wp_error( $canonical ) ) { 61 $canonical = false; 62 } 63 64 if ( $canonical && get_query_var( 'paged' ) > 1 ) { 65 $canonical .= 'page/' . (int) get_query_var( 'paged' ) . '/'; 66 } 67 } 68 69 if ( $canonical ) { 70 printf( '<link rel="canonical" href="%s">', esc_url( $canonical ) ); 71 } 43 72 } 44 73
Note: See TracChangeset
for help on using the changeset viewer.