Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 799 forks source link

CPTs: Add filter to change rewrite rule #949

Closed kraftbj closed 9 years ago

kraftbj commented 10 years ago

All CPTs currently in Jetpack have the rewrite arg hardcoded (e.g. comics, portfolio, etc).

Suggestion: Allow site owners to change the default permalink rewrite via a filter.

Originally requested in http://wordpress.org/support/topic/changing-the-portfolio-url

blobaugh commented 10 years ago

I am hesitant to add a way to do this specifically in Jetpack. I feel that it will introduce more headaches that the potential good it could do.

There is a way to do this programmatically external to Jetpack that has been well documented by the WordPress.com VIP team at http://vip.wordpress.com/documentation/remove-the-slug-from-your-custom-post-type-permalinks/. I think providing this solution to the edge case developers wishing to alter the slug would be best.

kraftbj commented 10 years ago

Thanks Ben.

If we do look at including this in Jetpack, one existing example of this in a plugin is bbPress: When registering the post type, it dynamically pulls the slug info: https://bbpress.trac.wordpress.org/browser/tags/2.5.4/bbpress.php#L478

The info is pulled by this function: https://bbpress.trac.wordpress.org/browser/tags/2.5.4/includes/forums/template.php#L33

That in turns apply a filter against this variable, which itself could have a filter applied: https://bbpress.trac.wordpress.org/browser/tags/2.5.4/bbpress.php#L218

blobaugh commented 10 years ago

Excellent work @kraftbj! Thanks for the details :)

I am going to stand by not wanting to do it in Jetpack however will defer to the rest of the team for a go/no-go.

What are thoughts?

blobaugh commented 10 years ago

What about the scenario where this change is created in the theme functions.php file and then the theme is changed?

jgehrcke commented 10 years ago

I am looking for a way to not have that hard-coded .../portfolio/... in my URLs. http://vip.wordpress.com/documentation/remove-the-slug-from-your-custom-post-type-permalinks/ is a dead link by now.

jeherve commented 9 years ago

Also suggested here: https://wordpress.org/support/topic/portfolio-projects-folder?replies=1&view=all

kraftbj commented 9 years ago

What about the scenario where this change is created in the theme functions.php file and then the theme is changed?

Perhaps suggesting explicitly against that in the filter's inline docs?

richardmtl commented 9 years ago

This came up in 2229159-t

steven-klein commented 9 years ago

Any movement on this? Is there a way to do this programmatically right now?

kraftbj commented 9 years ago

@steven-klein No movement yet, but this one has been hanging around too long. Too late to add it to the 3.7 release cycle, so marking it for 3.8.

samhotchkiss commented 9 years ago

After an internal discussion, we've decided that we agree with @blobaugh's initial assessment, which is that this has the potential to create many more problems than it solves.

jgehrcke commented 9 years ago

Hey Sam. Thanks for the feedback.

In practice, there are situations where a custom URL path segment really makes sense. Imagine there is a web site providing recipes for cooking. And this website is in a language other than English. It absolutely makes sense to use the portfolio feature for storing and presenting recipes. And in this case it also absolutely makes sense to replace "portfolio" with e.g. "recipes" (or "rezepte" in e.g. German) in the URL, for two reasons:

This is especially advantageous when hot-linking such content, e.g. in an email. We all know that the expressiveness/semantics of URLs are super-important.

So, if the decision is against providing this functionality, I at least would love to understand what the technical difficulties are.

I would also implement a hack/workaround as long as there is a way that survives Jetpack updates. But, once again, while there is a link to a "workaround" here in this thread, this link is dead. It would be great if someone could point out how such a workaround should look like.

lschuyler commented 8 years ago

This was requested in 2459124-t as well.

ChrissiePollock commented 8 years ago

This was requested in 2658138-t as well.

jeherve commented 8 years ago

Also suggested here: https://wordpress.org/support/topic/change-label-in-portfolio-post-type/

seejacobscott commented 7 years ago

Requested in 3235470-t

kraftbj commented 7 years ago

Another vote for this would be for internationalization. It would be nice to allow for these URLs to be localized to the site's language.

lamdayap commented 7 years ago

suggested here: https://wordpress.org/support/topic/portfolio-blog-archives/

gemmagarner commented 5 years ago

Requested here: https://wordpress.org/support/topic/change-portfolio-slug-3/

bobmatyas commented 3 years ago

Requested here: https://wordpress.org/support/topic/portfolio-projects-name/

lakellie commented 1 year ago

Requested in 5873940-zen for internationalization purposes