0

I have custom posts and I created one page that shows all my custom posts.

Example: www.example.com/archive-page

I wonder if I can change permalinks of categories and tags related to this custom post.

Now i have:

  • www.example.com/my-custom-post-type-cats/my-category-1
  • www.example.com/my-custom-post-type-tags/my-tag-1

And I want something like this:

  • www.example.com/archive-page?category=1
  • www.example.com/archive-page?tag=1

If this is possible, can I get new URLs by get_category_link() for example?

If not, can i just override default taxonomy URLs to point they to my archive-page?

0

If not, can i just override default taxonomy URLs to point they to my archive-page?

I am not sure about newer version of the WP, but In the past I managed to create a taxonomy, say ivan_taxonomy and I also created a page, which slug was also ivan_taxonomy. So, when user viewed posts through example.com/ivan_taxonomy/super-cool-post/, he could have gotten easily to example.com/ivan_taxonomy/ and my page was being displayed. (Not sure, whether you wanted to know sth like this :-D)

And I want something like this:

Easy, grab a url param and create a WP_Query with dependence on it, for example:

if(isset($_GET) && false != $_GET)
{
    //whitelist
    $allowed = array("category", "tag");

    $url_params = array_keys($_GET);

    //get your term, provided it is the first in a query, 
    $term = (string)array_shift($url_params);

    //get your id
    $id = (int)$_GET[$term];

    //validate input
    if(in_array($term, $allowed) && (false != get_the_term_list( $id, $term )))
    {
        $query = new WP_Query(array($term => $id));
    }

}

Or it would be a lot easier with url like example.com/archive-page/?term=category&id=8.

2
  • The problem is when i have multiple categories and i can't do what you suggest with just one page. Oct 22 '13 at 19:55
  • Something I've got wrong, so, when you have multiple categoies, and you want to display posts from a particular category, you distinguish it with numeric ID from URL, doesn't you? Oct 23 '13 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.