Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function delicious_promocoes($atts, $content = null) {
- extract(shortcode_atts(array(
- "items" => '2',
- ), $atts));
- global $post;
- /* DEBUG STARTS HERE - I want to show only posts on the category "destaque" */
- $categories = get_the_category($post->ID);
- var_dump($categories);
- /* DEBUG ENDS HERE - But the var_dump returns array(0) { }*/
- $retour ='';
- $retour .= '<div class="centered-wrapper">';
- $retour .= '<section>';
- $retour .= '<ul id="promocoes-home-principal" style="height:300px">';
- $args = array(
- 'orderby'=> 'post_date',
- 'order' => 'rand',
- 'post_type' => 'portfolio',
- 'posts_per_page' => $items
- );
- $my_query = new WP_Query($args);
- if( $my_query->have_posts() ) {
- while ($my_query->have_posts()) : $my_query->the_post();
- $portf_icon = get_post_meta($post->ID,'dt_portf_icon',true);
- $thumb_id = get_post_thumbnail_id($post->ID);
- $mythumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'portfolio-thumb');
- if ( has_post_thumbnail() ) {
- $retour .='<li>';
- $retour .='<a href="'. get_permalink() .'" title="'. get_the_title() .'">';
- $retour .='<span class="item-on-hover"><span class="hover-link"></span></span>';
- $retour .='<img src="'. $mythumbnail[0] .'" height="'. $mythumbnail[2] .'" width="'. $mythumbnail[1] .'" alt="'. get_the_title() .'" /></a>';
- $retour .='<span class="caption"><a href="'. get_permalink() .'">'. get_the_title() .'</a></span>';
- $retour .='</li>';
- }
- endwhile; wp_reset_query(); }
- $retour .='</ul>';
- $retour .='</section>';
- $retour .='</div><!--end centered-wrapper-->';
- return $retour;
- }
- add_shortcode("promocoes", "delicious_promocoes");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement