• Hi, community.
    I am working on a website with movie reviews. I did some changes in the code and now I cannot access the archive pages of the taxonomies anymore. The website is based on the _s-master theme, and I coded it myself. But as the site grew bigger and bigger, I got lost in my own code. ??

    in my functions.php I have this:

    
    
    function genre_init() {
    	// create a new taxonomy
    	register_taxonomy(
    		'review_taxonomy_1',
    		array('post', 
    			  'os_review', 
    			  'os_buch_review', 
    			  'os_classic_review', 
    			  'os_versus'  ),
    		array(
    		    'hierarchical'    => true,
    			'label' => __( 'Genre' ),
    			'rewrite' => array( 'slug' => 'review-genre' ),
    		)
    	);
    }
    add_action( 'init', 'genre_init' ); 
    
    

    And this:

    
    function custom_taxonomies_terms_links_genre() {
        global $post;
        //custom taxonomy:
        $taxonomies = array( 
                             "review_taxonomy_1"=>"Genre: "
                      );
        foreach ($taxonomies as $tax => $taxname) {     
            
            // get the terms related to post
            $terms = get_the_terms( $post->ID, $tax );
            if ( !empty( $terms ) ) {
                foreach ( $terms as $term )
                    $out .= '<a>slug, $tax) .'">'.$term->name.'</a> ';
            }
        }
        return $out;
    }

    So what would be the URL of a movie within the genre “action” or “horror”? Can anybody see that in the code I posted? Or if not. Does anybody know how the URL of a specific taxonomy is created?

    Thanks a lot!
    Raphael

    • This topic was modified 3 years, 11 months ago by rabox66.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter rabox66

    (@rabox66)

    I could resolve it myself. Maybe somebody has a similar problem, therefore my solution. Given that the domain is example.com it would be like:

    1) The URL for the genre “action” would be like that: https://example.com/review-genre/action That was that was I read in the code, but it did not work. ??

    2) My problem was, that I did not flush the permalinks. So I changed the permalink-structure from “postname” to the normal permalink and then I changed id again to the pretty permalink with “postname” as a part of the URL. After doing so, it worked.

    Moderator bcworkz

    (@bcworkz)

    Thanks for coming back with your solution! It’s a common problem when we add our own custom taxonomies. When plugins add taxonomies, they can call flush_rewrite_rules(); to achieve the same end. If you decide to do this, it should only be done once upon plugin activation. Doing so on every request will seriously slow down your site.

    For self-coded taxonomies, it’s much easier to flush through the permalinks settings. FWIW, you don’t actually have to change anything, simply visiting the settings screen will flush the rules on its own.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘What is the URL of my taxonomies’ is closed to new replies.