Viewing 3 replies - 1 through 3 (of 3 total)
  • Cool idea,

    I don’t know technically how to accomplish this, but my first guess would be to some how create or find a plugin that allows you to do a search query using a permalink URL.

    so example.com/actor/john-smith/ would return a list of results containing the name john-smith that was in the category actor no matter what its permalink was. i.e When someone clicked on John Smith it would take them to his profile, which then the permalink would change, but users could still access john smith from any of the urls.

    maybe?

    Moderator bcworkz

    (@bcworkz)

    The default behavior is not too far removed from this. If you have a post slug john-smith, you can put any random permalink text in front of it and the post will be found.

    example.com/meaningless-text/john-smith will return the correct post.

    The problem arises when meaningful text is used.

    example.com/category/john-smith will 404 unless there is a category slug john-smith.

    example.com/2015/john-smith/ will 404 unless the post really was published in 2015. Unlike meaningless text, meaningless numbers will 404 because they get interpreted as dates which typically do not match the post.

    We can work around the issue of known taxonomy slugs being in the permalink by assigning matching terms. If john-smith is both an actor and director, assign the term john-smith to both the actor taxonomy and director taxonomy when publishing the john-smith post. Then all expected permalinks will turn up the post instead of 404ing. This also prevents rewrites to the post because the post is actually listed in a taxonomy archive.

    Riffing on Julian’s idea of searching for permalink elements, the problem is unless the permalink is highly structured, the code cannot know if the search terms are supposed to be a particular taxonomy or a particular post type. Yes we can search for matches in all taxonomies and all post types, but that can quickly spiral out of control and the results will be low quality, most not matching the user’s intended content.

    We could just search for the terminal john-smith element and ignore other permalink elements, but post slugs aren’t great for relational searches. They either match exactly or they do not show up at all. jon-smith will not be returned even though it may be what the user is looking for.

    We could parse john-smith into individual terms john and smith, then jon-smith would be returned in the mix.

    I know I haven’t answered any questions yet, that was not my intent. I’m just adding more food for thought.

    One way a permalink search could be implemented is off of the 404.php template in most themes. There should be no reason to attempt a permalink search if it actually returns content anyway. The 404 template typically has a search box anyway. Why not do the search for the user?

    Oops! We couldn’t find anything matching your query, perhaps one of these is what you were looking for:

    John Smith
    Jon Smith
    J Smith
    John Smythe etc…

    As a completely custom query off of the 404 template, you can structure it to do anything you want.

    Great idea

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Category in URL instead of post type’ is closed to new replies.