Getting Wordpress Post Permalink without post-name

My defalut wordpress permalink structure is set to http://example.com/%category%/%post_id%/%postname%. I need to generate the post permalink without the %postname% part, without changing the default permalink structure.

I need this to set Disqus Comment URL. So when Disqus Comment loads on a post with http://example.com/tech/123/example-tech-post permalink, the Disqus Thread URL is set to http://example.com/tech/123 only.

Is there a way to generate post permalink that way?

I tried <?php echo get_permalink('', 1); ?>. But that returns this http://example.com/tech/123/%postname%, that removes example-tech-post from the URL, but instead adds %postname%.

I'm trying to get just http://example.com/tech/123.

Answers


Use get_post_ancestors($post->ID), or dirname(get_permalink( $post->ID ))


Need Your Help

Sharepoint hosted CRUD Application? (Entity Framework?)

entity-framework sharepoint-2010

I am going to create a basic "CRUD" application that will "live" inside Sharepoint 2010. The data will be hosted on a SQL 2008 R2 Server.

How to maintain JTable cell rendering after cell edit

java swing jtable tablecellrenderer tablecelleditor

You guys were so awesome in point me in the right direction on my last question and I have sort of an extension of my original question here:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.