Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/03/2013, 02:52
Eric_Draven
 
Fecha de Ingreso: mayo-2011
Mensajes: 18
Antigüedad: 12 años, 11 meses
Puntos: 0
Excluir galerías según su categoría (Condicional de WP)

Buenas.

Tengo un theme de Fotografía con galerías propias y su correspondiente categoría, (no las de wordpress, están creadas para las galerías)

Este es el código cuando editas una categoría:

Código:
edit-tags.php?action=edit&taxonomy=gallery_cats&tag_ID=6&post_type=galleries

En toda galería muestra en un popup el resto de galería por si quieres ver el resto. Te muestra todas.

Ahora bien, yo quiero que si estás en una categoría, solo te muestre las galarías de la misma categoría:

En este código se forma ese mini popup

Código:
if ( $data['gallery_related'] == '1' ) {
			
			$wpex_current_post_id = get_the_ID(); // Get current post ID to exclude in the loop below
			// Get post type ==> photos
			global $post;
			$args = array(
				'post_type' =>'galleries',
				'numberposts' => -1,
				'exclude' => $wpex_current_post_id,
				'suppress_filters' => false //WPML support,
			);
			$gallery_posts = get_posts($args); ?>
				
			<div id="popup-galleries">
				<a href="#popup-galleries-close" id="popup-galleries-close">&times;</a>
				<div id="popup-galleries-inner">
					<div id="galleryScroller" class="scroller-con" style="width: 930px; height: 160px;">
						<div class="inner">
								<?php
								// If there are posts load the loop-photos.php file
								// which contains the layout for single photos posts for each post in the loop
								foreach($gallery_posts as $post) : setup_postdata($post);
								
									// Get resize and show featured image : refer to functions/img_defaults.php for default values
									$wpex_gallery_entry_img = aq_resize( wp_get_attachment_url( get_post_thumbnail_id(), 'full' ),  wpex_img( 'gallery_popup_width' ), wpex_img( 'gallery_popup_height' ), wpex_img( 'gallery_popup_crop' ) );
									if($wpex_gallery_entry_img) {  ?>
										<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $wpex_gallery_entry_img; ?>" alt="<?php the_title(); ?>" /></a>
									<?php }
								endforeach; ?>
						</div><!-- /inner -->
					</div><!-- /galleryScroller -->
				</div><!-- popup-galleries-inner -->
			</div><!-- /popup-galleries -->
        
        	<?php wp_reset_postdata(); // Reset the postdata in order to prevent any loop conflicts later on
		}
	}
Aqui: $wpex_current_post_id = get_the_ID(); // Get current post ID to exclude in the loop below

Obtiene la ID de esa galaría y se excluye de abajo. La idea es modificar esa variable para que no solo excluya una ID, sino todas las ID de una categoría. Pero no consigo que coja todas las IDs de galerías de una categoría

He probado con los condicionales de wordpress, con el "is_single ()" consigo que si estás en una galería expecífica me excluya otra galería, pero es muy concreto, y no es plan que ponga todas las IDs porque no funcionaría con futuras galerías.

No sé si me he explicado bien.

Gracias por adelantado.