Custom Permalinks for Custom post Type Archives?

Take an example custom post type called movie the code below will create custom permalinks awesomemovies/ regardless of the one created by using the has_archive and rewrite options of register_post_type. add_filter( ‘rewrite_rules_array’, ‘custom_permalink_for_my_cpt’ ); function custom_permalink_for_my_cpt( $rules ) { $custom_rules = array(); // for archive urls $custom_rules[‘awesomemovies/?$’] = ‘index.php?post_type=movie’; // for individual post urls e.g: … Read more

Change post permalink to external URL from custom field

Filter post_link (or post_type_link for custom post types), fetch and validate the post meta value, then return that instead of the original link. As a plugin: <?php /** * Plugin Name: External Permalinks * Plugin URI: http://wordpress.stackexchange.com/q/64285/73 * Description: Uses the value of post meta field <code>syndication_permalink</code> as permalink if available. * Version: 2012.11.13 * … Read more

Change link to other post to shortlink in the editor

The links in that dialog are made by wp_ajax_wp_link_ajax() (see wp-admin/includes/ajax-actions.php, there is no page on Codex or queryposts.com for that function). To change the links filter ‘page_link’, ‘post_type_link’, ‘post_link’ and maybe ‘attachment_link’ after check_ajax_referer() was called for the action ‘internal-linking’. Okay, sounds a little bit complicated, but it is really easy. 🙂 Plugin on … Read more

Custom Rewrite with Query vars

Add a rewrite endpoint instead of a rewrite rule and query var. This API function will do both of these things for you. function wpd_add_my_endpoint(){ add_rewrite_endpoint( ‘information’, EP_PAGES ); } add_action( ‘init’, ‘wpd_add_my_endpoint’ ); Now any page can have information appended to the end, and the value will be available via get_query_var(‘information’).

Changing the category permalink structure

The following code changes all links to category archives so they don’t include the parent category: add_filter( ‘category_link’, ‘wpse7807_category_link’, 10, 2 ); function wpse7807_category_link( $catlink, $category_id ) { global $wp_rewrite; $catlink = $wp_rewrite->get_category_permastruct(); if ( empty( $catlink ) ) { $catlink = home_url(‘?cat=” . $category_id); } else { $category = &get_category( $category_id ); $category_nicename = … Read more

Why can posts never have a number as the link?

Why Suffixes Are Appended to (Some) Numeric Post-Slugs WordPress posts can almost always have numeric permalinks, the exceptions being when they might conflict with another post, a feed, or a post post-type date archive, or are otherwise reserved. The wp_unique_post_slug() function mitigates these conflicts by appending a suffix. Potential date-archive conflicts arise when a numeric … Read more

Permalinks in Custom Post types

Take a look at my answer to the following question. You can modify my parse_request() to get what you need: “Remove taxonomy slug from a custom hierarchical taxonomy permalink”. And you can read the following to see why what you want can cause issues in WordPress and requires a complex solution: “Category in Permalinks Considered … Read more

Custom Permalinks for Custom Post Types and Taxonomies

Here’s the method I use to get what you’re trying to achieve. First, register your location taxonomy: register_taxonomy( ‘location’, array( ‘business’ ), array( ‘rewrite’ => array( ‘slug’ => ‘business-location’ ) ) ); Next, register the business post type. The important bit to note here is the inclusion of the %location% rewrite tag in the slug. … Read more