Risolto Loop non funziona correttamente

Stato
Discussione chiusa ad ulteriori risposte.

NoName00

Utente Electrum
27 Agosto 2010
162
24
4
115
Ultima modifica:
Buongiorno, come da titolo ho un problema con il loop di wordpress, ho bisogno che mi mostri gli elementi con id 5 della tassonomia categoria macchinario, il titolo lo mostra correttamente mentre del contenuto ne fa un mischione. Mi spiego meglio, in tag_id[5] Ho i torni e in tag_id[4] ho i centri di lavoro, come titolo mi mostra correttamente Torni mentre negli elementi stampati mi mischia i torni e i centri di lavoro, quale potrebbe essere l'errore? perché me li mischia?
PHP:
<?php
/**
* Template Name: Template Macchinari Torni
* A custom page template for products pages
*
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/

get_header(); ?>
<?php $args = array(
    'taxonomy_name' => 'categria_macchinario',
    'post_type' => 'macchinario',
    //'slug' => 'torni',
    'tag_ID' => 5,
    //'orderby' => 'name',
    //'order' => 'ASC',
    'posts_per_page' => 15,
);
 
$query = new WP_query($args);
$tax_id = get_term(5); //Example term ID
//$categories = get_the_category($id);
?>
<h1> <?php echo $tax_id->name; ?>  </h1>   <?php //get term name?>
<section class="section-content">
        <div class="container">

                <div class="col-xs-12">
                    <div class="products-page" >  
                    <?php if ( $query->have_posts() ) while ( $query->have_posts() ) : $query->the_post(); ?>

   
                        <div class="col-md-4" style=" box-shadow:5px 5px 5px gray; padding:10px; height:280px;">
                            <h4 class="categ-feat-title  text-center"><?php echo the_title(); ?></h4>
                            <?php the_post_thumbnail();?>
       
                        </div>
                       
           
                    <?php endwhile; ?>
                    </div>
                </div><!-- End Right Column -->
        </div> <!-- End Container fluid -->


    </section>
<!-- Pre-footer -->
<?php get_template_part( 'part', 'pre-footer' ); ?>

<?php get_footer(); ?>
cci tua.png

Messaggio unito automaticamente:

Ho risolto inserendo un'ulteriore filtro in $args, lo posto nel caso qualcun altro avesse lo stesso problema
Codice:
'taxonomy' => 'categria_macchinario',
    'post_type' => 'macchinario',
    //'slug' => 'torni',
    'tag_ID' => 4,
    //'orderby' => 'name',
    //'order' => 'ASC',
    'posts_per_page' => 15,
    --->'tax_query' => array(
        array(
            'taxonomy' => 'categoria_macchinario',
            'field' => 'id',
            'terms' => (4),
            'include_children' => false, <---
            
        )
    )
Potete chiudere
 
Stato
Discussione chiusa ad ulteriori risposte.