Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » WordPress »

ordenar por entradas

Estas en el tema de ordenar por entradas en el foro de WordPress en Foros del Web. hola tengo unos autores que publican, y quiero sacarlos ordenados por el numero de publicaciones hechas. Alguien sabe como hacerlo Gracias Código PHP: /**  * Displays category posts widget on blog. ...
  #1 (permalink)  
Antiguo 12/11/2011, 15:55
Avatar de camilo_1987  
Fecha de Ingreso: junio-2008
Ubicación: ALZIRA, Spain, Spain
Mensajes: 77
Antigüedad: 15 años, 10 meses
Puntos: 0
ordenar por entradas

hola
tengo unos autores que publican, y quiero sacarlos ordenados por el numero de publicaciones hechas.
Alguien sabe como hacerlo
Gracias
Código PHP:
/**
 * Displays category posts widget on blog.
 */
function widget($args, $instance) {
    global $post;
    $post_old = $post; // Save the post object.
    
    extract( $args );
    
    $sizes = get_option('sw_arti_cat_thumb_sizes');
    
    // If not title, use the name of the category.
    if( !$instance["author"] ) {
        $category_info = get_category($instance["cat"]);
        $instance["author"] = $category_info->name;
    }

  $valid_sort_orders = array('author_name', 'title', 'comment_count', 'random', 'author' );
  if ( in_array($instance['sort_by'], $valid_sort_orders) ) {
    $sort_by = $instance['sort_by'];
    $sort_order = (bool) $instance['asc_sort_order'] ? 'ASC' : 'DESC';
  } else {
    // by default, display latest first
    $sort_by = 'author';
    $sort_order = 'DESC';
  }
  {
    // by default, display latest first
    $sort_by = 'author_posts';
    $sort_order = 'DESC';
  }
  
    // Get array of post info.
  $cat_posts = new WP_Query(
    "showposts=" . $instance["num"] . 
    "&cat=" . $instance["cat"] .
    "&orderby=" . $sort_by .
    "&order=" . $sort_order.
    "$author" .$author["author=1"] 
  );

    // Excerpt length filter
    $new_excerpt_length = create_function('$length', "return " . $instance["excerpt_length"] . ";");
    if ( $instance["excerpt_length"] > 1 )
        add_filter('excerpt_length', $new_excerpt_length);
    
    echo $before_widget;
    
    // Widget title
    echo $before_title;
    if( $instance["title_link"] )
        echo '<a href="' . get_category_link($instance["cat"]) . '">' . $instance["title"] . '</a>';
    else
        echo $instance["title"];
    echo $after_title;

    // Post list
    echo "<div style='border :  padding : 4px; width : 310px; height : 700px; overflow : auto;'> <ul>\n";
    
    while ( $cat_posts->have_posts() )
    {
        $cat_posts->the_post();
        $author = get_userdata(get_the_author_id());
    ?>
        <li class="cat-post-item">
            <?php the_author_meta('description'); ?>
            <?php if ( $instance['author_avatar'] ) : ?>
            
            <p class="author-avatar"><?= get_avatar($author->user_email64?></p>
            <?php endif; ?>
            

            <?php
                
if (
                    
function_exists('the_post_thumbnail') &&
                    
current_theme_supports("post-thumbnails") &&
                    
$instance["thumb"] &&
                    
has_post_thumbnail()
                ) :
            
?>
                <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
                <?php the_post_thumbnail'cat_post_thumb_size'.$this->id ); ?>
                </a>
            <?php endif; ?>
            

            <?php if ( $instance['date'] ) : ?>
            <p class="post-date"><?php the_time("j M Y"); ?></p>
            <?php endif; ?>
            
            <?php if ( $instance['excerpt'] ) : ?>
            <?php the_excerpt(); ?> 
            <?php endif; ?>
            
            <?php if ( $instance['author_name'] ) : ?>
            <a class="author-name" href="<?= get_author_posts_url($author->ID$author->user_nicename?>"><?= $author->first_name ' ' $author->last_name ?></a>
            <?php endif; ?><br/><br/><br/>
               
            <?php if ( $instance['comment_num'] ) : ?>
            <p class="comment-num">(<?php comments_number(); ?>)</p>
            <?php endif; ?>
            <?php if ( $instance['author-bio-box'] ) : ?>
            <?php endif; ?>
            <br />
        </li>

Etiquetas: plugin
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:10.