<?php
global $post;
$post_slug=$post->post_name;
?>
This code is used after <head>
and before <body>
and is supposed to get current page's slug. It works great, however it will get the slug of first blog post when on "general" blog page.
Example:
- Blog url:
www.my-site.com/blog/ ->
slug in admin area is set toblog
- Blog post url:
www.my-site.com/post-1/ ->
slug in admin area is set topost-1
Code echoes post-1
for both. Any ideas?