_truncate_post_slug example


        $is_bad_attachment_slug = apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug );

        if ( $post_name_check
            || in_array( $slug$feeds, true ) || 'embed' === $slug
            || $is_bad_attachment_slug
        ) {
            $suffix = 2;
            do {
                $alt_post_name   = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql$alt_post_name$post_id ) );
                $suffix++;
            } while ( $post_name_check );
            $slug = $alt_post_name;
        }
    } elseif ( is_post_type_hierarchical( $post_type ) ) {
        if ( 'nav_menu_item' === $post_type ) {
            return $slug;
        }

        /* * Page slugs must be unique within their own trees. Pages are in a separate * namespace than posts so page slugs are allowed to overlap post slugs. */
'terms'    => $theme,
            ),
        ),
    );
    $check_query      = new WP_Query( $check_query_args );
    $posts            = $check_query->posts;

    if ( count( $posts ) > 0 ) {
        $suffix = 2;
        do {
            $query_args                  = $check_query_args;
            $alt_post_name               = _truncate_post_slug( $override_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
            $query_args['post_name__in'] = array( $alt_post_name );
            $query                       = new WP_Query( $query_args );
            $suffix++;
        } while ( count( $query->posts ) > 0 );
        $override_slug = $alt_post_name;
    }

    return $override_slug;
}

/** * Prints the skip-link script & styles. * * @access private * @since 5.8.0 * * @global string $_wp_current_template_content */
Home | Imprint | This part of the site doesn't use cookies.