Articles of rewrite tag

How to test custom rewrite rules /permalinks?

After much research, I think I can wrap my brain around WP’s rewrite system. I would like to know, though, how to properly test rewrite rules to see if the right rule/tags is being used and the right query vars are being passed. Is there a way to create a temporary template that supersedes everything […]

What add_rewrite_tag()'s RegEx matches against?

I’m trying to figure out wether I can specify the position of the string to match (i.e. immediately after the domain) to reduce the chances of matching something else, but I don’t even know what the RegEx in add_rewrite_tag() matches against. Does it match against a full url including domain? or Does it match against […]

Taxonomy Url with Custom post type prefix re-write rule

I have a taxonomy called Section and a Custom post type called Developments. What i need to achieve is a permalink on the taxonomy with custom post type prefixed: e.g: custom post type: development <- More than one custom post type so needs to be dynamic taxonomy: section term: casting http://site.com/development/section/casting What i have at […]

404 error using Meta for Permalink rewrite

I’m trying to rewrite my permalinks using meta data from my post. The permalink rewrite works fine but I’m getting the 404 error when I try to view the post. Could someone offer a clue as to why this wouldn’t work? add_action(‘init’, ‘new_rewrite’); function new_rewrite(){ add_rewrite_tag(“%mls%”, ‘([a-zA-Z0-9])’); } add_filter(‘post_link’, ‘mls_permalink’, 10, 3); add_filter(‘post_type_link’, ‘mls_permalink’, 10, […]

permastruct for custom post type not working in one of four cases

I’ve created custom permalinks for various custom post types on a website. They all worked. Until recently I added another one, which I cannot get to work 8-o. The “company” struct is not working and gives a 404.. Can anyone spot a flaw in my thinking or put me on the right track? I must […]

add_rewrite_endpoint not working

I’ve been having looot of troubles with this function, I don’t know what to do, because I tried everything. I have a custom post type, let’s call it study. The url structure for it is http://example.com/study/studyname They have different sections, I want to have the new structure like this: http://example.com.com/study/studyname/view/view_arg So far I’ve tried add_rewrite_endpoint() […]

Enpoint Not Found in Rewrite Tag Permalink

I’m trying to make an XML feed show nice and pretty permalinks rather than showing query strings. The problem is I can’t get my /products/ endpoint to show up when trying to process my custom rewrite template tag. Here’s what I have: /** Register Query Vars **/ function theme_custom_query_vars( $vars ){ $vars[] = ‘custom_category’; $vars[] […]

Help with rewrite rules for two post types

I’m trying to setup two rewrite rules for two post types. Basically, the structure I want is this: site.com/app/course/xxxx/ => adds query_var course site.com/app/course/xxxx/theme/xxxx/ => adss query vars course and theme I set up two add_rewrite_rule: public function rewrite_rules(){ add_rewrite_tag( ‘%course%’, ‘([^&]+)’ ); add_rewrite_tag( ‘%theme%’, ‘([^&]+)’ ); add_rewrite_rule(“^app/course/([^/]+)/?”,’index.php?page_id=3400&course=matches[1]’, ‘top’ ); add_rewrite_rule(‘^app/course/([^/]+)/theme/([^/]+)/?’,’index.php?page_id=3400&course=$matches[1]&theme=$matches[2]’, ‘top’ ); } If […]

Custom permalink leads to index page

I have a custom post type named patch and custom permalink structure: www.site.ru/patch/%version_id% I managed to replace %version_id with actual version code with this code: add_action(‘init’, ‘patch_rewrite_rules’); add_filter(‘post_type_link’, ‘patch_permalinks’, 10, 3); function patch_rewrite_rules() { global $wp_rewrite; $wp_rewrite->add_rewrite_tag(‘%version_id%’, ‘([^/]+)’, ‘version_id=’); $wp_rewrite->add_permastruct(‘patch’, ‘/patch/%version_id%’, false); } function patch_permalinks($permalink, $post, $leavename) { $post_id = $post->ID; if($post->post_type != ‘patch’ || […]

404 Issue w/ Custom Post Type – using Meta for Permalink rewrite

I’m trying to rewrite my permalinks using meta data from my post. The permalink rewrite works- but I’m getting the 404 issue when I try to view the post. I’ve flushed by visiting the permalink settings page, and still no dice. Could someone offer a clue as to why this wouldn’t work? add_filter(‘post_type_link’,’calendar_link_filter’,1,3); function calendar_link_filter( […]