How can i change the base of url for listings (custom post type url)?

I need to change the base url for listings in this way:

From sitename.com/listing/pink-moleskine-notebook/
To sitename.com/pink-moleskine-notebook/

Simply i don’t want any word before the listing name, i tried changing permalink with %postname% but the word listing remain, i tried under permalink settings to change listing with another name and it worked example /ads/pink-moleskine-notebook/, but if the text box is empty so return back to listing.
I can’t find a solution, please, someone that help me to have the simplest permalink: site/postname/

Thank you to who will help me

Hi,

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

​I hope this is helpful to you.

Hello andrii,
i’m sorry but your solution work if i want to change the slug “listing” with some other word, so in this case in the Permalinks > Optional i can write my new slug, anyway i won’t any slug, my perfect url is sitename/postname, if i leave blank the slug field i have again the old standard slug “listing”.

Only this php code below worked, the url is right “sitename/postname” but all listings pages says no results.
This code is added to wp-content\themes\listinghive\functions.php

<?php
add_filter(
	'hivepress/v1/post_types',
	function( $args ) {
		$args['listing']['rewrite']['slug'] = '/';

		return $args;
	},
	100
);

Where are stored all default slugs used by Hivepress?
Seems easy to do but it’s so hard to resolve :sleepy:

Hi,

I see. Please note that this is a WP-level setting; you can change the slug, but it is required in any case for WordPress to understand that the listing page will now be displayed. The structure you want to add is already used by WordPress for regular pages in WordPress > Pages, please check this topic Remove slug from custom post type post URLs - WordPress Development Stack Exchange
As for your snippet, it looks good, post types are being overwritten like that. After you add it, please update the permalinks How to refresh WordPress permalinks - HivePress Help Center

I believe this will be useful to you.

Thanks a lot andrii,
i read the article and understand that is possible to do what i thought to do, anyway it’s a little bit difficult and they says can be unstable, so i decided to customize the slug instead of remove it, so thanks for your help.

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