Ciao, ho implementato questo tema per la realizzazione di un sito.
Avrei la necessità di visualizzare nella pagina prodotti non tutte le sottocategorie dei prodotti, ma solamente una (ovvero: nel menu principale avrò la voce prodotti che mi fa visualizzare una descrizione generica. Le sottovoci della voce prodotti - prodotto1, prodotto2, prodotto3 devono visualizzare solo i prodotti di quella categoria, mentre ora vengono visualizzati tutti, vanificando di fatto la presenza di un sotto menu specifico).Si può visualizzare ciò che intendo selezionando menu -> fullmenu.
La pagina template che mostra queste categorie fa un array per il quale appunto tutte le categorie vengono mostrate. Come posso dirgli di mostrare invece solo la pagina che è stata selezionate in base a specifici id o nomi di pagina?
Spero di essere stato più o meno chiaro.
Pagina template:
Codice PHP:
<?php $ipaddress = getenv(REMOTE_ADDR); ?>
<div id="content" class="page menu col-full">
<div class="post-wrap">
<?php if ( function_exists('yoast_breadcrumb') ) { yoast_breadcrumb('<div id="breadcrumb">
','</p></div>'); } ?>
<?php if (have_posts()) : $count = 0; ?>
<?php while (have_posts()) : the_post(); $count++; ?>
<?php
//custom field
$menu_additional_info = get_post_meta($post->ID,'menu_additional_info',true);
$menu_pdf = get_post_meta($post->ID,'menu_pdf',true);
?>
<div class="post fl">
<h1 class="title">[url="<?php the_permalink() ?>"]"><?php the_title(); ?>[/url]</h1>
<div class="entry">
<?php the_content(); ?>
</div>
</div>
<div class="additional fr">
<h2><?php _e('Additional Info', 'woothemes'); ?></h2>
<?php echo $menu_additional_info; ?></p>
</div>
<div class="fix"></div>
<?php endwhile; endif; ?>
</div>
<div id="menu" class="full-width-menu">
<div class="info-bar">
<ul class="fl">
<?php if ($menu_pdf != '') { ?><li class="pdf">[url="<?php echo $menu_pdf; ?>"]<?php _e('Download PDF', 'woothemes'); ?>[/url]<?php } ?>
<li class="email <?php if ($menu_pdf == '') { echo 'no-pdf'; } ?>">[url="#"]<?php _e('Email to Friend', 'woothemes'); ?>[/url]
[/list]
<div class="order fr">
<span><?php _e('Order by:', 'woothemes'); ?></span>
<a id="sort-default" class="active" title="#"><?php _e('Default', 'woothemes'); ?></a>
<a id="sort-price" title="#"><?php _e('Price', 'woothemes'); ?></a>
<a id="sort-rating" title="#"><?php _e('Rating', 'woothemes'); ?></a>
</div>
<div class="fix"></div>
</div>
<?php
// Make menu system recursive. - 2010-11-14.
global $more;
// Set the global "more" value to activate/deactivate automated "More" links in the_content().
$more = 0; // Automated "More" links are set to "on". 0 = on, 1 = off.
// Add custom ordering to the menu types. - 2010-11-30.
$menu_ordering = get_option( 'woo_diner_menutype_orders' );
// If the menu ordering values returned aren't in an array, reset them as they're not correct.
if ( ! is_array( $menu_ordering ) ) {
$menu_ordering = array();
} // End IF Statement
function woo_food_menu_display( $parent_id, $menu_ordering ) {
$terms = get_terms( 'menutype', 'parent=' . $parent_id . '&hide_empty=0' );
$_terms = array();
// Loop through and sort the terms by their sort ordering setting.
if ( count( $terms ) ) {
foreach ( $terms as $t ) {
if ( ! in_array( $t->term_id, array_keys( $menu_ordering ) ) ) {
$_terms['0-' . $t->term_id] = $t;
} else {
$_ordering_value = $menu_ordering[$t->term_id];
if ( $_ordering_value < 10 ) {
$_ordering_value = '0' . $_ordering_value;
} // End IF Statement
$_terms[$_ordering_value . '-' . $t->term_id] = $t;
} // End IF Statement
} // End FOREACH Loop
} // End IF Statement
// Sort the terms by key.
ksort( $_terms );
if ( count( $_terms ) ) {
foreach ( $_terms as $k => $term ) {
// foreach ($terms as $term) {
// query_posts('post_type=woo_menu&menutype='.$term->slug);
$category_link = get_term_link( $term, 'menutype' );
?>
<table>
<thead>
<tr>
<th colspan="3"><h2><?php echo $term->name; ?> <?php if ($term->description != '') { ?><span class="asterix">[url="#info-1"]*[/url]</span> <?php } ?><span class="about-section">[url="<?php echo $category_link; ?>"]"><?php _e('More about this section', 'woothemes'); ?>[/url]</span></h2></th>
</tr>
</thead>
<?php if ($term->description != '') { ?>
<tfoot>
<tr class="asterix-info">
<td colspan="3"><span id="info-1">*</span> <?php echo $term->description; ?></td>
</tr>
</tfoot>
<?php } ?>
<tbody>
<?php
$query_args = array( 'post_type' => 'woo_menu','paged' => $paged, 'menutype' => $term->slug, 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => '-1' );
$the_query = new WP_Query($query_args);
if ($the_query->have_posts()) : $count = 0;
while ($the_query->have_posts()) : $the_query->the_post();
global $post;
$postid = get_the_ID();
$price = get_post_meta($postid,'price',true);
$meal_price = number_format($price , 2 , '.', ',');
$img_link = woo_image('return=true&link=img&key=thumbnail&width=170&height=140&class=thumbnail thickbox');
$img_url = get_post_meta($postid,'thumbnail',true);
// Get the terms assigned to this post.
$_terms_obj = get_the_terms( $postid, 'menutype' );
// Create an array of the assigned term IDs.
$_terms = array_keys( $_terms_obj );
if ( in_array( $term->term_id, $_terms ) ) :
?>
<tr id="<?php echo $postid; ?>">
<td class="image">[url="<?php echo $img_url; ?>"]"><?php echo $img_link; ?>[/url]</td>
<td class="details">
<h3>[url="<?php the_permalink() ?>"]"><?php the_title(); ?>[/url]</h3>
<?php the_content( __( '(more...)', 'woothemes' ) ); ?>
</td>
<td class="price"><?php echo get_option('woo_diner_currency').''.$meal_price; ?>
<span id="vote-<?php echo $postid; ?>" class="rating-images"><?php echo woo_get_post_rating_form($postid,$ipaddress); ?></span></td>
</tr>
<?php
endif; // End IF ( in_array() ) IF Statement
endwhile;
endif;
?>
</tbody>
</table>
<?php
woo_food_menu_display( $term->term_id, $menu_ordering );
} // End FOREACH Loop
} // End IF Statement
} // End woo_food_menu_display()
woo_food_menu_display( 0, $menu_ordering );
?>
</div>
</div>