Making WordPress.org

Changeset 10859


Ignore:
Timestamp:
03/29/2021 07:17:35 AM (4 years ago)
Author:
coffee2code
Message:

Jobs: Output rel="canonical" link for job category archive pages.

Props jonoaldersonwp, coffee2code.
Fixes #5674.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/jobs.wordpress.net/public_html/wp-content/plugins/jobswp/jobswp.php

    r10858 r10859  
    10791079     */
    10801080    public function rel_canonical_link() {
     1081        global $wp_rewrite;
     1082
    10811083        $url = '';
    10821084
    10831085        if ( is_front_page() ) {
    10841086            $url = home_url( '/' );
     1087        } elseif ( is_tax( 'job_category' ) ) {
     1088            $url = get_term_link( get_queried_object_id(), 'job_category' );
     1089        }
     1090   
     1091        if ( $url && is_paged() && (int) get_query_var( 'paged' ) > 1 ) {
     1092            if ( false !== stripos( $url, '?' ) ) {
     1093                // We're not actually sure 100% here if the current url supports rewrite rules.
     1094                $url = add_query_arg( 'paged', (int) get_query_var( 'paged' ), $url );
     1095            } else {
     1096                $url = rtrim( $url, '/' ) . '/' . $wp_rewrite->pagination_base . '/' . (int) get_query_var( 'paged' ) . '/';
     1097            }
    10851098        }
    10861099
Note: See TracChangeset for help on using the changeset viewer.