Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » WordPress »

short code gallery en un post personalizado

Estas en el tema de short code gallery en un post personalizado en el foro de WordPress en Foros del Web. alguien sabe por que el shortchode gallery no funciona en un post personalizado? muchas graicas...
  #1 (permalink)  
Antiguo 23/08/2013, 09:51
Avatar de engonga
Usuario no validado
 
Fecha de Ingreso: marzo-2002
Ubicación: Buenos Aires
Mensajes: 1.300
Antigüedad: 24 años, 7 meses
Puntos: 8
short code gallery en un post personalizado

alguien sabe por que el shortchode gallery no funciona en un post personalizado?

muchas graicas
  #2 (permalink)  
Antiguo 23/08/2013, 09:54
Avatar de engonga
Usuario no validado
 
Fecha de Ingreso: marzo-2002
Ubicación: Buenos Aires
Mensajes: 1.300
Antigüedad: 24 años, 7 meses
Puntos: 8
Respuesta: short code gallery en un post personalizado

la verdad es que si que funciona pero he añadido un filtro para modificar la galeria y cuando lo activo no me funcion


esto es la personalización de la galería

Código PHP:
// http://wordpress.stackexchange.com/questions/4343/how-to-customise-the-output-of-the-wp-image-gallery-shortcode-from-a-plugin

add_filter( 'post_gallery', 'my_post_gallery', 10, 2);
function 
my_post_gallery( $output, $attr) {
    global 
$post, $post_type $wp_locale;
    
    static 
$instance = 0;
    
$instance++;
    
    
// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    
if ( isset( $attr['orderby'] ) ) {
        
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
        if ( !
$attr['orderby'] )
        unset( 
$attr['orderby'] );
    }
    
    
extract(shortcode_atts(array(
    
'order'      => 'ASC',
    
'orderby'    => 'menu_order ID',
    
'id'         => $post->ID,
    
'itemtag'    => 'DIV',
    
'icontag'    => 'SPAN',
    
'captiontag' => 'P',
    
'columns'    => 1,
    
'size'       => 'large', // medium, large, full, 
    
'include'    => '',
    
'exclude'    => ''
    
), $attr));
    
    
$id = intval($id);
    if ( 
'RAND' == $order )
    
$orderby = 'none';
    
    
$galeriatipo = esc_attr($tipogal);
    
    
/*if ( $galeriatipo == "comun"){
        echo "se esta mostrando la galeria común    ";
        }else{
        echo "la galeria es especial   ";
    }*/
    
    
if ( !empty($include) ) {
        
$include = preg_replace( '/[^0-9,]+/', '', $include );
        
$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
        
        
$attachments = array();
        foreach ( 
$_attachments as $key => $val ) {
            
$attachments[$val->ID] = $_attachments[$key];
        }
    } elseif ( !empty(
$exclude) ) {
        
$exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
        
$attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
    } else {
        
$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
    }
    
    if ( empty(
$attachments) )
    return 
'';
    
    if ( 
is_feed() ) {
        
$output = "\n";
        foreach ( 
$attachments as $att_id => $attachment )
        
$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        return 
$output;
    }
    
    
$numero_imagenes = count($attachments);
    
    
    
    
$itemtag = tag_escape($itemtag);
    
$captiontag = tag_escape($captiontag);
    
$columns = intval($columns);
    
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
    
$float = is_rtl() ? 'right' : 'left';
    
$anchocontenedor = $numero_imagenes * 940; 
    
    
$selector = "gallery-{$instance}";
    
    
$output = apply_filters('gallery_style', '<!-- see gallery_shortcode() in wp-includes/media.php -->
    
    
    <div class="slider-wrapper theme-default">
    
    <div id="slider" class="nivoSlider">
    '
);
    
    
$i = 0;
    foreach ( 
$attachments as $id => $attachment ) {        
        
//$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        
$link =  wp_get_attachment_image($id, $size, true, false) ;
        
        
        
// para saber el ancho de la imagen
        
$image_attributes = wp_get_attachment_image_src( $id, $size ); // returns an array el [1] es l'amplada http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
        
        //$output .= "<{$itemtag} id='gallery-item-$i' class='slide'>\n";
        
$output .= $link ."\n";
        
/*$output .= "
            <{$icontag} class='gallery-icon'>
            $link
        </{$icontag}>";*/
        //$output .= "</{$itemtag}>\n";
        //if ( $columns > 0 && ++$i % $columns == 0 )
        //$output .="<br style="clear: both" />';
    
}
    
    
$output .= "
    </div> <!-- end of slider -->\n
    </div> <!-- end of  id='slider-wrapper theme-default' -->\n"
;
    
    return 
$output;
} 

Etiquetas: code, gallery, personalizado, post
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:09.