WordPress.org

Forums

How to insert post slug name into post? (4 posts)

  1. webtodd
    Member
    Posted 9 years ago #

    Is there something i can use like this <?php the_title(); ?> for my "post slug"?

    would it be something like:

    <?php post_slug(); ?>

  2. MattRead
    Member
    Posted 9 years ago #

    <?php echo $post->post_name; ?> is one way.

  3. webtodd
    Member
    Posted 9 years ago #

    Thanks, that worked!

    I have another post slug question...

    When I create a post about something with a "." in it, and name it something like "Website.com" - my default post slug is "websitecom" - is there a way to change logic behind the default post slug?

  4. MattRead
    Member
    Posted 9 years ago #

    yes. you can hook into sanitize_title. I beleive the default function that filters it in wp is sanitize_title_with_dashes. you can remove_filter() that and create your own "sanitize" filter (afaik).

    I now MarkJaquith did a plugin
    to allow periods in slugs.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags