brayancardiet
Respuestas de foro creadas
-
Foro: Guías – Resolución de problemas
En respuesta a: Crear un slider con imagenes de postForo: Guías – Resolución de problemas
En respuesta a: Crear un slider con imagenes de postesta es una de las formas que he intentado pero siempre el slider muestra una sola informacion porque obviamente el foreach esta llenando las llamadas de imagenes, he intentado con un if que llene variables que contenga el link de las imagenes pero no imprimen igual
Foro: Guías – Resolución de problemas
En respuesta a: problema con the_excerptCerrado
Foro: Guías – Resolución de problemas
En respuesta a: problema con the_excerptpara los que quieran saber la solucion aqui esta, el cambio fue en este script `<?php
$args =
array(
‘post_type’ => ‘post’,
‘numberposts’ => 4,
‘orderby’ => ‘date’,
‘order’ => ‘DESC’,
‘post_status’ => ‘publish’,
‘category__not_in’ => array( 7 ),
);
$list_post = get_posts( $args );
foreach ($list_post as $post):
setup_postdata( $post );?>`
solo cambie el nombre de las variables para separar ya que uso script de otros sidebar con los mismos nombre de variables
tambien deje de usar
the_excerpt_max_charlength(160)
y en cambio usethe_excerpt($post-->ID)
y para que mostrara la cantidad de texto necesario recorte la cantidad de texto con una funcion en mi archivoFunction.php
:function custom_excerpt_length( $length ) { return 30; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
agrege este codigo
setup_postdata( $post );
y quedo asi:
<section id="news_last" class="row"> <div id="news_content" class="col-xs-6"> <?php $args = array( 'post_type' => 'post', 'numberposts' => 4, 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish', 'category__not_in' => array( 7 ), ); $list_post = get_posts( $args ); foreach ($list_post as $post): setup_postdata( $post ); ?> <div class="row item"> <div class="col-xs-12"> <a href="<?php echo get_permalink($post->ID); ?>"> <h4><?php echo get_the_title($post->ID); ?></h4> </a> <div class="row info"> <div class="col-xs-12 head"> <?php $post_categories = wp_get_post_categories( $post->ID ); foreach($post_categories as $c): $cat = get_category( $c ); $color = get_field('categoria_color', $cat); ?> <a class="category-link pull-left" href="<?php echo get_category_link( $cat->term_id ); ?>"> <span class="etiqueta" style="background: <?php echo $color; ?>"><?php echo $cat->name; ?></span> </a> <?php break; endforeach; ?> <?php $post_date = get_the_date( 'Y-m-d H:i:s', $post->ID ); $hace = new haceTanto($post_date,'h'); ?> <span class="time pull-left"><i class="fa fa-clock-o"></i> hace <?php echo $hace; ?></span> <span class="share pull-left"> <ul class="nav nav-pills"> <li role="presentation"><a target="_blank" data-href="<?php echo get_permalink($post->ID); ?>" href="https://www.facebook.com/sharer/sharer.php?u=www.revistapolicial.pe/<?php echo get_permalink($post->ID); ?>"><i class="fa fa-facebook"></i></a></li> <li role="presentation"><a target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo get_the_title($post->ID); ?>&url=<?php echo get_permalink($post->ID); ?>"><i class="fa fa-twitter"></i></a></li> </ul> <div class="clearfix"></div> </span> </div> </div> <div class="info_news row"> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <?php if (has_post_thumbnail()): ?> <img src="<?php the_post_thumbnail_url( $post->ID, 'medium' ); ?>" class="img-responsive" alt="<?php echo get_the_title($post->ID); ?>"> <?php else: ?> <img src="<?php echo get_template_directory_uri(); ?>/assets/image/post-especial.png" class="img-responsive" alt="<?php echo get_the_title($post->ID); ?>"> <?php endif ?> </div> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <p> <?php the_excerpt($post->ID); ?> </div> </div> </div> </div> <hr> <?php endforeach;?> </div> <!---------------------------------------------------------------------------------------------------(1865)--> <div id="news_ultimas" class="col-xs-3 news_ult"> <div class="col-xs-12 news"> <div class="content"> <div class="header"> <h4>Últimas Noticias</h4> </div> <?php $args = array( 'post_type' => 'post', 'numberposts' => 4, 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish', 'tax_query' => array( array( 'taxonomy' => 'news', 'field' => 'slug', 'terms' => 'ultimas-noticias' ) ), ); $posts = get_posts( $args ); foreach ($posts as $post): ?> <div class="info-item"> <a class="title" href="<?php echo get_permalink($post->ID); ?>"> <?php echo get_the_title($post->ID); ?> </a> <div class="meta"> <?php $post_categories = wp_get_post_categories( $post->ID ); foreach($post_categories as $c): $cat = get_category( $c ); $color = get_field('categoria_color', $cat); ?> <a class="etiqueta pull-left" href="<?php echo get_category_link( $cat->term_id ); ?>" style="color: <?= $color?>"> <?php echo $cat->name; ?> </a> <?php break; endforeach; ?> <?php $post_date = get_the_date( 'Y-m-d H:i:s', $post->ID ); $hace = new haceTanto($post_date,'h'); //$fecha2 = new DateTime($post_date); //$hace = hace($fecha2); ?> <center> <span class="time"><i class="fa fa-clock-o"></i> hace <?php echo $hace; ?></span> </center> <span class="share pull-right"> <ul class="nav nav-pills"> <li role="presentation"><a target="_blank" data-href="<?php echo get_permalink($post->ID); ?>" href="https://www.facebook.com/sharer/sharer.php?u=www.revistapolicial.pe/<?php echo get_permalink($post->ID); ?>"><i class="fa fa-facebook"></i></a></li> <li role="presentation"><a target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo get_the_title($post->ID); ?>&url=<?php echo get_permalink($post->ID); ?>"><i class="fa fa-twitter"></i></a></li> </ul> <div class="clearfix"></div> </span> </div> <div class="img"> <a href="<?php echo get_permalink($post->ID); ?>"> <?php if (has_post_thumbnail()): ?> <img src="<?php the_post_thumbnail_url( $post->ID, 'post-verde' ); ?>" class="img-responsive" alt="<?php echo get_the_title($post->ID); ?>"> <?php else: ?> <img src="<?php echo get_template_directory_uri(); ?>/assets/image/post-verde.png" class="img-responsive" alt="<?php echo get_the_title($post->ID); ?>"> <?php endif ?> </a> </div> <hr> </div> <?php endforeach; ?> </div> </div> </div> <!--------------------------------------------------------------------------------------------(1988)--> <div id="home-aside" class="col-xs-3 meta publicidad"> <?php if (is_page( 'prevencion' )) { if ( is_active_sidebar( 'widget-aside-page-prevencion' ) ){ dynamic_sidebar( 'widget-aside-page-prevencion' ); } }elseif (is_page( 'orientacion' )) { if ( is_active_sidebar( 'widget-aside-page-prevencion' ) ){ dynamic_sidebar( 'widget-aside-page-prevencion' ); } }else{ if ( is_active_sidebar( 'widget-aside-page-prevencion' ) ){ dynamic_sidebar( 'widget-aside-page-prevencion' ); } } ?> </div> </section>
- Esta respuesta fue modificada hace 5 años, 9 meses por brayancardiet.
Foro: Guías – Resolución de problemas
En respuesta a: problema con the_excerptte amo wey jajajajaja ya solucione, estaba haciendo dos veces el proceso por eso tenia doble foreach.
gracias por la solucion
y perdona tanta molestia un saludo
Foro: Guías – Resolución de problemas
En respuesta a: problema con the_excerptsi cambio
the_excerpt_max_charlength(160)
porthe_excerpt($post->ID)
toman su orden las descripciones de los post pero por elendforeach;
se sigue inprimiendo varias veces por postForo: Guías – Resolución de problemas
En respuesta a: problema con the_excerpty que la primera descripcion pertenece a el ultimo post de los 4
Foro: Guías – Resolución de problemas
En respuesta a: problema con the_excerptpor lo que veo mi problema es este
endforeach;
pero intento eliminarlo y se va todo mi php lo he intentado mover y obviamente se imprime en diferentes tamaños y maneras pero creo que si logro sacar este foreach del codigo solo se imprimiria lo necesario<p> <?php $list_post = get_posts( $args ); foreach ($list_post as $post): the_excerpt_max_charlength(60); setup_postdata( $post ); endforeach; ?> <?php
Foro: Guías – Resolución de problemas
En respuesta a: problema con the_excerptveo progresoo..!!!
ya casi despues de ir probando volvi a tu solucion inicial y me ha ido mejor, solo que el corte de la informacion se da dentro de un post
sera que puedes ver si ves algo fuera de lugar? ya creo que es el
endforech;
que hay que ubicarlo mejory perdona la molestia
-…………………………………………………………………-
<section id="news_last" class="row"> <div id="news_content" class="col-xs-6"> <?php $args = array( 'post_type' => 'post', 'numberposts' => 2, 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish', 'category__not_in' => array( 7 ), ); $list_post = get_posts( $args ); foreach ($list_post as $post): ?> <div class="row item"> <div class="col-xs-12"> <a href="<?php echo get_permalink($post->ID); ?>"> <h4><?php echo get_the_title($post->ID); ?></h4> </a> <div class="row info"> <div class="col-xs-12 head"> <?php $post_categories = wp_get_post_categories( $post->ID ); foreach($post_categories as $c): $cat = get_category( $c ); $color = get_field('categoria_color', $cat); ?> <a class="category-link pull-left" href="<?php echo get_category_link( $cat->term_id ); ?>"> <span class="etiqueta" style="background: <?php echo $color; ?>"><?php echo $cat->name; ?></span> </a> <?php break; endforeach; ?> <?php $post_date = get_the_date( 'Y-m-d H:i:s', $post->ID ); $hace = new haceTanto($post_date,'h'); ?> <span class="time pull-left"><i class="fa fa-clock-o"></i> hace <?php echo $hace; ?></span> <span class="share pull-left"> <ul class="nav nav-pills"> <li role="presentation"><a target="_blank" data-href="<?php echo get_permalink($post->ID); ?>" href="https://www.facebook.com/sharer/sharer.php?u=www.revistapolicial.pe/<?php echo get_permalink($post->ID); ?>"><i class="fa fa-facebook"></i></a></li> <li role="presentation"><a target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo get_the_title($post->ID); ?>&url=<?php echo get_permalink($post->ID); ?>"><i class="fa fa-twitter"></i></a></li> </ul> <div class="clearfix"></div> </span> </div> </div> <div class="info_news row"> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <?php if (has_post_thumbnail()): ?> <img src="<?php the_post_thumbnail_url( $post->ID, 'medium' ); ?>" class="img-responsive" alt="<?php echo get_the_title($post->ID); ?>"> <?php else: ?> <img src="<?php echo get_template_directory_uri(); ?>/assets/image/post-especial.png" class="img-responsive" alt="<?php echo get_the_title($post->ID); ?>"> <?php endif ?> </div> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <p> <?php $list_post = get_posts( $args ); foreach ($list_post as $post): the_excerpt_max_charlength(60); setup_postdata( $post ); endforeach; ?> <?php ?> </p> </div> </div> </div> </div> <hr> <?php endforeach;?> </div>
Foro: Guías – Resolución de problemas
En respuesta a: problema con the_excerptya saque los
break;
que puse extra y igual, sigue cortando el contenido que va despues delendwhile;
Foro: Guías – Resolución de problemas
En respuesta a: problema con the_excerptel detalle de los break es intentando que termine el ciclo y no mate las etiquetas
el div lo chequeoForo: Guías – Resolución de problemas
En respuesta a: problema con the_excerptahora lo que hare sera separar ese codigo en un modulo a ver si deja de matar todo el codigo sobrante (en caso de no saber cual endwhile hablo del que esta sobre el separador <!—–1865–>
gracias de antemano
Foro: Guías – Resolución de problemas
En respuesta a: problema con the_excerptholaa, logre hacer que mostrara cada texto con un while y no un foreach
pero desde el endwhile;?> en adelante mata a todas mis etiquetas html y php
dejo todo el codigo, espero puedan ayudarme con lo que estoy olvidando<hr> <section id="news_last" class="row"> <div id="news_content" class="col-xs-6"> <?php while ( have_posts() ) : the_post(); ?> <div class="row item"> <div class="col-xs-12"> <a href="<?php echo get_permalink($post->ID); ?>"> <h4><?php the_title(); ?></h4> </a> <div class="row info"> <div class="col-xs-12 head"> <?php $post_categories = wp_get_post_categories( $post->ID ); foreach($post_categories as $c): $cat = get_category( $c ); $color = get_field('categoria_color', $cat); ?> <a class="category-link pull-left" href="<?php echo get_category_link( $cat->term_id ); ?>"> <span class="etiqueta" style="background: <?php echo $color; ?>"><?php echo $cat->name; ?></span> </a> <?php break; endforeach; ?> <?php $post_date = get_the_date( 'Y-m-d H:i:s', $post->ID ); $hace = new haceTanto($post_date,'h'); ?> <span class="time pull-left"><i class="fa fa-clock-o"></i> hace <?php echo $hace; ?></span> <span class="share pull-left"> <ul class="nav nav-pills"> <li role="presentation"><a target="_blank" data-href="<?php echo get_permalink($post->ID); ?>" href="https://www.facebook.com/sharer/sharer.php?u=www.revistapolicial.pe/<?php echo get_permalink($post->ID); ?>"><i class="fa fa-facebook"></i></a></li> <li role="presentation"><a target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo get_the_title($post->ID); ?>&url=<?php echo get_permalink($post->ID); ?>"><i class="fa fa-twitter"></i></a></li> </ul> <div class="clearfix"></div> </span> </div> </div> <div class="info_news row"> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <?php if (has_post_thumbnail()): ?> <img src="<?php the_post_thumbnail_url( $post->ID, 'medium' ); ?>" class="img-responsive" alt="<?php echo get_the_title($post->ID); ?>"> <?php else: ?> <img src="<?php echo get_template_directory_uri(); ?>/assets/image/post-especial.png" class="img-responsive" alt="<?php echo get_the_title($post->ID); ?>"> <?php endif ?> </div> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <p> <?php the_excerpt_max_charlength(160); ?> </p> </div> </div> </div> </div> <hr> <?php endwhile; ?> </div> <!---------------------------------------------------------------------------------------------------(1865)--> <div id="news_ultimas" class="col-xs-3 news_ult"> <div class="col-xs-12 news"> <div class="content"> <div class="header"> <h4>Últimas Noticias</h4> </div> <?php $args = array( 'post_type' => 'post', 'numberposts' => 4, 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish', 'tax_query' => array( array( 'taxonomy' => 'news', 'field' => 'slug', 'terms' => 'ultimas-noticias' ) ), ); $posts = get_posts( $args ); foreach ($posts as $post): ?> <div class="info-item"> <a class="title" href="<?php echo get_permalink($post->ID); ?>"> <?php echo get_the_title($post->ID); ?> </a> <div class="meta"> <?php $post_categories = wp_get_post_categories( $post->ID ); foreach($post_categories as $c): $cat = get_category( $c ); $color = get_field('categoria_color', $cat); ?> <a class="etiqueta pull-left" href="<?php echo get_category_link( $cat->term_id ); ?>" style="color: <?= $color?>"> <?php echo $cat->name; ?> </a> <?php break; endforeach; ?> <?php $post_date = get_the_date( 'Y-m-d H:i:s', $post->ID ); $hace = new haceTanto($post_date,'h'); //$fecha2 = new DateTime($post_date); //$hace = hace($fecha2); ?> <center> <span class="time"><i class="fa fa-clock-o"></i> hace <?php echo $hace; ?></span> </center> <span class="share pull-right"> <ul class="nav nav-pills"> <li role="presentation"><a target="_blank" data-href="<?php echo get_permalink($post->ID); ?>" href="https://www.facebook.com/sharer/sharer.php?u=www.revistapolicial.pe/<?php echo get_permalink($post->ID); ?>"><i class="fa fa-facebook"></i></a></li> <li role="presentation"><a target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo get_the_title($post->ID); ?>&url=<?php echo get_permalink($post->ID); ?>"><i class="fa fa-twitter"></i></a></li> </ul> <div class="clearfix"></div> </span> </div> <div class="img"> <a href="<?php echo get_permalink($post->ID); ?>"> <?php if (has_post_thumbnail()): ?> <img src="<?php the_post_thumbnail_url( $post->ID, 'post-verde' ); ?>" class="img-responsive" alt="<?php echo get_the_title($post->ID); ?>"> <?php else: ?> <img src="<?php echo get_template_directory_uri(); ?>/assets/image/post-verde.png" class="img-responsive" alt="<?php echo get_the_title($post->ID); ?>"> <?php endif ?> </a> </div> <hr> </div> <?php endforeach; ?> </div> </div> </div--> <?php break; ?> <!--------------------------------------------------------------------------------------------(1988)--> <div id="home-aside" class="col-xs-3 meta publicidad"> <?php if (is_page( 'prevencion' )) { if ( is_active_sidebar( 'widget-aside-page-prevencion' ) ){ dynamic_sidebar( 'widget-aside-page-prevencion' ); } }elseif (is_page( 'orientacion' )) { if ( is_active_sidebar( 'widget-aside-page-prevencion' ) ){ dynamic_sidebar( 'widget-aside-page-prevencion' ); } }else{ if ( is_active_sidebar( 'widget-aside-page-prevencion' ) ){ dynamic_sidebar( 'widget-aside-page-prevencion' ); } } ?> </div> </section>
Foro: Guías – Resolución de problemas
En respuesta a: problema con the_excerptperfecto gracias, aviso que tal va
Foro: Guías – Resolución de problemas
En respuesta a: problema con the_excerptigual ya con esa respuesta creo poder solucionar muchas gracias, cualquier detalle que salga pregunto