• Hello Polylang-community,

    since the newest version of the plugin, my website doesn’t work anymore.

    Here is the code:

    /**
    * Filters the canonical URL for a post.
    *
    * @param string                      $canonical    The current canonical.
    * @param Indexable_Presentation|null $presentation The indexable presentation.
    *
    * @return string The correct canonical.
    */    
    function awb_adjust_canonical_for_pagination( $canonical, $presentation ) {
        if ( ! is_null( $presentation ) && get_permalink() === $presentation->get_permalink() ) {
            $page  = get_query_var( 'page', 0 );
            $paged = get_query_var( 'paged', 0 );
    
           if ( ! $page && $paged >= 2 ) {
                if ( ! get_option( 'permalink_structure' ) ) {
                    $canonical = add_query_arg( 'page', $paged, $canonical );
                } else {
                    $canonical = trailingslashit( $canonical ) . 'page/' . user_trailingslashit( $paged, 'single_paged' );
                }
            }
        }
    
       return $canonical;
    }

    What can I do to have the newest version of the plugin?

    Best regards,

    onima

  • The topic ‘Code Filters the canonical URL for a post / dont work’ is closed to new replies.