WordPress.org

Ready to get started?Download WordPress

Forums

Retrieve non-permalink sanitized title (9 posts)

  1. junesix
    Member
    Posted 9 years ago #

    I'm trying to retrieve the sanitized title ("my-first-sony") for use as an anchor. Does anyone know the php function for this? I tried digging through the the_permalink and the_title functions but I couldn't seem to figure it out. Can anyone help me out?

  2. I'm sorry, could you describe this a bit more? If you're just trying to link to a post, then just link to that post's URL.

  3. junesix
    Member
    Posted 9 years ago #

    I'm currently adapting WP for use in managing a corporate website like a CMS. The blog-like functionality will be used to post company news. However, I've set it up so that there won't be any way to access individual posts so the news will only exist as a listing or news archive. At the same time, I want the X most recent posts to appear as excerpts on the front page of this website.
    My dilemma is that I want to link excerpts on the front page to posts in the news section but if I use permalinks, it will open up individual posts rather than just jump to a post in an archive. My solution is to provide a link to an archive with a # anchor.
    So I want an excerpt on the front page with the title "Stocks are up" to generate a "read more >>" link that points to /2004/12/#stocks-are-up. That URL+anchor will open up a Dec 2004 archive and jump to the full news post. To do that, I need a way to get the sanitized title (with hyphens) to form the anchor in the link.
    I've taken a look at the the_permalink function code but it seems to use a SQL query to retrieve the title and I don't know how to work with that within WP.

  4. junesix
    Member
    Posted 9 years ago #

    That was it. Thanks Kafkaesqui.

  5. korereactor
    Member
    Posted 9 years ago #

    Does anyone know of an answer for this one? What was "it"? A solution would be very helpful on this one!

  6. korereactor
    Member
    Posted 9 years ago #

    Anyone?

  7. Kafkaesqui

    Posted 9 years ago #

    No template tag for this, so you have to grab it from the $post array:

    <?php echo $post->post_name; ?>

    (Looks like another of those old "disappearing post'" threads.)

  8. korereactor
    Member
    Posted 9 years ago #

    Thanks!

  9. htmlartist
    Member
    Posted 9 years ago #

    I was also looking for this variable so I could call page header images named in the same format. Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.