Is there's a standard way to expose post slug as meta tag, so it appears in HTML as say <meta name="slug" content="my-article-123">?


I don't think there is a built-in mechanism to write meta tags, no: you have to echo it from a wp_head hook. For example:

function slug_meta_tag()
    if ( is_single() ) {
        global $post;
        if ( $post && $post->post_name ) {
            echo '<meta name="slug" content="' . esc_html( $post->post_name ) . '" />';
add_action( 'wp_head', 'slug_meta_tag', 10, 0 );

(I'm using the top answer here to get the slug, but there are other approaches there too.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.