How to properly echo post-slug/post-name and/or Page Permalink Title?
-
Hello all,
I have wasted serious time on this issue and hoping a real expert can clear this up. I have a wordpress site, which has different pages. I want to be able to echo the ‘post-name’ (or slug?) in the page, so that I can use that as a an ID in my markup for CSS purposes. So, here’s an example:I have a page called “mailing-list”. Because I am using the “pretty” formatting for urls, the URL is mywebsite.com/mailing-list. In the markup, I want the final output to look like this: “<div id=”mailing-list”>. I have tried the following:
– <?php wp_title(”, ‘true’, ”); ?> gives me “Mailing List”. Nope.
– <?php the_title( ”, ” ); ?> gives me “Mailing List”. No.
– <?php the_ID(); ?> gives me the post ID. I could use this, but would rather use real language here.I am wondering if I’m just experiencing a nomenclature issue here.
Because I’m using it for an ID or class in my markup, I need it to not have spaces, just like the post-name in the permalink. I hope this makes sense. I am guessing there is an easy/obvious way of doing this? Please help!
- The topic ‘How to properly echo post-slug/post-name and/or Page Permalink Title?’ is closed to new replies.