How to map permalinks with accented letters to sanitized slugs?

The best way to accomplish this is remove the default sanitize_title filter and replace it with yours, which will encode those characters properly. Here is an implementation of using accents in permalinks. Example: remove_filter( ‘sanitize_title’, ‘sanitize_title_with_dashes’); add_filter( ‘sanitize_title’, ‘restore_raw_title’, 9, 3 ); function sweURLtoCHAR($text) { $url=array( “%C3%81″,”%C3%A1”, “%C3%8D”,”%C3%AD” ); $char=array( “Á”,”á”, “Í”,”í” ); $str = … Read more

Permalink rewrite with custom post type and custom taxonomy

You have to build up the link structure by using filters post_link and post_type_link: add_filter(‘post_link’, ‘territorio_permalink’, 10, 3); add_filter(‘post_type_link’, ‘territorio_permalink’, 10, 3); function territorio_permalink($permalink, $post_id, $leavename) { if (strpos($permalink, ‘%territorio%’) === FALSE) return $permalink; // Get post $post = get_post($post_id); if (!$post) return $permalink; // Get taxonomy terms $terms = wp_get_object_terms($post->ID, ‘territorio’,’orderby=term_order’); if (!is_wp_error($terms) && … Read more

Categories’ hierarchy in URL

The permastruct /%category%/%postname%/ will include the categories and subcategories in the URL from top to first assigned child. So, if you want the URL be site.com/source/books/moby-dick/*postname*, you have to assign the post only to “Moby Dick”. Assigning the post only to “Moby Dick” category will still show the post under “source” and “books” category archives … Read more

Modify get_permalink with a specific filter

Solved!, Change $postID by $post->ID, so, rewriting function: function noticias_print_permalink( $permalink, $post, $leavename ){ $external_link = get_post_meta( $post->ID, ‘external_link’, true ); if( !empty( $external_link ) ) { $permalink = $external_link; } return $permalink; } Regards.

Using %postname% tag with a Custom Permastruct creates 400 Bad Request Errors from the server

Okay, I feel stupid. I needed to translate %postname%. I thought it did so automatically since the admin page looked like it had but apparently if you do use custom permastructs, you have to translate even the default tags. My solution: add this to my post_type_link filter: $post = get_post($post_id); $permalink = str_replace(‘%postname%’, $post->post_name, $permalink); … Read more