• Is there an away to create “virtual” slugs on wordpress?

    I have a system based on lot’s of custom post type.
    The structure is basically 1 cpt(item) as a default post and 6 others cpt to populate the information inside the cpt item.

    All cpts have post inside:
    Brand -> brand a, brand b, brand C.

    If I access the site.com/brand(or other cpt)
    I list all post inside this cpt.

    If I access the site.com/brand/brand-a
    I list all cpt(item) that have the brand-a information on field brand.
    * I created a custom archive.php that make this query.

    I need to insert now other field (YEAR) inside the cpt(item).
    The field will be a text because the possible range is between 1800 -> 2018 and it’s not possible to create one post for each year(if its a cpt)

    I create a cpf (year) just for slug site.com/year/
    If i access the url my archive.php make a query and return all values year used on cpt(item).

    I need to access site.com/year/1980/ and the wordpress load the single.php file(like a normal cpf) and not a 404 file.

    Is it possible to do it using cpt or only on .htaccess?

    Thanks
    Fernando

Viewing 1 replies (of 1 total)
  • It is possible to add rewrite rules to make the addresses do what you want. But consider if the year is really a post meta or a taxonomy. Some of what you are doing is already built-in, if you use it correctly.

Viewing 1 replies (of 1 total)
  • The topic ‘Manipulate slugs and urls on wordpress’ is closed to new replies.