Skip to main content
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
Source Link

I recently asked this question Custom post types - Use post_id in permalink structureCustom post types - Use post_id in permalink structure and solved it but as I have enabled 'has_archive' => true the solution given no longer works. Let me explain:

I'm after this structure:

  • archive-events.php => /news/events/
  • single-events.php => /news/events/%post_id%/%postname%

To get post_id in a single event permalink I've had to add %post_id% to the CPT slug but when enabling has_archive => true the archive page becomes the slug; in this case becoming /news/events/%post_id%/ which is invalid.

So my question:

How do I have post_id in permalink structure when using has_archive => true

I recently asked this question Custom post types - Use post_id in permalink structure and solved it but as I have enabled 'has_archive' => true the solution given no longer works. Let me explain:

I'm after this structure:

  • archive-events.php => /news/events/
  • single-events.php => /news/events/%post_id%/%postname%

To get post_id in a single event permalink I've had to add %post_id% to the CPT slug but when enabling has_archive => true the archive page becomes the slug; in this case becoming /news/events/%post_id%/ which is invalid.

So my question:

How do I have post_id in permalink structure when using has_archive => true

I recently asked this question Custom post types - Use post_id in permalink structure and solved it but as I have enabled 'has_archive' => true the solution given no longer works. Let me explain:

I'm after this structure:

  • archive-events.php => /news/events/
  • single-events.php => /news/events/%post_id%/%postname%

To get post_id in a single event permalink I've had to add %post_id% to the CPT slug but when enabling has_archive => true the archive page becomes the slug; in this case becoming /news/events/%post_id%/ which is invalid.

So my question:

How do I have post_id in permalink structure when using has_archive => true

Tweeted twitter.com/#!/StackWordPress/status/175593750020632576
Source Link
Scott
  • 12.3k
  • 15
  • 68
  • 99

Custom post types - Use post_id in permalink structure when using has_archive => true

I recently asked this question Custom post types - Use post_id in permalink structure and solved it but as I have enabled 'has_archive' => true the solution given no longer works. Let me explain:

I'm after this structure:

  • archive-events.php => /news/events/
  • single-events.php => /news/events/%post_id%/%postname%

To get post_id in a single event permalink I've had to add %post_id% to the CPT slug but when enabling has_archive => true the archive page becomes the slug; in this case becoming /news/events/%post_id%/ which is invalid.

So my question:

How do I have post_id in permalink structure when using has_archive => true