<?php
/**
* A Simple Category Template (Parent Category)
*/


function mypage_head() {
    echo '<link rel="stylesheet" type="text/css" href="'.plugins_url('../css/nichecreator.css',__FILE__).'">'."\n";
}
add_action('wp_head', 'mypage_head');


	
get_header(); 
//the_author_posts_link()
// category_description()
// single_cat_title( '', false )
//the_author_posts_link()
// the_title_attribute()
// the_permalink()
// the_content()
?> 
 
<section id="primary" class="site-content">
<div id="content" role="main">
<!--
<header class="archive-header">
</header> -->
 <?php
$aplicarcss = get_option("nichecreator_aplicarcss");
if ($aplicarcss == 'Si')
{
wp_register_style('csscategories',plugins_url('../css/pages.css',__FILE__),'','1.0');
wp_enqueue_style('csscategories');
}
$category = get_queried_object();
$categoryid = $category->term_id;
 $ocultarh1 = get_option('nichecreator_ocultarh1');
if ($ocultarh1 == 'No')
	{
	$h1 = get_term_meta($categoryid,'textoh1',true);
	echo "<h1>$h1</h1>";
	}
echo '<div class="entry">';
$ocultardesc = get_option('nichecreator_ocultardesc');
if ($ocultardesc == 'No')
	{
	echo '<div class="descripcion">';
	$desc = category_description($categoryid);
	echo do_shortcode($desc);
	echo '</div>';
	}
///// OBTENER CATEGORIAS HIJO //////////////////
$catlist = get_categories(
		array(
        'child_of' => $categoryid,
        'orderby' => 'id',
        'order' => 'DESC',
        //'exclude' => $catid,
        'hide_empty' => '0'
        ) );
echo '<div class="clusterhijos" style="display:flex;flex-direction:row;flex-wrap:wrap;align-items:stretch;align-content:center;gap:20px;">';
$clusterdesc = get_option('nichecreator_clusterdesc','No');
$clusterchars = get_option('nichecreator_clusterchars',50);
$clusterimagen = get_option('nichecreator_clusterimagen','No');
foreach ($catlist as $cat)
{
$link = get_category_link($cat);
$image_id = get_term_meta($categoryid,'imagen',true);
if ($image_id AND $clusterimagen == 'Si')
	$imagen = wp_get_attachment_image( $image_id, array(100,100));
else $imagen = '';
if ($clusterdesc == 'Si')
	{
	$category->description = RecortTexto($category->description, $clusterchars);
	echo '<div class="child" style="padding:20px;border:1px solid black;border-radius:10px;flex:1 0 25%;">'.$imagen.'<a href="'.$link.'">'.ucfirst($cat->name).'</a><br/>'.$category->description;
	}
else echo '<div class="child" style="padding:20px;border:1px solid black;border-radius:10px;flex:1 0 25%;">'.$imagen.'<a href="'.$link.'">'.ucfirst($cat->name).'</a><br/>';
echo '</div>';
}
echo '</div>';
//////// FIN OBTENER CATEGORIAS HIJO ////////////

$parrafoconc = get_term_meta($categoryid,'conclusion',true);
echo '<div class="concl">';
echo '<p>'.do_shortcode($parrafoconc).'</p>';
echo '</div>';
?>
</div>
 
 
</div>
</section>
<?php
$ocultarcats = get_option('nichecreator_ocultarcats');
if ($ocultarcats == 'No')
    get_sidebar();
get_footer(); 
?>
