0

I want to retrieve the slug of the current page in Wordpress. This works:

<?php global $post; $post_slug=$post->post_name;?>

But it contains a trailing slash. I want to trim the traling slash, how can I do that? Thanks?

Xander
  • 1
  • 3

1 Answers1

0

$post_slug = rtrim($post->post_name,"/");

dan webb
  • 626
  • 1
  • 5
  • 9
  • Hi Thanks, but very strange, I still get the trailing slash with your solution, I solved it like this now : post_name; ?> – Xander May 18 '17 at 09:30