Ejemplo n.º 1
0
function mini_archive_draw()
{
    global $wp_query;
    if (is_page() && mini_archive_on_page()) {
        $archive_type = get_post_meta(get_the_ID(), 'mini_archive', true);
        if ($archive_type == 'user') {
            $users = mini_archive_get_users();
            $locations = array('/mini_archive-users.php');
            $template = locate_template($locations);
            if ($template == "") {
                include MINI_ARCHIVE_PLUGIN_DIR . '/templates/mini_archive/mini_archive-users.php';
            } else {
                include $template;
            }
        } else {
            $query = mini_archive_get_query(get_the_ID());
            if ($query) {
                $locations = array('/templates/mini_archive/' . $archive_type . '.php', '/mini_archive/' . $archive_type . '.php', '/mini_archive-' . $archive_type . '.php', '/templates/archive/' . $archive_type . '.php', '/archive/' . $archive_type . '.php', '/archive-' . $archive_type . '.php', '/templates/mini_archive/loop.php', '/mini_archive/loop.php', '/mini_archive-loop.php', '/mini_archive.php', '/templates/archive/loop.php', '/archive/loop.php', '/archive-loop.php', '/archive.php');
                $template = locate_template($locations);
                if ($template == "") {
                    include MINI_ARCHIVE_PLUGIN_DIR . '/templates/mini_archive/mini_archive.php';
                } else {
                    $original_query = $wp_query;
                    $wp_query = $query;
                    include $template;
                    $wp_query = $original_query;
                    wp_reset_postdata();
                }
            }
        }
    }
}
function sfhiv_get_archive_query()
{
    global $wp_query;
    $query = false;
    if (is_page()) {
        $archive_type = mini_archive_on_page(get_the_ID());
        if ($archive_type) {
            $query = mini_archive_get_query(get_the_ID());
        }
    }
    if (is_archive()) {
        $wp_query->rewind_posts();
        $query = $wp_query;
    }
    return $query;
}
function sfhiv_add_mini_archive_menu()
{
    global $post;
    $archive_type = mini_archive_on_page(get_the_ID());
    if ($archive_type && !is_home()) {
        $output_archive = false;
        $query = mini_archive_get_query(get_the_ID());
        if (!in_array($archive_type, array('sfhiv_event'))) {
            $years = sfhiv_get_taxonomy_in($query, 'sfhiv_year', 'ids');
            if (count($years) > 1) {
                $output_archive = true;
                sfhiv_draw_taxonomy_menu(array('taxonomy' => 'sfhiv_year', 'title_li' => false, 'include' => implode(',', $years), 'show_all_link' => false, 'base_link' => get_permalink(get_the_ID())));
            }
        }
        $archive_filters = mini_archive_get_filters();
        foreach ($archive_filters as $filter) {
            if (!$output_archive) {
                $taxes = sfhiv_get_taxonomy_in($query, $filter['type'], 'ids');
                if (count($taxes) > 1) {
                    $output_archive = true;
                    sfhiv_draw_taxonomy_menu(array('taxonomy' => $filter['type'], 'title_li' => false, 'include' => implode(',', $taxes), 'show_all_link' => false, 'base_link' => get_permalink(get_the_ID())));
                }
            }
        }
        if (is_home()) {
            $output_archive = true;
        }
        if (!$output_archive && !in_array($archive_type, array('sfhiv_service', 'sfhiv_service_hour'))) {
            $query = mini_archive_get_query(get_the_ID(), array('posts_per_page' => 3));
            $org_post = $post;
            ?>
<nav><ul class="menu"><?php 
            foreach ($query->posts as $post) {
                get_template_part('list-item', get_post_type());
            }
            $post = $org_post;
            ?>
</ul></nav><?php 
        }
    }
}