Forum Replies Created

  • Muchas gracias por tu trabajo.
    Ha el problema ha quedado resuelto.
    Ya convenci al admin para que utilize categorias diferentes en cada subasta.

    Aunque estas categorias tengan el mismo nombre, si cambiamos el slug funcionara correctamente.

    Ya que despues de todo el trabajo que me continuaba mostrando categorias que tenian post de otras subastas. Eso se produce, supongo, por que la funcion get_terms me trae todos los terminos que no estan vacios, sin considerar a que subasta pertenecen.

    SALUDOS y muchas gracias por tu trabajo.

  • hi,
    I’m sorry my friend, I don’t understand you.
    Sorry I’m not that good with WordPress.

    Should I manipulate the get_terms function with one of its many parameters?
    I tried to follow you but it didn’t work.

       $categories = get_terms( 'type_produc', array(
                            'orderby' =>   'count',
                            'hide_empty' => true,
                            'fields'     => 'ids' // (or parent) but not found 
                        ) );

    What you are telling me is that first I must save the posts that produce the code you gave me and then look for the taxonomy of each one?

    Sorry I didn’t understand.
    Thanks for your help and sorry for not understanding.

  • Hi,
    Thank you very much for your help.
    I have been able to solve a large part of the problem.
    Thank you very much for responding so promptly.

    Order Custom Post Type by Taxonomy-OK

    The only problem with this solution is that WordPress shows me Taxonomies that have posts from other auctions.

    While WordPress does not show empty taxonomies thanks to the ‘hide_empty’ rule hide_empty => true , it does show taxonomies that have a custom post type but belong to another auction.

    Do you have any idea what I should change in the code below so that it only shows the taxonomies that are associated with the products of this auction?

    Greetings and thank you very much for your help.

    My code:

         $products = get_field('products_in_this_auction', false, false);      
                          $categories = get_terms( 'type_produc', array(
                            'orderby' =>   'count',
                            'hide_empty' => true
                        ) );
                          foreach( $categories as $category ): 
                          <h3 class="title_pru"><?php echo  $category->name;  ?></h3>
                        $query = get_posts(array(
                            'post__in' => $products,
                            'post_type' => 'myproduct',
                            'taxonomy' => $category->taxonomy,
                            'term' => $category->slug,
                            'nopaging' => true,
                          foreach($query as $post): 
                          <div id="post-<?php the_ID(); ?>">
                        <?php  the_title( sprintf( '<p class="title_pru"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></p>' ); ?>
                          </div><!-- #post-## --> 
                          <?php endforeach; ?>
                         <?php endforeach; ?>
Viewing 3 posts - 1 through 3 (of 3 total)