Skip to content

Instantly share code, notes, and snippets.

@pedrorvidal
Created February 27, 2014 20:19
Show Gist options
  • Save pedrorvidal/9258697 to your computer and use it in GitHub Desktop.
Save pedrorvidal/9258697 to your computer and use it in GitHub Desktop.
<li>
<div class="img">
<?php $imgsrc = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<img src="<?php echo $imgsrc; ?>">
</div>
<div class="description">
<header><?php the_title(); ?></header>
<div><?php the_content(); ?></div>
<?php $metas = get_post_meta( $post->ID ); ?>
<div>Est.: <?php echo $metas['estoque'][0]; ?> unidades</div>
<div class="de">
<?php
$de = $metas['de'][0];
if (!strpos($de, 'de')) {
$nde = "de R$ ".$de;
} else {
$nde = "R$ ".$de;
}
echo $nde;
?>
</div>
<?php
$por = $metas['por'][0]; //199,99
$s = explode(',',$por); //$s[0] = 199, $[1] = ',99';
if (!strpos($s[0], 'por')) {
$por = "por R$ ";
} else {
$por = " R$ ";
}
?>
<div><?php echo $por; ?></div>
<div class="por">
<?php echo $s[0]; ?><sup><?php echo ','.$s[1]; ?></sup><sub>cada</sub>
</div>
</div>
</li>
function produtos_render() {
get_template_part( 'content', 'produtos');
// get_template_part( 'content', get_post_format() );
}
...
add_theme_support(
'infinite-scroll',
array(
'type' => 'scroll',
'footer_widgets' => false,
'container' => 'produtos',
'wrapper' => false,
'render' => 'produtos_render',
'posts_per_page' => get_option( 'posts_per_page' )
)
);
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme and one of the
* two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* For example, it puts together the home page when no home.php file exists.
*
* @link http://codex.wordpress.org/Template_Hierarchy
*
* @package Odin
* @since 2.2.0
*/
get_header(); ?>
<div id="home" class="content">
<nav id="color-nav">
<ul>
<li class="blue"></li>
<li class="purple"></li>
<li class="green"></li>
<li class="orange"></li>
</ul>
<div>Oriente-se pelas cores do corredor</div>
</nav>
<section id="secao-produtos" class="products">
<ul id="produtos">
<?php get_template_part('content', 'produtos'); ?>
<?php
$args = array(
'post_type' => 'oferta',
'posts_per_page' => 12,
'order' => 'DESC'
);
$q = new WP_Query($args);
global $post;
while ($q->have_posts()) : $q->the_post(); ?>
<?php get_template_part('content', 'produtos'); ?>
<?php endwhile; wp_reset_query(); ?>
</ul> <!-- #products -->
</section> <!-- .products -->
</div><!-- #primary -->
<?php
get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment