WordPress.org

Ready to get started?Download WordPress

Forums

probleme taxonomy.php (8 posts)

  1. fxbenard
    Member
    Posted 3 years ago #

    Hi, i'm using this to display my taxonomy, everything works fine for the name but i don't have no post displaying under it, i got the 'Sorry, no posts matched your criteria'.

    <?get_header(); ?>
    <? $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?>
            <div id="container">
                <div id="content" role="main">
    
                    <h1 class="page-title"><?php
                        printf( __( 'Posts classified under: %s', 'twentyten' ), '<span>' . $term->name . '</span>' );
                    ?></h1>
    
                    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <?php the_excerpt(); ?>
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
                </div><!-- #content -->
            </div><!-- #container -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  2. chinmoy
    Member
    Posted 3 years ago #

    have you register custom taxonomy? or using any plugin?

    First create a custom taxonomy post and then check once.

  3. fxbenard
    Member
    Posted 3 years ago #

    My custom taxonomy is created already by hand with no plug in

    add_action('init', 'my_custom_init');
    
    function my_custom_init() {
      $labels = array(
        // You can alter the text on any of these
        'name' => _x('Pharmacie', 'post type general name'),
        'singular_name' => _x('Item', 'post type singular name'),
        'add_new' => _x('Add Item', 'Event Item'),
        'add_new_item' => __('Add New Item'),
        'edit_item' => __('Edit Item'),
        'new_item' => __('New Item'),
        'view_item' => __('View Item Details'),
        'search_items' => __('Search Pharmacie Items'),
        'not_found' =>  __('Element non trouve'),
        'not_found_in_trash' => __('No portfolio items found in the Trash with that criteria'),
        'view' =>  __('Voir Item')
      );
    
      $args = array(
        'labels' => $labels,
        // We can give our post type a description in case we forget what its for
        'description' => 'This is the holding location for all pharmacie items',
        'public' => true,
        'publicly_queryable' => true,
        // To keep in the search, or to not keep in the search. That is the question.
        'exclude_from_search' => true,
        'show_ui' => true,
        'rewrite' => true,
        'hierarchical' => true,
        'menu_position' => 5,
        'supports' => array('title', 'editor', 'thumbnail', 'custom-fields', 'revisions')
      );
    
      register_post_type('pharmacie',$args);
    }
    
    // Register References taxonomy
    $labels = array(
      'name' => _x( 'References', 'taxonomy general name' ),
      'singular_name' => _x( 'Reference', 'taxonomy singular name' ),
      'search_items' =>  __( 'Search references' ),
      'popular_items' => __( 'References' ),
      'all_items' => __( 'Tous' ),
      'parent_item' => __( 'Parent References' ),
      'parent_item_colon' => __( 'Parent reference:' ),
      'edit_item' => __( 'Editer References' ),
      'update_item' => __( 'Mettre a jour' ),
      'add_new_item' => __( 'Ajouter nouvelle reference' ),
      'new_item_name' => __( 'New reference Name' )
    );
    
    register_taxonomy('xyz',array('pharmacie'), array(
      // Make sure you set hierarchical to true
      'hierarchical' => true,
      'labels' => $labels,
      'show_ui' => true,
      'query_var' => true,
      // You can rename the slug to whatever you like, just make sure its unique
      // Make sure you remember what it was because you'll need it later
      'rewrite' => array( 'slug' => 'xyz' )
    ));
  4. fxbenard
    Member
    Posted 3 years ago #

    Ok i made a new "taxotest" taxonomy in my post and not in my custom field "pharmacie" and like this it works. how can i fix it to make it work for my xyz taxonomy, thanks

  5. chinmoy
    Member
    Posted 3 years ago #

    'rewrite' => array( 'slug' => 'xyz' ) would be true or false

  6. fxbenard
    Member
    Posted 3 years ago #

    i don't understand how to make it true or false

  7. fxbenard
    Member
    Posted 3 years ago #

    i tried with
    'rewrite' => array( 'slug' => 'xyz','with_front' => false ) and
    'rewrite' => array( 'slug' => 'xyz','with_front' => true )
    nothing changed my taxonomy works when it's in my post section but not when it's in my custom field

  8. fxbenard
    Member
    Posted 3 years ago #

    A little up, i'm still stuck with this, thanks

Topic Closed

This topic has been closed to new replies.

About this Topic