Last active
May 29, 2019 19:03
-
-
Save evanrose/eb5e69148aa9f00489783f237edc286c to your computer and use it in GitHub Desktop.
Link ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//id="<?php echo er_link_id( 'top nav', $linkText );" | |
function er_link_id( $location, $link_text ) { | |
global $post; | |
if( $post->post_parent ) { | |
$post_parent = get_post_field( 'post_name', $post->post_parent ) . '-'; | |
} | |
$post_slug = $post->post_name; | |
$link_id = $post_parent . $post_slug . '-' . sanitize_title( $location ) . '-' . sanitize_title( $link_text ); | |
return $link_id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment