2014-07-09 5 views
0

저자가 작성한 마지막 게시물을 보여주는 WordPress에 shortcode가 있습니다. 문제는 구체적인 작성자 (ID = 13)를 제외하고 싶다는 것입니다. 저자가 작성한 Wordpress 단축 코드

function latest_posts_c($array) { 
    global $post; 

    $defaults = array(
     'show' => 3, 
     'excerpt' => 'false', 
     'post_type' => 'post', 
    ); 

    extract(shortcode_atts($defaults, $array)); 

    $args = array(
     'posts_per_page' => $show, 
     'post_type' => $post_type, 
    ); 

    // Gets posts form database 
    $query = new WP_Query($args); 

    // Displays posts if available 
    if($query) { 
     $i = 0; 

     while ($query->have_posts()) : $query->the_post(); 
      if ($i == 0) 
       $html = '<div class="column dt-sc-one-third first">'; 
      else 
       $html .= '<div class="column dt-sc-one-third">'; 

      $html .= '<article id="post-'.get_the_ID().'" class="'.implode(' ', get_post_class('blog-entry')).'">'; 
      $html .= '<div class="blog-entry-inner">'; 

      $html .= '<div class="entry-meta">'; 
      $html .= ' <a href="'.get_permalink().'" title="'.get_the_title().'" class="entry_format"> </a>'; 
      $html .= ' <div class="date">'; 
      $html .= '  <p>'.get_the_date('M').' '.get_the_date('d').' <span>'. get_the_date('Y') .'</span> </p>'; 
      $html .= ' </div>'; 
      $html .= '</div><!-- .entry-meta -->'; 

      if(has_post_thumbnail()): 
       $html .= '<div class="entry-thumb">'; 
       $html .= ' <a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_post_thumbnail(get_the_ID(), 'medium').'</a>'; 
       $html .= '</div><!-- .entry-thumb -->'; 
      endif; 

      $html .= '<div class="entry-details">'; 
      if(is_sticky()): 
      $html .= ' <div class="featured-post"> <span class="fa fa-trophy"> </span> Destacado</div>'; 
      endif; 

      $html .= ' <div class="entry-title">'; 
      $html .= '  <h4><a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_title().'</a></h4>'; 
      $html .= ' </div>'; 

      $html .= ' <div class="entry-metadata">'; 
      $html .= '  <p class="author">'; 
      $html .= '<span class="fa fa-user"> </span>'; 
      $html .= '   <a href="'.get_author_posts_url(get_the_author_meta('ID')).'" title="Ver todos las entradas de '.get_the_author().'">'.get_the_author().'</a></p>'; 
      $categories = 0;/*get_the_category();*/ 
      $separator = ', '; 
      $output = ''; 
      if($categories){ 
       $j = 0; 
       foreach($categories as $category) { 
        $output .= '<a href="'.get_category_link($category->term_id).'" title="' . esc_attr(sprintf(__("Ver todos las entradas en %s"), $category->name)) . '">'.$category->cat_name.'</a>'; 
        $j++; 
        if ($j < count($categories)) $output .= $separator; 
       }  
       $html .= '  <p class="categories"><span class="fa fa-folder-open"> </span>'.$output.'</p>'; 
      } 
      $html .= ' </div><!-- .entry-metadata-->'; 

      $html .= ' <div class="entry-body">'; 
      $html .= '  '.dttheme_excerpt(50); 
      $html .= '  <p><a href="'.get_permalink().'" title="'.get_the_title().'" class="dt-sc-button small read-more">'; 
      $html .= '  Leer más <span class="fa fa-angle-double-right"> </span></a></p>'; 
      $html .= ' </div>'; 

      $html .= '</div><!-- .entry-details -->'; 

      $html .= '</div><!-- .blog-entry-inner-->'; 
      $html .= '</article>'; 
     $html .= '</div>'; 

     $i++; 
     endwhile; 
    } 

    $html .= '<div class="dt-sc-clear"></div>'; 

    // Resets Post Data 
    wp_reset_postdata(); 

    // Returns the results 
    return $html; 
} 
add_shortcode('latestposts_c', 'latest_posts_c'); 

내가 저자 ID = 13 게시물이있을 경우 코드를 차단하는 경우를 추가하지만, 문제는 단축 코드 아무것도 표시되지 않는 경우 : 단축 코드는 다음입니다. 또한 "authors_in"을 사용하여 어레이 내부의 특정 저자 ID를 허용합니다. $ args 및 $ default하지만 아무 것도 없습니다 ... 어떤 아이디어입니까?

답변