• Resolved wordmax

    (@wordmax)


    We don’t want to have …/oum-location/…. directory to be shown in the URL for locations like …/oum-location/location-title but instead we want to change the words to …/locations/location-title so how can we change the words to our preference?

    Would be nice if you could show us a custom function or code snippet we could add using a code snippet plugin.

    Something like…

    define( 'WP_OUM_LOCATIONS_FOLDERNAME', ‘new name’ );

    Please forgive if this has already been addressed. (no pun intended).

    • This topic was modified 1 year, 3 months ago by wordmax.
Viewing 2 replies - 1 through 2 (of 2 total)
  • +1

    Plugin Author 100plugins

    (@100plugins)

    Hi @wordmax and @hwuser,

    I just did a quick test, but using this kind of filter seems to work:

    add_filter( 'register_post_type_args', function ( $args, $post_type ) {
    
        if ( 'oum-location' === $post_type ) {
           $args['rewrite']['slug'] = 'locations';
        }
     
        return $args;
     }, 10, 2 );

    Don’t forget to save the WordPress Settings > Permalinks page again after adding this to your theme. This ensures new rewrite rules are applied.

    Best regards,
    Daniel

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to rewrite /oum-location/ in the URL to something else?.’ is closed to new replies.