WordPress.org

Forums

CataBlog
[resolved] modifying catablog-term slug prefix? (6 posts)

  1. alx359
    Member
    Posted 3 years ago #

    Hello,

    I can't find a proper way to modify the final slug for each category. Now if I have a category 'cars', the slug for it comes as 'catablog-term-cars', but would like it to be just 'cars', for a better SEO.

    I see the wp_terms stores each slug as catablog-term-<category> format. Why would one need a slug prefix if it can be differentiated by wp_term_taxonomy.term_id?

    Thanks.

  2. alx359
    Member
    Posted 3 years ago #

    Zach, the only place where "catablog-term-" prefix seems set is here:

    private function string2slug($string) {
    		$slug = "catablog-term-" . strtolower($string);
    		return  wp_unique_term_slug($slug, null);
    	}

    Is it possible I strip this, or at least change to something more suitable my project, with no adverse side-effects? (of course need to update table wp_terms.slug). Please advise.

    Thanks.

  3. macguru2000
    Member
    Plugin Author

    Posted 3 years ago #

    You may strip it out or change it, but before you do that read on.

    In case you were unaware each taxonomy term slug must be unique across all taxonomies. This means if you have a WordPress category with the slug cars and a CataBlog category with the slug cars, you will see odd behaviors and unexpected results.

    To fix this problem in a past version of CataBlog, before there ever was a public option, I added the prefix to CataBlog terms. Now I will need to make it configurable in a future version.

  4. alx359
    Member
    Posted 3 years ago #

    I see, thanks for the information!

    But isn't reasonable to think that uniqueness is reached as the whole path consisting of taxonomy+slug? Isn't that enough?

    Or as in my CataBlog setup:

    Category Pages Slug: [gallery]

    The composite slug would be: [gallery/catablog-term-cars] or [gallery/cars] as I'd prefer.

    If I have another category named [cars] the slug would be mysite.com/[cars] or [topic/cars] if using a taxonomy base, so the uniqueness would be kept.

    Anyway, if you consider putting that prefix as configurable in a future version it will be great!

  5. macguru2000
    Member
    Plugin Author

    Posted 3 years ago #

    I am not referring to the url but a core WordPress requirement. If you want two different categories, even if in different taxonomies, WordPress requires they have different slug values. Period. Nothing I know of besides hacking WordPress to get around this limitation. Sorry.

    Also, just to clarify WordPress does not store the entire "slug" in the database, but just the category's slug value. Look in the database to see what I mean.

  6. alx359
    Member
    Posted 3 years ago #

    I see, thanks again. Still a newbie to WP.

    To have this as a configurable value is a very good option though, as the prefix can be part of the site's niche. I've changed it to something more suitable, thanks to your helpful comments.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags