2015-06-02 3 views
1

Есть ли способ редактировать следующие, чтобы вместо того, чтобы вводить самые последние сообщения, он вносит сообщения из определенной категории?Редактирование Wordpress код для ввода типа сообщения

if(!function_exists('zolo_recent_posts')) { function zolo_recent_posts($atts, $content = null) { ob_start(); extract(shortcode_atts(array("num" => '4', 'columnsizepost' => '', 'data_animation'=>'fadeInDown', 'data_delay'=>'0'), $atts)); global $post; 
query_posts('post_type=post&posts_per_page='.$num.'&paged='. @$paged); ?> 

<div class="zolo-recent-post <?php echo $columnsizepost;?>"> 
    <?php $i=1 ; while (have_posts()) : the_post(); if (has_post_thumbnail($post->ID)): ?> 
    <?php //$image=w p_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'recent_posts_thumb'); ?> 
    <?php endif; if($i % 4==0) $class='last' ; else $class='' ; ?> 
    <div class="blog-box <?php echo $class;?> animated hiding" data-animation="<?php echo $data_animation;?>" data-delay="<?php echo $data_delay; ?>"> 
    <div class="blog-img"><a href="<?php the_permalink(); ?>"> 
    <?php 
    if (has_post_thumbnail()) { 
     the_post_thumbnail('recent_posts_thumb'); 
    } 
    else { 
     echo '<img src="' . get_bloginfo('stylesheet_directory') . '/images/thumb-img.jpg" />'; 
    } 
    ?> 
     </a> 
    </div> 
    <div class="blog-text-area"> 
     <h3><a href="<?php the_permalink(); ?>"> 
     <?php the_title(); ?> 
     </a></h3> 
     <div class="alltag-row"> <span class="date"><i class="fa fa-calendar"></i>&nbsp; 
     <?php the_time('F jS, Y') ?> 
     </span> <span class="add-comment"><a href="<?php the_permalink(); ?>#hello"> 
     <?php comments_number('0 <i class="fa fa-comment-o"></i>', '1 <i class="fa fa-comment"></i>', '% <i class="fa fa-comments"></i>'); ?> 
     </a></span> 
     </div> 
     <?php the_excerpt() ;?> 
    </div> 
    </div> 
    </span> 
    <?php $i++; endwhile; ?> 
</div> 
<?php wp_reset_query(); $demolp_output=o b_get_clean(); return $demolp_output; } add_shortcode("zolo_recent_post", "zolo_recent_posts"); } 

ответ

1
<?php query_posts('category_name=CATEGORYNAME&showposts=5'); 
    while (have_posts()) : the_post(); 
    // do whatever you want 
?> 
<b><a href="<?php the_permalink() ?>" title="Permanent Link to <?php  the_title(); ?>"><?php the_title(); ?></a> 
<?php 
endwhile; 
?> 

Используя этот способ, которым Вы можете получить сообщения определенной категории в WordPress.

+0

Конечно .. иногда не видно леса для деревьев. Благодарю. –

Смежные вопросы