Add vendor name to listing permalinks

To clarify: I know how to change permalink structure in wordpress, no issue with that.

When a vendor creates a listing, the listing gets a title. Let’s say one user names their listing “test”
Now, let’s say another vendor creates a listing and also names their listing “test”

What happens is that a number is appended to the listing name for any duplicate listing if no other factor differs in the permalink.
So, the first listing would be:
sitename.com/listing/test

and the second would be:
sitename.com/listing/test-2

rather than use the default ‘listing’ in the permalink, I want to use the vendor user name so the links differ since no two usernames can be the same.
sitename.com/listing/{vendor-1}/test
sitename.com/listing/{vender-2}/test
This would be a variable, though, and not possible to add on the permalinks page.
How would I achieve this? Is there a function that can be added?

I found a function in the documentation, but it is not for adding dynamic vendor name to the permalink structure (and the code doesn’t work):

add_filter(
	'hivepress/v1/post_types',
	function( $args ) {
		$args['listing']['rewrite']['slug'] = 'custom-slug-here';

		return $args;
	},
	100
);

Anyone able to achieve this?

If not, this should be a feature.

Hi,

Please note that this is WP-level customization, so you need a custom implementation using WP hooks, as HivePress only registers post types hp_listing and hp_vendor. Please check this sample wordpress - Include parent page slug in permalink for posts - Stack Overflow

​I hope this is helpful to you.

I saw that post and others that did not apply. It was not the solution I was looking for.

Again, this should be a feature for people to select having listing URLs include the vendor.

For any one else who is experiencing this issue and wants to fix it without having to code, install “Custom Post Type Permalinks”
Under hp_listing enter:/%author%/%postname%/

if you want the default ‘listing’ base name to change, you can change it in the optional section already provided. Unfortunately, tags in that section do not work - they are converted to text - therefore the workaround is needed.
Caveat: There is a bug in the plugin when defining the product permalinks. It adds an extra forward slash. The workaround is to click default and not change anything for the woocommerce products. If that is more important to you, than this solution is not something that will work for you at the moment until the bug is resolved by the plugin devs. Note: This plugin is not a hivepress plugin.
Here’s hoping Hivepress will add the ability to include the author/vendor name in the urls for listings in the future.

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