Skip to content

Instantly share code, notes, and snippets.

@taciara
Created September 27, 2018 19:38
Show Gist options
  • Save taciara/bf1b60c37637035ea5045b4df005ea54 to your computer and use it in GitHub Desktop.
Save taciara/bf1b60c37637035ea5045b4df005ea54 to your computer and use it in GitHub Desktop.
Metódo antigo Quaery_post
<?php query_posts(array('post_type' => 'representantes', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => 2)); ?>
<section>
<?php while(have_posts()):the_post(); ?>
<?php $imagem = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full'); ?>
<div class="item-<?=$post->post_name;?>">
<figure style="background-image: url('<?php echo $imagem[0] ?>');"></figure>
<h4><?php the_title(); ?></h4>
<?php the_content(); ?>
<?php the_excerpt(); ?>
<a class="leiamais" href="<?php the_permalink(); ?>">leia mais</a>
</div>
<?php endwhile; ?>
</section>
<?php wp_reset_query(); ?>
Passando Para Get_post
<?php
$MeuQueryPostNovo = array(
'post_type' => 'representantes',
'orderby' => 'date', 'order' => 'ASC',
'posts_per_page' => 2,
);
$paginasLoop = get_categories( $MeuQueryPostNovo );
foreach ( $paginasLoop as $cat ) {
if( $cat->category == 0 ) {
/* NAO SEI SE PRECISA TER. PEGUEI DO EXEMPLO
$cat_class = mb_strtolower($cat->name);
$image = wp_get_attachment_url( $thumbnail_id );
$cat_thumb_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
$cat_thumb_url = wp_get_attachment_thumb_url( $cat_thumb_id );
$term_link = get_term_link( $cat, 'product_cat' );
$imagem = wp_get_attachment_image_src($cat_thumb_id, 'large');
*/
$nomedoPost = $post->post_name;
$meuConteudo = get_the_content();
$meuTitulo = get_the_title();
?>
<!-- FALTA COLOCAR: the_excerpt(); / the_permalink(); / IMAGEM DESTACADA DA PAGINA -->
<div class="item-<?php echo $nomedoPost; ?>">
<h3><?php echo $meuTitulo; ?></h3>
<?php echo $meuConteudo; ?>
</div>
<?php }
} wp_reset_query();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment