Taxonomy + post_type

I’m quite lost with taxonomies and custom post type.

  • I have a taxonomy -> auteur
  • I have custom_post-type -> citation (quote in french).

I just want list all citations (quote) from an auteur (auteur = taxonomy) with a permalink structure like this :

Read More
www.myblogname.com/citation/auteur_name/

or

www.myblogname.com/auteur_name/citation/

or

www.myblogname.com/auteur/auteur_name/citation/

( in fact the easiest way).

what are the steps to do this job (and what is the template page to modify).

Related posts

Leave a Reply

3 comments

  1. Don’t know how did you set the post type and the taxonomy, but by default I think you’re supposed to see all quotes from an author through myblogname.com/the-author-name.

    If you want to place static words such auteur or citation in the link, then this is related to how you set the options for creating the post type and/or the taxonomy. (register_post_type and register_taxonomy).

    Note: you can’t use author (in english) because this slug already exists in WordPress (See Reserved terms).

    About theme files, when you view a quotes list from an author (a taxonomy in this case), your theme uses taxonomy.php file, you can create this file if doesn’t exists, see Template Hierarchy

  2. You can try this approach:

    $args = array(           
                'hierarchical' => true,
                'show_ui' => true,
                'show_admin_column' => true,
                'query_var' => true,
                'rewrite' => array( 'slug' => 'citation/auteur' )
            );
    register_taxonomy('auteur','citation',$args);
    

    When you do that you can list and filter your citations by auteurs.
    Just type in the address bar http://yoursite.com/citation/auteur/auter_name.
    But remember that the “autor_name” have to be a slug.

  3. You can use the query below for this issue.

    // WP_Query arguments
    $args = array (
    'post_type'              => 'my_custom_post_type',
    'slug'                   => 'citation/auteur',
    'post_status'            => 'publish',
    'author_name'            => 'author_name',
    'order'                  => 'DESC',
    );
    
     // The Query
    $my_query = new WP_Query( $args );
    
    // The Loop
    if ( $my_query->have_posts() ) {
    while ( $my_query->have_posts() ) {
        $my_query->the_post();
        // do something
    }
    } else {
     // no posts found
    }
    
    // Restore original Post Data
      wp_reset_postdata();
    

    Please replace your post type, author name & others with default options.