# Permalinks: How to remove "listing-category" and "listing" from permanent links?

**URL:** <https://community.hivepress.io/t/permalinks-how-to-remove-listing-category-and-listing-from-permanent-links/17834>\
**Category:** HivePress\
**Tags:** code\
**Created:** [July 11, 2026, 12:55pm UTC](https://community.hivepress.io/t/permalinks-how-to-remove-listing-category-and-listing-from-permanent-links/17834 "2026-07-11T12:55:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![obtrusive170](https://community.hivepress.io/letter_avatar_proxy/v4/letter/o/8dc957/32.png) [@obtrusive170](https://community.hivepress.io/u/obtrusive170)\
**Post date:** [July 11, 2026, 12:55pm UTC](https://community.hivepress.io/t/permalinks-how-to-remove-listing-category-and-listing-from-permanent-links/17834/1 "2026-07-11T12:55:54Z")

</div>

HivePress default free plugin template results in a following URL scheme, which i would like to change as shown:

1. 

/listing-category/categorynamehere/  
 →   
/categorynamehere/

1. 

/listing/abc-def/  
 →   
/categorynamehere/abc-def/

I have spent around 1 hour asking AI to give me PHP code/.htaccess rules (Homepage and category tags may continue redirecting to a old link scheme) or using plugin “Redirects”

but failed to find a working solution. Permalink change seems to be also related on re-saving configuration at /wp-admin/options-permalink.php

My categories count would be limited (low number), so maybe i can define these manually if necessary.

---

<div class="post-metadata">

**Author:** ![kseniia](https://community.hivepress.io/user_avatar/community.hivepress.io/kseniia/32/13513_2.png) [@kseniia](https://community.hivepress.io/u/kseniia)\
**Post date:** [July 13, 2026, 4:05pm UTC](https://community.hivepress.io/t/permalinks-how-to-remove-listing-category-and-listing-from-permanent-links/17834/4 "2026-07-13T16:05:45Z")

</div>

Hi,

I hope you had a lovely weekend.

HivePress is built on top of the WordPress database and core concepts, meaning a listing is a custom post type, and a listing category is a custom taxonomy. Because of this, the solution you’re looking for isn’t specific to HivePress itself, so I’d recommend searching for solutions related to custom post types + custom taxonomies in general, since that’s really the underlying structure here.

By default, WordPress uses `/taxonomy/term-slug` for custom taxonomies and `/post-type/post-slug` for custom post types. These URL segments are how WordPress determines which taxonomy or post type to look up the entry in, and which layout/template to display.

For reference, in case it helps:

- Listings use the `hp_listing` post type
- Categories use the `hp_listing_category` taxonomy

I found a couple of links on this topic that might be useful, hope this helps point you in the right direction:

> <https://wordpress.stackexchange.com/questions/346452/how-to-add-custom-taxonomy-in-custom-post-type-permalink>

> <https://wordpress.stackexchange.com/questions/42120/remove-slug-in-taxonomy-url>

---

<div class="post-metadata">

**Author:** ![obtrusive170](https://community.hivepress.io/letter_avatar_proxy/v4/letter/o/8dc957/32.png) [@obtrusive170](https://community.hivepress.io/u/obtrusive170)\
**Post date:** [July 14, 2026, 6:01am UTC](https://community.hivepress.io/t/permalinks-how-to-remove-listing-category-and-listing-from-permanent-links/17834/5 "2026-07-14T06:01:40Z")

</div>

I have spent/wasted around 1 hour with Hive and other AI and unable to make it working. Highest achievement is that listings URLs changes like i wanted

> /listing/abc-def/  
> →  
> /categorynamehere/abc-def/

after applying PHP snippet:

```auto
// 1. Change displayed URL: /listing/saa/ → /categoryname/saa/
add_filter('post_type_link', function($url, $post) {
    if ('hp_listing' !== $post->post_type) return $url;
    $terms = wp_get_post_terms($post->ID, 'hp_listing_category');
    if ($terms && !is_wp_error($terms)) {
        return home_url('/' . $terms[0]->slug . '/' . $post->post_name . '/');
    }
    return $url;
}, 10, 2);

// 2. Make WordPress understand the new URL pattern (per-category rules)
add_action('init', function() {
    $terms = get_terms(['taxonomy' => 'hp_listing_category', 'hide_empty' => false]);
    if (!is_wp_error($terms)) {
        foreach ($terms as $term) {
            add_rewrite_rule('^' . $term->slug . '/([^/]+)/?$', 'index.php?hp_listing=$matches[1]', 'top');
        }
    }
});

```

, but in such case, listings pages like /categoryname/saa/ shows “Nothing found” error while Hive AI commenting it " HivePress has its own template and query logic that doesn’t fully respect custom rewrite rules". If anyone knows the fix, let me know.

Unlike above mentioned objective, second objective that I had, was:

> /listing-category/categorynamehere/  
> →  
> /categorynamehere/

and that could be partly achieved at /wp-admin/options-permalink.php setting “Category (Listing)” field to for example letter “c” which correctly changes /listing-category/categorynamehere/ to /c/categorynamehere/ and that looks better to me (shorter).

---

<div class="post-metadata">

**Author:** ![ihor](https://community.hivepress.io/user_avatar/community.hivepress.io/ihor/32/5_2.png) [@ihor](https://community.hivepress.io/u/ihor)\
**Post date:** [July 14, 2026, 1:39pm UTC](https://community.hivepress.io/t/permalinks-how-to-remove-listing-category-and-listing-from-permanent-links/17834/7 "2026-07-14T13:39:36Z")

</div>

Please note that the issue is not related to HivePress framework – it just registers the post type “hp\_listing” and taxonomy “hp\_listing\_category”. WordPress then takes care of URL routing and permalinks; we only have custom rewrite rules for static pages like “/submit-listing”. I recommend trying the code snippet below; please re-save permalinks in Settings/Permalinks after adding it:

```auto
// rewrite /listing/slug to /category/slug
add_filter(
	'post_type_link',
	function ( $permalink, $post ) {

		if ( $post->post_type !== 'hp_listing' ) {
			return $permalink;
		}

		$terms = get_the_terms( $post->ID, 'hp_listing_category' );

		if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
			// Use the first assigned category
			$term = array_shift( $terms );

			return home_url( '/' . $term->slug . '/' . $post->post_name . '/' );
		}

		// Fallback if no category
		return home_url( '/' . $post->post_name . '/' );

	},
	10,
	2
);

add_action(
	'init',
	function () {

		add_rewrite_rule(
			'^([^/]+)/([^/]+)/?$',
			'index.php?hp_listing=$matches[2]',
			'top'
		);

	}
);

// rewrite /listing-category/slug to /slug -- conflicts with regular pages possible
add_filter(
	'term_link',
	function ( $url, $term, $taxonomy ) {

		if ( $taxonomy === 'hp_listing_category' ) {
			return home_url( '/' . $term->slug . '/' );
		}

		return $url;

	},
	10,
	3
);

add_action(
	'init',
	function () {

		add_rewrite_rule(
			'^([^/]+)/?$',
			'index.php?hp_listing_category=$matches[1]',
			'top'
		);

	}
);

```

I haven’t reviewed the code in detail as it was generated by AI, but I briefly tested it locally and it seems to work – I got URLs like “/real-estate/cozy-home” for listings and “/real-estate” for categories.

Hope this helps

---

<div class="post-metadata">

**Author:** ![obtrusive170](https://community.hivepress.io/letter_avatar_proxy/v4/letter/o/8dc957/32.png) [@obtrusive170](https://community.hivepress.io/u/obtrusive170)\
**Post date:** [July 15, 2026, 2:58pm UTC](https://community.hivepress.io/t/permalinks-how-to-remove-listing-category-and-listing-from-permanent-links/17834/9 "2026-07-15T14:58:08Z")

</div>

**Yes, that PHP snippet worked to solve what i wanted in OP. Thank you.**  
I had to clear cache (using Wordpress caching plugin) and save that /wp-admin/options-permalink.php page 1-2 times. I am unsure about order of things, but if anyone have problem applying that PHP workaround, then try:

1. enable PHP snippet inside “Code snippets” or “Fluent snippets” plugin,
2. Save that Permalinks page (Maybe custom values on that Permalinks page can interfere)
3. clear cache.

---

<div class="post-metadata">

**Author:** ![kseniia](https://community.hivepress.io/user_avatar/community.hivepress.io/kseniia/32/13513_2.png) [@kseniia](https://community.hivepress.io/u/kseniia)\
**Post date:** [July 15, 2026, 4:11pm UTC](https://community.hivepress.io/t/permalinks-how-to-remove-listing-category-and-listing-from-permanent-links/17834/10 "2026-07-15T16:11:54Z")

</div>

Glad we could help resolve your request!

If you find HivePress useful, we would really appreciate it if you could take a moment to leave a review on the [WordPress repository](https://wordpress.org/support/plugin/hivepress/reviews/) or [Trustpilot](https://www.trustpilot.com/review/hivepress.io). Your feedback means a lot to us and makes a real difference in helping us grow.

---

<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:** [August 14, 2026, 4:12pm UTC](https://community.hivepress.io/t/permalinks-how-to-remove-listing-category-and-listing-from-permanent-links/17834/11 "2026-08-14T16:12:01Z")

</div>

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