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 am triying to modify wordpress (version 3.3) for that the listing to be able to show posts from one taxomy and one category.

I have installed two plugin:

WP No Category Base WP No Taxonomy Base

These allow me to show post with this kind of url: domain[.]com/taxonomy-1 and domain[.]com/category-1

At this poing I am triying to get the results with domain[.]com/taxonomy-1/category-1

¿Which is the function about this?

share|improve this question
    
What have you tried already? Show us your code. –  toscho Sep 20 '12 at 7:49

3 Answers 3

You are going to have to get into URL re-writing which is notoriously pretty complex. However, there are several good answers on this site explaining how to do something similar. This one in particular

Many to Many Taxonomies or rewrite rules?

I also followed the tutorial Advanced Taxonomy Queries with Pretty Urls... which is very similar in scope.

share|improve this answer
    
Thank you, your links were very usefull. To achieve "taxonomy/category" form, is necessary to store a rule for each combination. At this point, i have choiced to have a base for each concept. Solution in the bottom. –  videador Sep 26 '12 at 8:38
function eg_add_rewrite_rules() {
    global $wp_rewrite;

    $new_rules = array(
        'location/(.+)/category/(.+)/?$' => 'index.php?location=' . $wp_rewrite->preg_index(1) . '&category_name=' . $wp_rewrite->preg_index(2)
    );
    $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_action( 'generate_rewrite_rules', 'eg_add_rewrite_rules' );

Does not work :(

share|improve this answer

Problem solved changing base name of category and taxonomy (not removing)

In functions.php (or in plugin if you want).

You must put this code to rewrite this url www.example.org/en/[mylocation]/de/[mycategory]

  add_action('init', 'flush_rewrite_rules'); 
  add_filter('category_rewrite_rules' , 'add_rules' ) ;  

  function flush_rules() {

    global $wp_rewrite;
    $wp_rewrite->flush_rules();

  }

  function add_rules($rules) 
  {
    /**
     * Loop em.
     * -------------------------------------------- */    

    $feed_rule  = 'index.php?location=$matches[1]&category_name=$matches[2]&feed=$matches[3]';
    $paged_rule = 'index.php?location=$matches[1]&category_name=$matches[2]&paged=$matches[3]';
    $base_rule  = 'index.php?location=$matches[1]&category_name=$matches[2]';

    $rules['en/([^/]+)/de/([^/]+)/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = $feed_rule;
    $rules['en/([^/]+)/de/([^/]+)/page/?([0-9]{1,})/?$']                  = $paged_rule;
    $rules['en/([^/]+)/de/([^/]+)/?$']                                    = $base_rule;

    $feed_rule2  = 'index.php?location=$matches[1]&feed=$matches[2]';
    $paged_rule2 = 'index.php?location=$matches[1]&paged=$matches[2]';
    $base_rule2  = 'index.php?location=$matches[1]';

    $rules['en/([^/]+)/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = $feed_rule2;
    $rules['en/([^/]+)/page/?([0-9]{1,})/?$']                  = $paged_rule2;
    $rules['en/([^/]+)/?$']                                  = $base_rule2;


    return $rules;

  }
share|improve this answer
    
Glad you have this sorted. One item of note, you should not flush the re-write rules on the init hook. This means the rules will be flushed and re-written every time your site loads. This is very inefficient. The rules can be flushed simply by re-saving your permalinks. –  helgatheviking Sep 26 '12 at 21:22
    
Thank you for the anwser, so, please, ¿what is the action to save permalinks? –  videador Nov 19 '12 at 11:39
    
In the admin, go to Options->Permalinks and then save changes. –  helgatheviking Nov 20 '12 at 13:11

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.