Example #1
0
function loop_entradas($con_cabecera = false, $category = false, $per_page = BLOG_PER_PAGE, $funcion = 'print_loop', $post__not_in = false)
{
    global $wp_query;
    $args = array('posts_per_page' => $per_page, 'post_type' => 'post', 'fields' => 'ids');
    if (!is_string($category)) {
        /*PAGINACION*/
        $page = $wp_query->query_vars['paged'];
        if ($page < 1) {
            $page = 1;
        }
        $args['paged'] = $page;
        /*CATEGORIA*/
        if ($category) {
            $args['cat'] = $category;
        }
    }
    if ($post__not_in) {
        $args['post__not_in'] = array($post__not_in);
    }
    $entradas = get_posts($args);
    if ($entradas && $category !== 0) {
        if ($con_cabecera) {
            /*
             **SETEAMOS 3 PRIMEROS
             */
            $primeros = array(array_shift($entradas));
            if (count($entradas)) {
                $primeros[] = array_shift($entradas);
            }
            if (count($entradas)) {
                $primeros[] = array_shift($entradas);
            }
            foreach ($primeros as $e) {
                $entrada = new Entrada($e);
                $entrada->{$funcion}(true);
            }
        }
        if (count($entradas)) {
            echo '<div class="cuerpo">';
            foreach ($entradas as $e) {
                $entrada = new Entrada($e);
                $entrada->{$funcion}();
            }
            echo '</div>';
        }
        if (!is_string($category)) {
            /*
             **LO PONEMOS ASÍ PARA QUE NO HAYA paginacion
             **EN LUGARES EXTRAÑOS
             */
            pagination_w($args, $page);
        }
    } else {
        if (!is_string($category) && $post__not_in == false) {
            no_entradas();
        }
    }
}
Example #2
0
<?php

get_header();
echo '<div class="cuerpo">';
if (have_posts()) {
    while (have_posts()) {
        the_post();
        $entrada = new Entrada($post->ID);
        $entrada->print_loop();
    }
} else {
    no_entradas();
}
echo '</div>';
get_footer();