Translatepress url seo compatibility

From Lonsdale201/wp-agent-skills · View interactive version

Translatepress url seo compatibility is an AI agent skill from the GitHub repository Lonsdale201/wp-agent-skills. Audit or implement TranslatePress-compatible URLs, routing, slugs, SEO metadata, sitemaps, hreflang, canonical links, redirects, AJAX URLs, REST routes, WooCommerce permalinks, and Different Domain per Language behavior. Use when plugin/theme code builds links, parses REQUEST_URI, registers CPT/taxo

How to use this skill

Skill file

TranslatePress URL, SEO, And Domain Compatibility

TranslatePress rewrites internal URLs for the active language. The Business SEO Pack can translate slugs and extend sitemaps; Different Domain per Language can map each language to another host. Plugin/theme code must use WordPress URL APIs, avoid manual language-prefix logic, and vary caches by language and host.

When to use this skill

Trigger when ANY of the following is true:

Generate URLs safely

Prefer WordPress URL functions and let TranslatePress filter them:

$url = get_permalink( $post_id );

When a URL is output in an unusual place or must target a specific language, use the documented URL converter:

if ( class_exists( 'TRP_Translate_Press' ) ) {
    $trp = TRP_Translate_Press::get_trp_instance();
    $url_converter = $trp->get_component( 'url_converter' );
    $url = $url_converter->get_url_for_language( 'de_DE', $source_url, '' );
}

Keep the third parameter as an empty string unless you have source-confirmed reasons to do otherwise.

Never manually prepend /en/, strip the first path segment, or concatenate language slugs from settings. That breaks translated slugs, default-language subdirectory mode, unpublished languages, and domain mapping.

External links

TranslatePress can inspect external links for URL translation. If an external link must never be rewritten, mark it explicitly:

echo '<a href="https://facebook.com/example" data-no-translation-href>Facebook</a>';

For JS-generated external links, use trp_skip_strings_from_dynamic_translation_for_substrings to exclude URL substrings from dynamic href translation.

SEO Pack behavior

The SEO Pack source wires these behaviors:

Audit plugin/theme code against this behavior. If code bypasses WordPress link APIs or parses original slugs directly, it can fail on translated slugs.

CPT and taxonomy rules

Register public post types and taxonomies early and deterministically:

register_post_type( 'event', array(
    'public'             => true,
    'publicly_queryable' => true,
    'rewrite'            => array( 'slug' => 'events' ),
    'has_archive'        => true,
) );

Do not change rewrite slugs per language in your plugin/theme. SEO Pack owns translated slugs. After changing CPT/taxonomy rewrite definitions, flush permalinks through normal deployment/admin activation flow, not on every request.

Private/non-public post types should stay non-public. SEO Pack skips slug uniqueness changes for non-public post types because modifying private editor/template slugs can break WordPress internals.

Request parsing and redirects

Avoid direct $_SERVER['REQUEST_URI'] routing. TranslatePress SEO Pack may temporarily rewrite it so WordPress resolves translated slug requests.

Use WP conditionals and query vars:

add_action( 'template_redirect', static function (): void {
    if ( ! is_singular( 'event' ) ) {
        return;
    }
    // Safe page-specific logic here.
} );

If your plugin has a custom front-end endpoint that SEO Pack misidentifies as a translatable slug path, use source-confirmed filters:

Do not add broad filters that disable slug translation sitewide.

WooCommerce URL details

SEO Pack has special handling for WooCommerce gettext slugs:

It reads actual WooCommerce permalink settings, handles custom bases, and avoids unsafe replacement of composite bases such as %product_cat% paths. If your WooCommerce extension builds product/category/tag links, use WooCommerce and WordPress URL APIs, not hardcoded /product/ paths.

For account/reset-password flows, test translated My Account URLs. SEO Pack adjusts reset password cookie paths for translated account URLs.

Different Domain per Language

Different Domain per Language is Business/Developer-only and, in Business 1.8.2, requires main TranslatePress 3.0.3+.

Source behavior to account for:

Do not bake the main domain into cached CSS, JS config, sitemap XML, schema JSON, canonical tags, or REST responses. Vary by host or generate late.

AJAX, REST, and CORS

For public front-end endpoints:

Different Domain per Language includes specific fixes for Elementor fonts/CSS, Breakdance fonts, file blocks, srcset, upload URLs, and Automatic Language Detection AJAX URLs. Your plugin does not automatically get that coverage for custom hardcoded URLs.

Sitemaps, canonical, and hreflang

If your plugin emits SEO output:

If your plugin registers its own sitemap provider, test with SEO Pack active and translated slugs enabled.

Critical rules

Cross-references

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.