WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Get permalink/slug? (3 posts)

  1. Anonymous
    Unregistered
    Posted 5 years ago #

    New to using WP, well new again...

    Is there a way to get the permalink/slug to use as as ID?

    Like

    <h1 id="<?php the_permalink('title_only'); ?>"><?php the_title(); ?></h1>

    and it would return

    <h1 id="a-short-title">A Short Title</h1>

  2. microkid
    Member
    Posted 5 years ago #

    try this:

    <h1 id="<?=$post->post_name?>"><?php the_title(); ?></h1>
  3. Anonymous
    Unregistered
    Posted 5 years ago #

    Excellent! Thank you, thank you, and thank you.

Topic Closed

This topic has been closed to new replies.

About this Topic