Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have my permalink set to %postname%/%location%/%course% I want this permalink %location%/%course%/%postname% but due to this I get 404 on every page but not on posts, I decided to put this permalink %postname%/%location%/%course%/%postname% but I need to strip the starting postname, in such a way I ll get no 404 pages and google will also index my site with this permalink /%location%/%course%/%postname% without any 404

how to do this????

This is my code, for displaying custom taxonomies on permalinks

add_filter('post_link', 'location_permalink', 10, 3);
add_filter('post_type_link', 'location_permalink', 10, 3);


    function location_permalink($permalink, $post_id, $leavename) {
        if (strpos($permalink, '%location%') === FALSE) return $permalink;

            // Get post
            $post = get_post($post_id);
            if (!$post) return $permalink;

            // Get taxonomy terms
            $terms = wp_get_object_terms($post->ID, 'location');    
            if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;
            else $taxonomy_slug = 'location';

        return str_replace('%location%', $taxonomy_slug, $permalink);
    }
share|improve this question
    
Can you post the code you're registering those taxonomies with? Assuming they're custom taxonomies that is. –  sanchothefat Jan 11 '11 at 15:30
    
I'm not trying to be snarky, but asking for you to please consider using capitalization where appropriate ("i" especially) and periods at the end of sentences. It's very hard to read your questions otherwise. Thanks in advance for helping those who aim to help you. –  MikeSchinkel Jan 11 '11 at 17:41
    
sorry for bad english, i ll rewrite my answer –  ntechi Jan 12 '11 at 4:57
    
@sanchothefat I am using GDCPT plugin for custom taxonomies, and it works fine with the posts, just to display the terms of custom taxonomies I am using a piece of code, check my original answer –  ntechi Jan 12 '11 at 5:11
add comment

1 Answer

up vote 1 down vote accepted

Apologies that this doesn't directly answer your question but If I were you I would use the following structure:

/%post_id%/%location%/%course%/%postname%

Using the id should help to speed up the page load as it reduces the amount of processing that WP needs to do to select the correct page and you still get a nice enough url.

share|improve this answer
    
I want my URL structure to start with Location, if I am starting it with Location, then all of my Pages are getting 404 error, only posts are opening, do you have any suggestions why is it happening so? –  ntechi Jan 13 '11 at 4:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.