Custom Permalink with Dynamic Taxonomy for Custom Post Type – Works, but breaks other permalinks

If you’re running WordPress 3.0.1 or later, I believe your problem lies with the ‘post_type_link’ filter declaration and function arguments. When the ‘post_type_link’ filter is applied, it passes the following 4 arguments: apply_filters(‘post_type_link’, $post_link, $post, $leavename, $sample); But your function accepts $post_link and $id. Try the following adjustments: function custom_post_link( $post_link, $post ) { if … Read more

Custom Post Type “Event” with custom permalink structure

Problem solved!!!! =) add_action(‘init’, ‘evento_add_rewrite_rules’); function evento_add_rewrite_rules( $wp_rewrite ){ // Add day archive (and pagination) add_rewrite_rule(“eventos/([0-9]{4})/([0-9]{2})/([0-9]{2})/page/?([0-9]{1,})/?”,’index.php?post_type=evento&ano=$matches[1]&mes=$matches[2]&dia=$matches[3]&paged=$matches[4]’,’top’); add_rewrite_rule(“eventos/([0-9]{4})/([0-9]{2})/([0-9]{2})/?”,’index.php?post_type=evento&ano=$matches[1]&mes=$matches[2]&dia=$matches[3]’,’top’); // Add month archive (and pagination) add_rewrite_rule(“eventos/([0-9]{4})/([0-9]{2})/page/?([0-9]{1,})/?”,’index.php?post_type=evento&ano=$matches[1]&mes=$matches[2]&paged=$matches[3]’,’top’); add_rewrite_rule(“eventos/([0-9]{4})/([0-9]{2})/?”,’index.php?post_type=evento&ano=$matches[1]&mes=$matches[2]’,’top’); // Add year archive (and pagination) add_rewrite_rule(“eventos/([0-9]{4})/page/?([0-9]{1,})/?”,’index.php?post_type=evento&ano=$matches[1]&paged=$matches[2]’,’top’); add_rewrite_rule(“eventos/([0-9]{4})/?”,’index.php?post_type=evento&ano=$matches[1]’,’top’); }

display URL or permalink instead of page title in dashboard

Filter ‘the_title’ on the screen with the list table of your post type. The pattern for the initial hook is: manage_edit-post_type_name_columns. Sample code: // replace ‘post’ with the post type name you want to catch. add_filter( ‘manage_edit-post_columns’, ‘wpse_67171_title_to_url’ ); /** * Replace the default title with its permalink. * * @param string $title * @param … Read more

Include taxonomy slug in url?

This can be a bit challenging for WordPress, because it wouldn’t know whether you are referring to post, page or taxonomy. Nevertheless, rename your taxonomy to something like product_category and try changing the slug in your post type arguments to system/%product_category%, and slug in your taxonomy arguments to just system. WordPress should now handle /system/your-product-category/post-name/ … Read more

URL rewriting must be activated manually for my plugin

Whenever I create a plugin that needs permalinks enabled i check on the plugin activation and if its not set i display a message for the user: // Add Check if permalinks are set on plugin activation register_activation_hook( __FILE__, ‘is_permalink_activate’ ); function is_permalink_activate() { //add notice if user needs to enable permalinks if (! get_option(‘permalink_structure’) … Read more

Image Attachment Url Rewrite

Ok so I found the answer. I used the code as per https://wordpress.stackexchange.com/a/56426/37472 and changed all references of ‘series’ to ‘gallery’. That added the required rewritre rule to parse a link like domain.com/landscapes/gallery/123/ to index.php?attachment_id=123. My assumption was that wordpress would display the default permalink that is generated by get_permalink() in the domain.com/landscapes/gallery/123/ format. It … Read more

What happens when permalink settings are updated?

You’re correct, when you update the permalinks, the htaccess file also updates. When you create or update a “pretty” permalink structure, WordPress will generate rewrite rules and attempt to insert them into the proper .htaccess file. If it can’t, it will say something like “You should update your .htaccess now” and print out the rules … Read more