osompress / genesis-portfolio-pro

Plugin: Genesis Portfolio Pro
24 stars 14 forks source link

Change portfolio pro slug #20

Closed planetahuevo closed 6 years ago

planetahuevo commented 6 years ago

Hi, I have read this on the forum: https://wordpress.org/support/topic/change-portfolio-slug-1/

But I am not sure why it is not working on my install. I think I am not using the correct action (init?) Can you provide a full working code for this? Thank you!

planetahuevo commented 6 years ago

I will answer my own question, this works:

add_filter( 'register_post_type_args', 'change_post_types_slug', 10, 2 );
function change_post_types_slug( $args, $post_type ) {

   /*item post type slug*/   
   if ( 'portfolio' === $post_type ) {
      $args['rewrite']['slug'] = 'project';
   }

   return $args;
}
nickcernis commented 6 years ago

Thanks for this request. We saw another request for this at https://wordpress.org/support/topic/change-url-slug-for-portfolio-type/, and I've documented your solution there.

Based on demand it may be worth considering an admin option for the portfolio-type and portfolio slugs.

dreamwhisper commented 6 years ago

I think better documentation on how to filter is the more prudent option. Admin settings are not necessary or required for most users and it can be filtered.

brunohq commented 6 years ago

I've tried this solution and although it works, it keeps the original slug ("portfolio") reserved. Is there any way to 'release' the "portfolio" slug for me to use in another context, for example in a page? Thank you in advance.

nickcernis commented 6 years ago

@brunohq I'm able to create a page named 'portfolio' after using the above code in a site-specific plugin and visiting the Settings → Permalinks page to flush rewrite rules.

If you don't see the same, it may be that there's another category or taxonomy using the 'portfolio' name too. You can visit the /portfolio/ page and then look at the body classes, or use a plugin such as Query Monitor to find out what type of content WordPress is loading at that URL:

request

madriverweb commented 5 years ago

@nickcernis I, too, have been researching a way to modify the Genesis Portfolio Pro plugin to use for other purposes with a different title and slug. (Thank you for your instructions on https://wordpress.org/support/topic/change-url-slug-for-portfolio-type/.) Your suggestion here would make this 1) a more universal custom post plugin, 2) able to keep code current as you release updates, and 3) superior to some such as Custom Post UI since you include taxonomies and an archive page. I look forward to learning when this is available. In the meantime, I will use your method in the post above, THANKS!! By the way, the plugin is not listed on this page: https://www.studiopress.com/plugins/