How do I add a tag slug to a category URL to filter posts?

Ok, I found a solution. By default in WP there is an option to filter categories by tags. E.g. https://example.com/category_name?tag=tag_name. I added a rewrite rule and redirection: https://developer.wordpress.org/reference/functions/add_rewrite_rule/ add_action( ‘init’, function () { add_rewrite_rule( ‘([a-z0-9-]+)\/tag\/([a-z0-9-]+)\/?$’, ‘index.php?category_name=$matches[1]&tag=$matches[2]’, ‘top’ ); } ); https://developer.wordpress.org/reference/hooks/template_redirect/ add_action( ‘template_redirect’, function () { if ( is_category() && is_tag() && ! empty( $_GET[‘tag’] … Read more

How to get category/tag in URL for Pagination links?

Why can you not use the core functions previous_posts_link()/next_posts_link() or posts_nav_link(), all of which already account for the taxonomy archive context? EDIT: I think I understand your question now. You want pagination links, rather than previous/next page links. WordPress also has a native function for pagination links: paginate_links() (Codex ref). Here’s how I use this … Read more

Change custom post type GUID in RSS

The feed template files call the_guid(), which calls get_the_guid(), which has a filter named (surprisingly) get_the_guid. You can hook into this filter to change the output. The filter only gets the current GUID, not the post ID, so look this up in the global variable if you need it. add_filter( ‘get_the_guid’, ‘wpse17463_get_the_guid’ ); function wpse17463_get_the_guid( … Read more

How does: /index.php?post_type=event&event-date=2011-07-25 work? What if it doesn’t work?

You will have to use the rewrite API to get that to work. First you need to register the rewrite rule. add_action( ‘init’, ‘wpse23712_rewrites’ ); function wpse23712_rewrites() { add_rewrite_rule( ‘events/day/(\d{4}-\d{2}-\d{2})/’, ‘index.php?post_type=event&event_date=$matches[1]’, ‘top’ ); } Then add your event_date to the query vars so wordpress understands it. add_filter( ‘query_vars’, ‘wpse23712_vars’ ); function wpse23712_vars ( $vars ) … Read more