Is there a way to rewrite vendor URL to utilize a vendor category?

Apart from using a custom post type and a separate registration page to group different kinds of users, for example, in an escort directory, one could use separate custom post to group Escort, Escort Agencies, Masseuse, Masseurs, and so on… Which other ways can this be achieve for a site that does not want to create multiple post type but has only one post types ‘vendor’ but, can create as many categories as possible. However, if this is implemented via category, how can the URL read like example.com/masseuse/smith and another vendor example.com/masseur/paul and NOT example.com/vendor/smith or example.com/vendor-category/paul ?

How would the rewrite rule looks like?

Hi,

Please check this doc: How to customize URL structure - HivePress Help Center

​I hope this is helpful to you.

It doesn’t meet my needs.

What I’m trying to achieve is to eliminate the default trailing category or post type name from appearing before the actual post name in the URL structure.

I DON’T WANT THIS: example.com/xyzt/postname

INSTEAD, I WANT ALL URLS ON MY SITE TO BE LIKE THIS: example.com/postname

IF THE POST BELONGS TO A CATEGORY, THEN THE URL SHOULD BE: example.com/post-category/postname

FOR VENDORS, THE URL SHOULD BE: example.com/vendor-category/vendorName

NOT: example.com/vendor/vendorName

In the WordPress permalink settings, the vendor category configuration does not allow for placeholders or variables like %category%.

Since the theme is not designed for multiple post types, I’m utilizing categories to group my users. Therefore, I want the category name to appear in the URL where the post type name would normally be. Thus, I cannot set a single category base; it must be variable based on the category of the post being viewed.

This is proving to be quite challenging.

Hi,

I see. Please check the solution in this topic: How can i change the base of url for listings? - #6

Those resources are not useful to me.

Please give me a PHP snippet that will make this vendor post type rewrite slug to work:

'vendor' => [
    'public' => true,
    'show_ui' => true,
    'has_archive' => true,
    'delete_with_user' => true,
    'supports' => [ 'title', 'editor', 'thumbnail' ],
    'menu_icon' => 'dashicons-businessman',
    'rewrite' => [ 
        'slug' => 'custom_vendor_categories OR %hp_vendor_category%', // Use 'custom_vendor_categories' as vendor url base
    ],
    'redirect_canonical' => false,

    'labels' => [
        'name' => hivepress()->translator->get_string( 'vendors' ),
        'singular_name' => hivepress()->translator->get_string( 'vendor' ),
        'add_new' => esc_html_x( 'Add New', 'vendor', 'hivepress' ),
        'add_new_item' => hivepress()->translator->get_string( 'add_vendor' ),
        'edit_item' => hivepress()->translator->get_string( 'edit_vendor' ),
        'new_item' => hivepress()->translator->get_string( 'add_vendor' ),
        'view_item' => hivepress()->translator->get_string( 'view_vendor' ),
        'all_items' => hivepress()->translator->get_string( 'vendors' ),
        'search_items' => hivepress()->translator->get_string( 'search_vendors' ),
        'not_found' => hivepress()->translator->get_string( 'no_vendors_found' ),
        'not_found_in_trash' => hivepress()->translator->get_string( 'no_vendors_found' ),
    ],
],

Hi,

Sorry for the inconvenience, but customization is beyond our support scope - it includes fixing bugs and guidance about the available features Support Policy | HivePress

If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work Fiverr - Freelance Services Marketplace

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.