Ciao a tutti, il mio problema è semplice ma non riesco a trovare una soluzione e non so se sia presente una funzione che permetta di farlo…
Solitamente per chiamare ad esempio in index solo i post di una determinata categoria uso il seguente codice:
<?php $posts = get_posts( “category=1,11&numberposts=4” ); ?>
<?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<h2>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endforeach; ?>
<?php endif; ?>
Vorrei però che l’utente dal pannello admin non dovesse selezionare ogni volta la categoria “1” (madre) e le sue subcategory (child) ma semplicemente selezionare la subcategory in modo che compaia direttamente in index…
Per questo pensavo ad una cosa tipo la chiamata per la lista delle category nella sidebar usando la funzione “child_of=1”:
<?php $posts = get_posts( “child_of=1&numberposts=4” ); ?>
ma vedo che non funziona. Qualche suggerimento (sempre se sono riuscito a far capire il “problema”)?
GRAZIE!