• Resolved yyy3

    (@yyy3)


    Hi everyone! I have a problem that’s driving me nuts

    I have registered my custom post type in my child theme, with corresponding custom taxonomies

    $args = array(
            'label'               => __( 'articles', 'onepress-child' ),
             
            'taxonomies'          => array( 'publications' ),
            
            'other_stuff'         => {...}
     
        );
        
        register_taxonomy('publications','articles', array(
        	'hierarchical' => false,
        	'labels' => $labels,
        	'show_ui' => true,
        	'show_in_rest' => true,
        	'show_admin_column' => true,
        	'update_count_callback' => '_update_post_term_count',
        	'query_var' => true,
        	'rewrite' => array( ),
      	 ));
        // Registering your Custom Post Type
        register_post_type( 'publications', $args ); 

    I’ve also made single-articles.php and taxonomy-publications.php

    So far so good, but both localhost/articles and localhost/publications show 404

    Am I correct in saying that localhost/publications should load the taxonomy-publications.php template?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter yyy3

    (@yyy3)

    Solved part of my problem, as localhost/publications/{publisher} now loads using the desired template taxonomy-publications.php

    Is there a way to set a “home page” for the entire taxonomy at localhost/publications that shows articles from all publishers according to a desired template?

    [Edit] Not sure what I did but I broke localhost/articles again ??

    • This reply was modified 3 years, 10 months ago by yyy3.
    Moderator bcworkz

    (@bcworkz)

    I think you meant to do register_post_type( 'articles', $args );. That’ll probably fix your articles query issue. When you add or change post types or taxonomies, you need to then visit the permalinks settings screen, which causes WP to regenerate its rewrite rules. You don’t need to change or save anything, loading the screen is enough.

    Normally requesting localhost/publications/ wouldn’t yield anything but a 404 page. It’s term requests like localhost/publications/foobar/ where taxonomy-publications.php would be used. If you want all articles shown when localhost/publications/ is requested, I suppose you could rewrite the request to localhost/articles/ in .htaccess.

    Thread Starter yyy3

    (@yyy3)

    I think you meant to do register_post_type( ‘articles’, $args );

    Yes that was definitely a problem ??
    Thank you so much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Am I using taxonomies correctly?’ is closed to new replies.