WordPress.org

Forums

Projects by WooThemes
[resolved] How to rename "projects" and "projects-category" slug? (15 posts)

  1. katuska
    Member
    Posted 1 year ago #

    Hi, thank you for this great plugin!

    I have a little problem - I need to rename "projects" and "project-category" in Projects permalink structure, because the website is not in english. How do I do that? Didn't find it in your documentation.

    And is it a safe way to do that regarding plugin updates?

    Thanks.

    https://wordpress.org/plugins/projects-by-woothemes/

  2. jameskoster
    Member
    Plugin Author

    Posted 1 year ago #

    Not currently, but you might want to give this plugin a shot.

  3. katuska
    Member
    Posted 1 year ago #

    Thanks, I will look into it.

  4. jameskoster
    Member
    Plugin Author

    Posted 1 year ago #

    Marking as resolved for now.

  5. Jason
    Member
    Posted 1 year ago #

    I gave that plugin a shot and it did work, however it caused problems for WooCommerce Orders, so we had to deactivate it. Any other ideas on how I can change the project and project-category slug?

  6. Jason
    Member
    Posted 1 year ago #

    I see this in the projects-core-functions.php:

    // Look in yourtheme/slug-name.php and yourtheme/projects/slug-name.php

    Which leads me to believe that it's possible, any ideas how to use this to customize the slug?

  7. Jason
    Member
    Posted 1 year ago #

    It's been a couple weeks and thought I'd check in. No response.

    I did manage to figure out where to change the slugs in the projects.php page. On line 63 where it says $this->post_type = 'projects' and on line 164 for the "project-category". I changed those, then I updated my permalinks, and it worked.

    However…It's now missing the settings, categories, the cover image, project details, project short description, project cover image, and project gallery. Ugh! This plugin could be soooo powerful, if we could have the ability to easily change the purpose. Instead of projects it could be used for video galleries, home showcase for real estate, portfolios, catalogs, etc, etc. If we could only have the ability to easily change the slug and the admin labels it could be used to present almost anything.

    I'd even settle for just some code snippets to add to my functions.php for the functionality. Anyway, hopefully you can find some time to update this great plugin to add this functionality, it would really make this plugin incredibly valuable!

    Thanks

  8. saxisme
    Member
    Posted 1 year ago #

    Hi @Jason,

    I am in a similar situation and would like to avoid editing the core files of the plugins.

    A temporary solution can be to modify in line 167 of project.php, like this
    form:
    'slug'=> trailingslashit ( strtolower( $this->singular_name ) ) . '%project_category%',
    to:
    'slug'=> trailingslashit 'new_name' . '%project_category%',

    Anyway using the plugin Codestyling Localization you should be able to translate it in a new language.

  9. Piet Bos
    Member
    Posted 1 year ago #

    @Jason you should open a new topic as the plugin author has remarked this as resolved (5 months ago) and therefore doesn't pay attention to whatever is happening after that.

  10. brightestspark
    Member
    Posted 11 months ago #

  11. mickyharris
    Member
    Posted 11 months ago #

    @Jason

    I'm trying to achieve this as well. I got this far by adding the following code to my functions file. However, it results in too many redirects when viewing a project so have abandoned the idea.

    I post in case this is useful to anyone, if anyone can take this further, let us know.

    add_filter('projects_post_type_singular_name', 'my_project_singular_name');
    function my_project_singular_name ( $singular_name ) {
    	return $singular_name = 'Your Name Here';
    }
    add_filter('projects_post_type_plural_name', 'my_project_plural_name');
    function my_project_plural_name ( $plural_name ) {
    	return $plural_name = 'Your Name (plural) Here';
    }

    Thanks

  12. Jason
    Member
    Posted 11 months ago #

    Hi @mickyharris

    I have fully conquered this plugin! ;-)

    First, as of version 1.3 onwards (from the change log) the project category urls have been improved to use the base page title as the slug opposed to the project-category default. So, previously your project cateogry urls will have looked like: yoursite.com/project-category/illustration. Now, project-category is replaced with the slug of your projects base page. So if you're using a page called 'Portfolio' that url will now look like: yoursite.com/portfolio/illustration. So no code is needed anymore. Hooray for 1.3 update!

    Second, the other thing that I wanted was the ability to actually change the text in the admin from "Projects" to whatever I wanted such as "Homes" for a real estate site, or "Video Gallery" for a video site, etc. To adjust this just add this code to your functions.php page

    /*Translation for Projects*/
    add_filter( 'projects_post_type_singular_name', 'replace_project_with_new');
    add_filter( 'projects_post_type_plural_name', 'replace_project_with_new');
    function replace_project_with_new( $project ){ $replaced = str_ireplace('Project', 'YOUR NEW NAME', $project); return $replaced; }

    Then just change the "YOUR NEW NAME" with your own new name and it will translate in the admin.

    Hope that helps. I feel with these two thing this plugin becomes very powerful!

  13. hugotiles
    Member
    Posted 11 months ago #

    Hi Jason,

    Thank you very much for for the code. I used this code to rename the slug "portfolio" and it works beautifully. Now when you select a project, you get the following path:

    http://www.site.com/portfolio/category/myfirstproject

    However, when you select a category, the root folder changes directory to:

    http://www.mysite.com/archive/category

    This doesn't create a consistent and logical permalink structure. Instead, I would have preferred to see:

    http://www.site.com/portfolio/category/

    I tried to rename the archive page "portfolio". Again, it does work fine when selecting an individual project. However, having the archive page and the Project slug carrying the same name, creates an inconsistency when selecting a category. That is, you get a "Sorry, no posts matched your criteria".

    Would you know if it is possible to display the project's folder when selecting project categories (instead of the archive URL)?

    Thank you,
    Hugo

  14. mickyharris
    Member
    Posted 11 months ago #

    Hi Jason and Hugo

    These filters work for changing slugs on categories and archives as well as admin labels:

    /* Change labels and slug on Projects */
    add_filter('projects_post_type_singular_name', 'my_project_singular_name');
    function my_project_singular_name ( $singular_name ) {
    	$singular_name = 'Case Study';
    	return $singular_name;
    }
    add_filter('projects_post_type_plural_name', 'my_project_plural_name');
    function my_project_plural_name ( $plural_name ) {
    	$plural_name = 'Case Studies';
    	return $plural_name;
    }

    I think this will work for you Hugo.

    The problem with Jason's code is it won't work for plurals that are spelt differently to the singular form (Gallery/Galleries etc)

    My problem was that the new names had spaces and for some reason was causing too many redirects on the single Project page. Therefore, I added these functions to filter register_post_type() and so far it seems to work well for me.

    add_filter( 'projects_register_post_type', 'my_project_post_type_args' );
    function my_project_post_type_args($args) {
    	$singular_name = 'Case Study';
    	$plural_name = 'Case Studies';
    	$labels = array(
    			'name' 					=> $plural_name,
    			'singular_name' 		=> $singular_name,
    			'add_new' 				=> _x( 'Add New', $post_type, 'projects-by-woothemes' ),
    			'add_new_item' 			=> sprintf( __( 'Add New %s', 'projects-by-woothemes' ), $singular_name ),
    			'edit_item' 			=> sprintf( __( 'Edit %s', 'projects-by-woothemes' ), $singular_name ),
    			'new_item' 				=> sprintf( __( 'New %s', 'projects-by-woothemes' ), $singular_name ),
    			'all_items' 			=> sprintf( _x( 'All %s', $post_type, 'projects-by-woothemes' ), $plural_name ),
    			'view_item' 			=> sprintf( __( 'View %s', 'projects-by-woothemes' ), $singular_name ),
    			'search_items' 			=> sprintf( __( 'Search %a', 'projects-by-woothemes' ), $plural_name ),
    			'not_found' 			=> sprintf( __( 'No %s Found', 'projects-by-woothemes' ), $plural_name ),
    			'not_found_in_trash' 	=> sprintf( __( 'No %s Found In Trash', 'projects-by-woothemes' ), $plural_name ),
    			'parent_item_colon' 	=> '',
    			'menu_name' 			=> $plural_name
    
    		);
    	$args = array(
    				'labels' 				=> $labels,
    				'public' 				=> true,
    				'publicly_queryable' 	=> true,
    				'show_ui' 				=> true,
    				'show_in_menu' 			=> true,
    				'query_var' 			=> true,
    				'rewrite' 				=> array(
    											'slug' 			=> trailingslashit ( 'case-study' ) . '%project_category%',
    											'with_front' 	=> false
    											),
    				'capability_type' 		=> 'post',
    				'has_archive'			=> 	( $projects_page_id = projects_get_page_id( 'projects' ) ) && get_page( $projects_page_id ) ? get_page_uri( $projects_page_id ) : 'projects',
    				'hierarchical' 			=> false,
    				'supports' 				=> array(
    											'title',
    											'editor',
    											'thumbnail',
    											'excerpt'
    											),
    				'menu_position' 		=> 5,
    				'menu_icon' 			=> 'dashicons-portfolio'
    			);
    			return $args;
    }

    I'm not really happy with hard coding the arrays like this outside the original Project functions, but there it is.

    Cheers

    Micky

  15. hugotiles
    Member
    Posted 11 months ago #

    Hi Micky,

    Thank you very much for your input. For the record, I contacted Woo support and they explained that the archive page for Projects' is used to display the portfolios. Whereas, projects' folder (slug name) is where the actual projects reside. And the slug name and the archive page need to have different names otherwise it causes an url conflict between sections in WordPress... I guess that is why I got the message :"Sorry, no..."

    So, I gave it up and simply named my archive page "portfolios" and the the slug "portfolio", and that's it.

    Thank you again for reaching out.

    Regards,
    Hugo

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Projects by WooThemes
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.