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

**URL:** <https://community.hivepress.io/t/how-can-i-change-the-base-of-url-for-listings-custom-post-type-url/9222>\
**Category:** HivePress\
**Created:** [January 14, 2024, 5:29pm UTC](https://community.hivepress.io/t/how-can-i-change-the-base-of-url-for-listings-custom-post-type-url/9222 "2024-01-14T17:29:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tex70](https://community.hivepress.io/letter_avatar_proxy/v4/letter/t/58956e/32.png) [@Tex70](https://community.hivepress.io/u/Tex70)\
**Post date:** [January 14, 2024, 5:29pm UTC](https://community.hivepress.io/t/how-can-i-change-the-base-of-url-for-listings-custom-post-type-url/9222/1 "2024-01-14T17:29:10Z")

</div>

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

From [sitename.com/listing/pink-moleskine-notebook/](http://sitename.com/listing/pink-moleskine-notebook/)  
To [sitename.com/pink-moleskine-notebook/](http://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

---

<div class="post-metadata">

**Author:** ![andrii](https://community.hivepress.io/user_avatar/community.hivepress.io/andrii/32/2951_2.png) [@andrii](https://community.hivepress.io/u/andrii)\
**Post date:** [January 15, 2024, 10:18am UTC](https://community.hivepress.io/t/how-can-i-change-the-base-of-url-for-listings-custom-post-type-url/9222/3 "2024-01-15T10:18:44Z")

</div>

Hi,

Please check this doc [How to customize URL structure - HivePress Help Center](https://help.hivepress.io/article/158-how-to-customize-urls)

​I hope this is helpful to you.

---

<div class="post-metadata">

**Author:** ![Tex70](https://community.hivepress.io/letter_avatar_proxy/v4/letter/t/58956e/32.png) [@Tex70](https://community.hivepress.io/u/Tex70)\
**Post date:** [January 15, 2024, 4:30pm UTC](https://community.hivepress.io/t/how-can-i-change-the-base-of-url-for-listings-custom-post-type-url/9222/4 "2024-01-15T16:30:30Z")

</div>

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

```auto
<?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 😪

---

<div class="post-metadata">

**Author:** ![andrii](https://community.hivepress.io/user_avatar/community.hivepress.io/andrii/32/2951_2.png) [@andrii](https://community.hivepress.io/u/andrii)\
**Post date:** [January 16, 2024, 1:04pm UTC](https://community.hivepress.io/t/how-can-i-change-the-base-of-url-for-listings-custom-post-type-url/9222/7 "2024-01-16T13:04:57Z")

</div>

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](https://wordpress.stackexchange.com/questions/203951/remove-slug-from-custom-post-type-post-urls)  
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](https://help.hivepress.io/article/165-how-to-refresh-wordpress-permalinks)

I believe this will be useful to you.

---

<div class="post-metadata">

**Author:** ![Tex70](https://community.hivepress.io/letter_avatar_proxy/v4/letter/t/58956e/32.png) [@Tex70](https://community.hivepress.io/u/Tex70)\
**Post date:** [January 26, 2024, 11:51am UTC](https://community.hivepress.io/t/how-can-i-change-the-base-of-url-for-listings-custom-post-type-url/9222/8 "2024-01-26T11:51:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://community.hivepress.io/user_avatar/community.hivepress.io/system/32/13990_2.png) [@system](https://community.hivepress.io/u/system)\
**Post date:** [February 25, 2024, 11:52am UTC](https://community.hivepress.io/t/how-can-i-change-the-base-of-url-for-listings-custom-post-type-url/9222/9 "2024-02-25T11:52:21Z")

</div>

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