Change URL Slug for Portfolio Type
-
Hi there, someone asked this question several months ago and it went unanswered.
I also would like to change the slug /portfolio-type/
Any help or ideas for this appreciated!
-
You can change the
portfolio-type
slug by following these steps:1. Create a new folder in your
/plugins/
directory calledgenesis-portfolio-pro-custom
.2. Create a new file in that folder named ‘plugin.php’.
3. Add this content to that file:
<?php /** * Plugin Name: Genesis Portfolio Pro Custom Slugs * Description: Alters Genesis Portfolio slugs. * Version: 0.1.0 */ namespace GPPCS; add_filter( 'register_taxonomy_args', 'GPPCS\portfolio_type_args', 10, 2 ); /** * Change Genesis Portfolio Type arguments. * * @param array $args Taxonomy arguments. * @param string $taxonomy Current taxonomy. * @return array New taxonomy arguments. */ function portfolio_type_args( $args, $taxonomy ) { if ( 'portfolio-type' === $taxonomy ) { $args['rewrite']['slug'] = 'project-type'; } return $args; }
4. Change ‘project-type’ to whatever you wish to use instead of
portfolio-type
. This should be a unique string that is not used for another post type or taxonomy.5. Activate the ‘Genesis Portfolio Pro Custom Slugs’ plugin.
6. Visit the Settings → Permalinks page to flush your rewrite rules.
If you also wish to change the default ‘portfolio’ slug for the main Portfolio archive page, you can add this code to the bottom of that file and repeat steps 4 and 6:
add_filter( 'register_post_type_args', 'GPPCS\portfolio_args', 10, 2 ); /** * Change Genesis Portfolio arguments. * * @param array $args Post type arguments. * @param string $post_type Current post type. * @return array Filtered post type arguments. */ function portfolio_args( $args, $post_type ) { if ( 'portfolio' === $post_type ) { $args['rewrite']['slug'] = 'project'; } return $args; }
I have also made a feature request at https://github.com/copyblogger/genesis-portfolio-pro/issues/20 for an option to the admin area to make renaming these slugs easier.
Thanks so much, Nick! Perfect! I appreciate the info.
Great! it works fine also as a workaround for fixing some problems I had with site-language different from english. Thanks!
This is terrific, thank you Nick.
Any suggestions on how to change the browser tab label since it still says portfolio items?
This works great. Thank you nick.
Only issue for me is that the breadcrumbs still show ‘Portfolio Items’ rather than my assigned ‘projects’.
What would I need to add to update the breadcrumbs too?
You can update the name labels to alter the breadcrumb name and browser tab title. Add these alongside your other
args
changes:$args['labels']['name'] = _x( 'Projects', 'taxonomy general name', 'genesis-portfolio-pro' ); $args['labels']['singular_name'] = _x( 'Project', 'taxonomy singular name', 'genesis-portfolio-pro' ); $args['labels']['menu_name'] = _x( 'Projects', 'taxonomy menu name', 'genesis-portfolio-pro' );
The properties you can override for the portfolio type and taxonomy are visible here.
-
This reply was modified 6 years, 4 months ago by
Nick C.
This is not working for me. Please advise.
I added this to my plugins.php
—–
<?php
/**
* Plugin Name: Genesis Portfolio Pro Custom Slugs
* Description: Alters Genesis Portfolio slugs.
* Version: 0.1.0
*/namespace GPPCS;
add_filter( ‘register_taxonomy_args’, ‘GPPCS\portfolio_type_args’, 10, 2 );
/**
* Change Genesis Portfolio Type arguments.
*
* @param array $args Taxonomy arguments.
* @param string $taxonomy Current taxonomy.
* @return array New taxonomy arguments.
*/
function portfolio_type_args( $args, $taxonomy ) {
if ( ‘portfolio-type’ === $taxonomy ) {
$args[‘rewrite’][‘slug’] = ‘work’;
}return $args;
}add_filter( ‘register_post_type_args’, ‘GPPCS\portfolio_args’, 10, 2 );
/**
* Change Genesis Portfolio arguments.
*
* @param array $args Post type arguments.
* @param string $post_type Current post type.
* @return array Filtered post type arguments.
*/
function portfolio_args( $args, $post_type ) {
if ( ‘portfolio’ === $post_type ) {
$args[‘rewrite’][‘slug’] = ‘work’;
}return $args;
}——————
goal being to change */porfolio to */work
@goldmaverick A few things:
1. The portfolio type slug should be different to the portfolio slug. You have both as ‘work’ at the moment. For example, you could change ‘work’ to ‘work-category’ for the portfolio type slug (the first ‘work’ in your code above):
$args['rewrite']['slug'] = 'work-category';
And leave the portfolio slug (the second ‘work’ in your code) as ‘work’.
2. Make sure the plugin containing your code is active.
3. Visit the Settings → Permalinks page after you have made your code changes to ensure the new URLs take effect.
Thanks
Hi
I’m having an issue getting Co-Authors Plus to integrate with the portfolio pro custom posts (see forum post here).
I’m just wondering if the customisations we made above (ie creating a new custom plugin to rename categories) is part of my problem?
Co-authors Plus is working fine and displays the custom guest authors in both normal blog posts and portfolio pro custom posts. But clicking the author name only displays an author archive page of the blog posts assigned to that author and doesn’t include portfolio posts. If you click on an author name in a porfolio post you just get a 404 error.
Any ideas how to edit the default WordPress Porfolio type / slug?
I’m not using Genesis Portfolio Pro plugin, but just the default wordpress custom portfolio type / URLs come up with /Portfolio/ and breadcrumbs as / projects / would like both to be customized to read the project-type if possible (‘members’ in this case).thanks!
It works, THANK YOU VERY MUCH, you save me <3
Still works perfectly. Thank you!!!
-
This reply was modified 6 years, 4 months ago by
- The topic ‘Change URL Slug for Portfolio Type’ is closed to new replies.