Skip to content

Instantly share code, notes, and snippets.

@mrfoxtalbot
Last active July 15, 2022 10:56
Show Gist options
  • Save mrfoxtalbot/bf11bc26c104f0f3b469c68c678641e2 to your computer and use it in GitHub Desktop.
Save mrfoxtalbot/bf11bc26c104f0f3b469c68c678641e2 to your computer and use it in GitHub Desktop.
Salimos de Bilbao Archives
<?php
get_header();
$term = get_queried_object();
$term_title = single_term_title();
$term_description = term_description();
$term_children = get_term_children( $term->term_id, $term->taxonomy );
$has_children = ! is_wp_error( $term_children ) && ! empty( $term_children );
$image_size = 'medium'; // Or thumbnail, medium, large, full
?>
<div id="primary" class="content-area mrfx-archive-test">
<main id="main" class="site-main" role="main">
<?php
if ( have_posts() ) : ?>
<?php
// Si es una categoría sin hijos (país)
if ( ! $has_children ): ?>
<header class="page-header">
<div class="term-header">
<?php the_archive_title( '<h1 class="page-title">', '</h1>' );?>
</div>
<div class="term-description">
<?php
// wp_kses_post Removes forbidden HTML
// wpautop wraps paragraphs inside <p> tags
echo wp_kses_post( wpautop( $term_description ) );
?>
</div>
</header>
<?php
// Si es una categoría con hijos (continente)
else: ?>
<header class="page-header">
<div class="term-description">
<?php
// wp_kses_post Removes forbidden HTML
// wpautop wraps paragraphs inside <p> tags
echo wp_kses_post( wpautop( $term_description ) );
?>
</div>
</header>
<div class="country-loop">
<?php foreach ( $term_children as $child_term_id ): ?>
<?php $child_term = get_term( $child_term_id ); ?>
<ul class="children-terms continentes" style="list-style: none; margin-left: 0; padding-left: 0">
<li>
<div class="term-image">
<a href="<?php echo esc_url( get_term_link( $child_term ) ); ?>">
<?php z_taxonomy_image( $child_term->term_id, 'medium' ); ?>
</a>
<h2>
<a href="<?php echo esc_url( get_term_link( $child_term ) ); ?>">
<?php echo $child_term->name ?>
</a>
</h2>
</div>
<div>
<div class="term-description">
<?php // echo wp_kses_post( wpautop( $term_description ) );
?>
</div>
</div>
</li>
</ul>
<?php endforeach; ?>
</div>
<?php endif; ?>
<!-- .page-header -->
<!-- The Post Loop -->
<?php if ( ! $has_children ): ?>
<div class="el-loop">
<?php
/* Start the Loop */
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', get_post_format() );
endwhile;
the_posts_pagination( [
'prev_text' => '',
'next_text' => '',
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'benevolent' ) . ' </span>',
] );
else :
get_template_part( 'template-parts/content', 'none' );
endif; ?>
</div>
<?php endif; ?>
<!-- The Post Loop -->
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment