changed excerpt in category when long length goes out of the box, specially in arxives category

This commit is contained in:
jorge-vitrubio 2022-07-19 00:27:21 +02:00
parent d8adf6c3a6
commit b2c2e3cd65
3 changed files with 239 additions and 351 deletions

View File

@ -1,180 +1,209 @@
<li id="post-<?php the_ID(); ?>" <?php echo 'class ="boxentry ' . $tipus; if (in_category("destacado")) echo ' destacat'; echo '"'; ?>> <li id="post-<?php the_ID(); ?>" <?php echo 'class ="boxentry ' . $tipus; if (in_category("destacado")) echo ' destacat'; echo '"'; ?>>
<!-- <?php echo $category; ?> --> <?php //echo $category; ?>
<!-- <?php echo $tipus; ?> --> <?php //echo $tipus; ?>
<!-- les pàgines fixes (no categories ni artistes) --> <!-- les pàgines fixes (no categories ni artistes) -->
<?php if ((!$category) and ($tipus == 'pag')) : ?> <?php if ((!$category) and ($tipus == 'pag')) : ?>
<h2 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title() ;?> </a> </h2> <h2 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title() ;?> </a> </h2>
<?php $contingut = get_the_content_with_formatting(); //funció que està a functions.php permet mostrar links i html del contingut, client ho volia ?> <?php $contingut = get_the_content_with_formatting(); //funció que està a functions.php permet mostrar links i html del contingut, client ho volia ?>
<div class="contingut plus"> <div class="contingut plus">
<?php echo $contingut; ?> <?php echo $contingut; ?>
</div>
<div class="boxpeu" >
<a href="<?php the_permalink(); ?>" class="peubox" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><img alt="enllaç" src="<?php echo get_template_directory_uri() . '/images/fletxalink.png';?>" /></a>
</div>
<!-- els artistes -->
<?php elseif ((!$category) and (($tipus == 'art')) or ($tipus == 'obra')): ?>
<div class="head-entry">
<?php if (is_home()) : ?>
<span class='cat'>
<a href="<?php echo get_permalink(2);?>"><?php echo get_the_title(2);?></a>
</span>
<h2 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title() ;?> </a> </h2>
<?php else : ?>
<h3 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title() ;?> </a> </h3>
<?php endif;?>
</div> </div>
<?php if ($tipus == 'art') :
if(get_post_meta($post->ID, 'autor_tipo_resid', true) && get_post_meta($post->ID, 'autor_data_resid', true)): ?>
<p class="meta box">
<?php echo __(get_post_meta($post->ID, 'autor_tipo_resid', true)) ?>
<br />
<?php echo __(get_post_meta($post->ID, 'autor_data_resid', true)) ?>
</p>
<?php else : ?>
<p class="meta box novista"></p>
<?php endif; ?>
<?php else : ?>
<p class="meta box"><?php echo get_post_meta($post->ID, 'data_obra', true) ?></p>
<?php endif; ?>
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail('artists-thumb'); ?>
</a>
<?php else : ?>
<img class="noimatge gran" width="200" height="230" title="imatge no disponible" alt="imatge no disponible" src="<?php echo get_template_directory_uri() .'/images/noimatgegran.jpg';?>" />
<?php endif; ?>
<div class="boxpeu" > <div class="boxpeu" >
<!-- la fletxeta link al post/pàgina --> <a href="<?php the_permalink(); ?>" class="peubox" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><img alt="enllaç" src="<?php echo get_template_directory_uri() . '/images/fletxalink.png';?>" /></a>
<a href="<?php the_permalink(); ?>" class="peubox" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><img alt="enllaç" src="<?php echo get_template_directory_uri() . '/images/fletxalink.png';?>" /></a> </div>
<?php if (is_home()) : ?> <!-- els artistes -->
<!-- els quadrets link a la categoria pare --> <?php elseif ((!$category) and (($tipus == 'art')) or ($tipus == 'obra')): ?>
<a href="<?php echo get_permalink(2); ?>" class="peudret" title="<?php echo get_the_title(2); ?>" rel="bookmark"><img alt="enllaç a la categoria" src="<?php echo get_template_directory_uri() . '/images/totslink.png';?>" /></a>
<div class="head-entry">
<?php if (is_home()) : ?>
<span class='cat'>
<a href="<?php echo get_permalink(2);?>"><?php echo get_the_title(2);?></a>
</span>
<h2 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title() ;?> </a> </h2>
<?php else : ?>
<h3 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title() ;?> </a> </h3>
<?php endif;?>
</div>
<?php if ($tipus == 'art') :
if(get_post_meta($post->ID, 'autor_tipo_resid', true) && get_post_meta($post->ID, 'autor_data_resid', true)): ?>
<p class="meta box">
<?php echo __(get_post_meta($post->ID, 'autor_tipo_resid', true)) ?>
<br />
<?php echo __(get_post_meta($post->ID, 'autor_data_resid', true)) ?>
</p>
<?php else : ?>
<p class="meta box novista"></p>
<?php endif; ?> <?php endif; ?>
<?php else : ?>
</div> <p class="meta box"><?php echo get_post_meta($post->ID, 'data_obra', true) ?></p>
<?php endif; ?>
<!-- EQUIP --> <?php if ( has_post_thumbnail() ) : ?>
<?php elseif ((!$category) and ($tipus == 'equip')): <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
$lang = qtrans_getLanguage(); <?php the_post_thumbnail('artists-thumb'); ?>
if($lang == 'ca'): </a>
$carrec = get_post_meta($post->ID, 'carrec', true); <?php else : ?>
elseif($lang == 'es'): <img class="noimatge gran" width="200" height="230" title="imatge no disponible" alt="imatge no disponible" src="<?php echo get_template_directory_uri() .'/images/noimatgegran.jpg';?>" />
$carrec = get_post_meta($post->ID, 'carrecES', true); <?php endif; ?>
<div class="boxpeu" >
<!-- la fletxeta link al post/pàgina -->
<a href="<?php the_permalink(); ?>" class="peubox" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><img alt="enllaç" src="<?php echo get_template_directory_uri() . '/images/fletxalink.png';?>" /></a>
<?php if (is_home()) : ?>
<!-- els quadrets link a la categoria pare -->
<a href="<?php echo get_permalink(2); ?>" class="peudret" title="<?php echo get_the_title(2); ?>" rel="bookmark"><img alt="enllaç a la categoria" src="<?php echo get_template_directory_uri() . '/images/totslink.png';?>" /></a>
<?php endif; ?>
</div>
<!-- EQUIP -->
<?php elseif ((!$category) and ($tipus == 'equip')):
$lang = qtrans_getLanguage();
if($lang == 'ca'):
$carrec = get_post_meta($post->ID, 'carrec', true);
elseif($lang == 'es'):
$carrec = get_post_meta($post->ID, 'carrecES', true);
elseif($lang == 'en'): elseif($lang == 'en'):
$carrec = get_post_meta($post->ID, 'carrecEN', true); $carrec = get_post_meta($post->ID, 'carrecEN', true);
endif; endif;
$email = get_post_meta($post->ID, 'email', true); $email = get_post_meta($post->ID, 'email', true);
$telefon = get_post_meta($post->ID, 'telefon', true); $telefon = get_post_meta($post->ID, 'telefon', true);
?> ?>
<div class="head-entry"> <!-- els equips només són índex, no tenen enllça a pàgina ni peu--> <div class="head-entry"> <!-- els equips només són índex, no tenen enllça a pàgina ni peu-->
<h3 class="equip <?php echo $tipus;?>"><?php the_title() ;?> </h3> <h3 class="equip <?php echo $tipus;?>"><?php the_title() ;?> </h3>
<p class="carrec"><?php echo $carrec; //echo qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($carrec); ?> </p> <p class="carrec"><?php echo $carrec; //echo qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($carrec); ?> </p>
</div> </div>
<p class="boxcurta"><?php echo $telefon; ?> </p> <p class="boxcurta"><?php echo $telefon; ?> </p>
<p class="meta box"><?php echo $email; ?> </p> <p class="meta box"><?php echo $email; ?> </p>
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail('thumbnail'); ?>
</a>
<?php else : ?>
<img class="noimatge gran" width="200" height="150" title="imatge no disponible" alt="imatge no disponible" src="<?php echo get_template_directory_uri() .'/images/noimatge.jpg';?>" />
<?php endif; ?>
<?php if (has_excerpt()) : ?>
<p class="excerptbox"><?php echo get_the_excerpt(); ?></p>
<?php else :?>
<div class="contingut curt"><?php echo custom_wp_trim_excerpt(); ?></div>
<?php endif; ?>
<!-- els descarregables --> <?php if ( has_post_thumbnail() ) : ?>
<?php elseif ((!$category) and ($tipus == 'desc')): ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail('thumbnail'); ?>
<div class="head-entry"> </a>
<?php if (is_home()) : ?> <?php else : ?>
<span class='cat'> <img class="noimatge gran" width="200" height="150" title="imatge no disponible" alt="imatge no disponible" src="<?php echo get_template_directory_uri() .'/images/noimatge.jpg';?>" />
<a href="<?php echo get_permalink(136);?>"><?php echo get_the_title(136);?></a> <?php endif; ?>
</span>
<h2 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title() ;?> </a> </h2> <?php if (has_excerpt()) : ?>
<?php else : ?> <p class="excerptbox"><?php echo get_the_excerpt(); ?></p>
<h3 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title() ;?> </a> </h3> <?php else :?>
<?php endif;?> <div class="contingut curt"><?php echo custom_wp_trim_excerpt(); ?></div>
<?php endif; ?>
</div>
<div class="contingut llarg"> <!-- els descarregables -->
<?php the_content(); ?> <?php elseif ((!$category) and ($tipus == 'desc')): ?>
</div>
<div class="head-entry">
<!-- la fletxeta link al post/pàgina --> <?php if (is_home()) : ?>
<div class="boxpeu"> <span class='cat'>
<a href="<?php the_permalink(); ?>" class="peubox" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><img alt="enllaç" src="<?php echo get_template_directory_uri() . '/images/fletxalink.png';?>" /></a> <a href="<?php echo get_permalink(136);?>"><?php echo get_the_title(136);?></a>
<!-- els quadrets link a la categoria pare --> </span>
<?php if (is_home()) : ?> <h2 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title() ;?> </a> </h2>
<a href="<?php echo get_permalink(136); ?>" class="peudret" title="<?php echo get_the_title(136); ?>" rel="bookmark"><img alt="enllaç a la categoria" src="<?php echo get_template_directory_uri() . '/images/totslink.png';?>" /></a> <?php ?> <?php else : ?>
<?php endif; ?> <h3 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title() ;?> </a> </h3>
</div> <?php endif;?>
</div>
<!-- resta de categories --> <div class="contingut llarg">
<?php the_content(); ?>
<?php else : </div>
// echo " category " . $category . " catt2 " . $catt2 . " category 0 " . $category[0]->term_id;?>
<div class="head-entry"> <!-- la fletxeta link al post/pàgina -->
<?php if (is_home()) : ?> <div class="boxpeu">
<span class='cat'> <a href="<?php the_permalink(); ?>" class="peubox" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><img alt="enllaç" src="<?php echo get_template_directory_uri() . '/images/fletxalink.png';?>" /></a>
<a href="<?php echo get_category_link( $category[0]->term_id );?>"><?php echo $category[0]->name;?></a> <!-- els quadrets link a la categoria pare -->
</span> <?php if (is_home()) : ?>
<h2 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php echo the_title();?> </a> </h2> <a href="<?php echo get_permalink(136); ?>" class="peudret" title="<?php echo get_the_title(136); ?>" rel="bookmark"><img alt="enllaç a la categoria" src="<?php echo get_template_directory_uri() . '/images/totslink.png';?>" /></a> <?php ?>
<?php else : ?> <?php endif; ?>
<?php if (has_subcategories($catt2)) : ?> </div>
<span class='cat'> <!-- atenció cal assingar cada post a la subcategoria, sinó sortirà la categoria pare -->
<a href="<?php echo get_category_link( $category[0]->term_id );?>"><?php echo $category[0]->name;?></a>
</span> <!-- resta de categories -->
<h3 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php echo the_title();?> </a> </h3>
<?php else : ?> <?php else :
<!-- <?php echo get_permalink(); ?> --> // echo " category " . $category . " catt2 " . $catt2 . " category 0 " . $category[0]->term_id;?>
<h3 class="box nosub<?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php echo the_title();?> </a> </h3> <div class="head-entry">
<?php endif;?> <?php if (is_home()) : ?>
<?php endif; ?> <span class="cat">
</div> <a href="<?php echo get_category_link( $category[0]->term_id );?>"><?php echo $category[0]->name;?></a>
<?php $lang = qtrans_getLanguage(); </span>
<h2 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php echo the_title();?> </a> </h2>
<?php else : ?>
<?php if (has_subcategories($catt2)) : ?>
<span class="cat"> <!-- atenció cal assingar cada post a la subcategoria, sinó sortirà la categoria pare -->
<a href="<?php echo get_category_link( $category[0]->term_id );?>"><?php echo $category[0]->name;?></a>
</span>
<h3 class="box <?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php echo the_title();?> </a> </h3>
<?php else : ?>
<?php //echo get_permalink(); ?>
<h3 class="box nosub<?php echo $tipus;?>"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php echo the_title();?> </a> </h3>
<?php endif;?>
<?php endif; ?>
</div>
<?php
$lang = qtrans_getLanguage();
if($lang == 'ca' and (get_post_meta($post->ID, 'data_activitat', true) )): if($lang == 'ca' and (get_post_meta($post->ID, 'data_activitat', true) )):
?><p class="meta box"><?php echo get_post_meta($post->ID, 'data_activitat', true); if (get_post_meta($post->ID, 'horari_activitat', true)) echo " / ".get_post_meta($post->ID, 'horari_activitat', true); if (get_post_meta($post->ID, 'lloc_activitat', true)) echo " - ".get_post_meta($post->ID, 'lloc_activitat', true); ?></p><?php ?>
elseif($lang == 'es' and (get_post_meta($post->ID, 'data_activitatES', true) )): <p class="meta box">
?><p class="meta box"><?php echo get_post_meta($post->ID, 'data_activitatES', true); if (get_post_meta($post->ID, 'horari_activitat', true)) echo " / ".get_post_meta($post->ID, 'horari_activitat', true); if (get_post_meta($post->ID, 'lloc_activitat', true)) echo " - ".get_post_meta($post->ID, 'lloc_activitat', true); ?></p><?php <?php
elseif($lang == 'en' and (get_post_meta($post->ID, 'data_activitatEN', true) )): echo get_post_meta($post->ID, 'data_activitat', true);
?><p class="meta box"><?php echo get_post_meta($post->ID, 'data_activitatEN', true); if (get_post_meta($post->ID, 'horari_activitat', true)) echo " / ".get_post_meta($post->ID, 'horari_activitat', true); if (get_post_meta($post->ID, 'lloc_activitat', true)) echo " - ".get_post_meta($post->ID, 'lloc_activitat', true); ?></p><?php if (get_post_meta($post->ID, 'horari_activitat', true)) echo " / ".get_post_meta($post->ID, 'horari_activitat', true);
else: ?> if (get_post_meta($post->ID, 'lloc_activitat', true)) echo " - ".get_post_meta($post->ID, 'lloc_activitat', true);
<p class="meta box novista"><?php // echo __('Publicat el ','hangar') . the_time('d F Y') ?></p> ?>
<?php endif;?> </p>
<?php
<?php if ( has_post_thumbnail() ) : ?> elseif($lang == 'es' and (get_post_meta($post->ID, 'data_activitatES', true) )):
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > ?>
<?php the_post_thumbnail('thumbnail'); ?> <p class="meta box">
</a> <?php
<?php else : ?> echo get_post_meta($post->ID, 'data_activitatES', true);
<!--<img class="noimatge" width="200" height="150" title="imatge no disponible" alt="imatge no disponible" src="<?php //echo get_template_directory_uri() .'/images/noimatge.jpg';?>" />--> if (get_post_meta($post->ID, 'horari_activitat', true)) echo " / ".get_post_meta($post->ID, 'horari_activitat', true);
<?php endif; ?> if (get_post_meta($post->ID, 'lloc_activitat', true)) echo " - ".get_post_meta($post->ID, 'lloc_activitat', true);
<?php if (has_excerpt()) : ?> ?>
<p class="excerptbox"><?php echo get_the_excerpt(); ?></p> </p>
<?php else :?> <?php
<div class="contingut curt"><?php echo custom_wp_trim_excerpt(); ?></div> elseif($lang == 'en' and (get_post_meta($post->ID, 'data_activitatEN', true) )):
?>
<?php endif; ?> <p class="meta box">
<?php
<div class="boxpeu" > echo get_post_meta($post->ID, 'data_activitatEN', true);
<a href="<?php the_permalink(); ?>" class="peubox" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><img alt="enllaç" src="<?php echo get_template_directory_uri() . '/images/fletxalink.png';?>" /></a> if (get_post_meta($post->ID, 'horari_activitat', true)) echo " / ".get_post_meta($post->ID, 'horari_activitat', true);
<?php if (is_home()) : ?> if (get_post_meta($post->ID, 'lloc_activitat', true)) echo " - ".get_post_meta($post->ID, 'lloc_activitat', true);
<!-- els quadrets link a la categoria pare --> ?>
<a href="<?php echo get_category_link( $category[0]->term_id ); ?>" class="peudret" title="<?php echo $category[0]->name; ?>" rel="bookmark"><img alt="enllaç a la categoria" src="<?php echo get_template_directory_uri() . '/images/totslink.png';?>" /></a> </p>
<?php endif;?> <?php else: ?>
</div> <p class="meta box novista"><?php // echo __('Publicat el ','hangar') . the_time('d F Y') ?></p>
<?php endif; ?> <?php endif;?>
</li><!-- post .hentry --> <?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail('thumbnail'); ?>
</a>
<?php endif; ?>
<?php
if (has_excerpt()) : ?>
<p class="excerptbox">
<?php
// echo get_the_excerpt();
// https://developer.wordpress.org/reference/functions/wp_trim_words/
echo wp_trim_words(get_the_excerpt(), 60,' <a href="'. get_permalink($post->ID) . '">[...]</a>')
?>
</p>
<?php else :?>
<div class="contingut curt"><?php echo custom_wp_trim_excerpt(); ?></div>
<?php endif; ?>
<div class="boxpeu" >
<a href="<?php the_permalink(); ?>" class="peubox" title="<?php printf( esc_attr__( 'Permalink to %s', 'hangar' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><img alt="enllaç" src="<?php echo get_template_directory_uri() . '/images/fletxalink.png';?>" /></a>
<?php if (is_home()) : ?>
<!-- els quadrets link a la categoria pare -->
<a href="<?php echo get_category_link( $category[0]->term_id ); ?>" class="peudret" title="<?php echo $category[0]->name; ?>" rel="bookmark"><img alt="enllaç a la categoria" src="<?php echo get_template_directory_uri() . '/images/totslink.png';?>" /></a>
<?php endif;?>
</div>
<?php endif; ?>
</li><!-- post .hentry -->

View File

@ -1,13 +1,13 @@
<?php <?php
/** /**
* Template Name: Category ample * Template Name: Category ample
* *
* Seccions de categories amd presentaçio de contingut ample. * Seccions de categories amd presentaçio de contingut ample.
* @link http://themehybrid.com/themes/hybrid/page-templates/categories * @link http://themehybrid.com/themes/hybrid/page-templates/categories
* *
* @package Hangar * @package Hangar
* @subpackage Template * @subpackage Template
*/ */
get_header(); ?> get_header(); ?>
@ -19,44 +19,46 @@ get_header(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class("boxentry"); ?>> <div id="post-<?php the_ID(); ?>" <?php post_class("boxentry"); ?>>
<div class="entry-content"> <div class="entry-content">
<?php echo '<h2 class="box index">'; <?php echo '<h2 class="box index">';
echo single_cat_title( '', false ) ; echo '</h2>' ; ?> echo single_cat_title( '', false ) ; echo '</h2>' ; ?>
<?php $category_description = category_description(); <?php $category_description = category_description();
if ( ! empty( $category_description ) ) : if ( ! empty( $category_description ) ) :
echo '<div class="descseccio">'. category_description(). '</div>'; echo '<div class="descseccio">'. category_description(). '</div>';
endif; endif;
?> ?>
</div><!-- .entry-content --> </div><!-- .entry-content -->
</div><!-- post .boxentry --> </div><!-- post .boxentry -->
</div><!-- .indexall.wide --> </div><!-- .indexall.wide -->
<?php $catt2 = get_query_var('cat'); ?>
<?php $catt2 = get_query_var('cat'); ?>
<div id="content" class="indexall fills"> <div id="content" class="indexall fills">
<ul> <ul>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php $tipus = 'catt'; <?php
$category = get_the_category(); $tipus = 'catt';
?> $category = get_the_category();
?>
<?php include(TEMPLATEPATH . "/caixes.php"); ?> <?php include(TEMPLATEPATH . "/caixes.php"); ?>
<?php endwhile; ?> <?php endwhile; ?>
</ul>
<?php wp_pagenavi(); /* kriesi_pagination();*/?>
<?php else: ?>
<p class="no-data"> </ul>
<?php _e( 'Apologies, but no results were found.', 'hangar' ); ?> </div><!-- .indexall.fills -->
</p><!-- .no-data --> <?php wp_pagenavi(); /* kriesi_pagination();*/?>
<?php else: ?>
<p class="no-data">
<?php _e( 'Apologies, but no results were found.', 'hangar' ); ?>
</p><!-- .no-data -->
</div><!-- .indexall.fills -->
<?php endif; ?>
<?php endif; ?>
</div><!-- .indexall.fills -->
</div><!--end #main--> </div><!--end #main-->
<?php get_footer(); ?> <?php get_footer(); ?>

View File

@ -1,4 +1,4 @@
<?php <?php
//wp_set_password( 'testhangar', 1 ); //wp_set_password( 'testhangar', 1 );
@ -28,123 +28,29 @@ require_once(THEMELIB . '/breadcrumb.php');
// Create custom posts and custom fields // Create custom posts and custom fields
require_once(THEMELIB . '/custom-posts.php'); require_once(THEMELIB . '/custom-posts.php');
function new_excerpt_length($length) { function hangar_excerpt_length($length) {
return 20; return 20;
} }
add_filter('excerpt_length', 'new_excerpt_length'); add_filter('excerpt_length', 'hangar_excerpt_length');
function new_excerpt_more($more) { function hangar_excerpt_more($more) {
global $post; global $post;
return '<a href="'. get_permalink($post->ID) . '"> [...]</a>'; return '<a href="'. get_permalink($post->ID) . '"> [...]</a>';
} }
add_filter('excerpt_more', 'new_excerpt_more'); add_filter('excerpt_more', 'hangar_excerpt_more');
// custom login screen i peu de l'admin // custom login screen i peu de l'admin
function custom_login() { function custom_login() {
//echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('template_directory').'/custom-login/custom-login.css" />';
// time stamp for caching
// https://developer.wordpress.org/reference/functions/wp_enqueue_style/#comment-2056
echo '<link rel="stylesheet" type="text/css" href="'. get_template_directory_uri() .'/custom-login/custom-login.css" />'; echo '<link rel="stylesheet" type="text/css" href="'. get_template_directory_uri() .'/custom-login/custom-login.css" />';
} }
add_action('login_head', 'custom_login'); add_action('login_head', 'custom_login');
//function change_wp_login_url() {
//echo bloginfo('url');
//}
//add_filter('login_headerurl', 'change_wp_login_url');
//function change_wp_login_title() {
//echo 'Powered by ' . get_option('blogname');
//}
//add_filter('login_headertitle', 'change_wp_login_title');
function remove_footer_admin () { function remove_footer_admin () {
echo 'Custom text | Copyright &copy; message'; echo 'Custom text | Copyright &copy; message';
} }
add_filter('admin_footer_text', 'remove_footer_admin'); add_filter('admin_footer_text', 'remove_footer_admin');
// THIS GIVES US SOME OPTIONS FOR STYLING THE ADMIN AREA
function custom_controls() {
// echo '<style type="text/css">
// label.lateral{width: 100px;}
// input.lateral{width: 150px; border-color: #ddd;}
// .petit {width: 20px!important;}
// label.dd{float:left; width:250px;}
// input.dd{width:450px;}
// </style>';
}
add_action('admin_head', 'custom_controls');
/* create calendar event when saving post with dates */
// function create_event( $post_id ) {
//
// // If this is just a revision, don't send the email.
// if ( wp_is_post_revision( $post_id ) )
// return;
//
// $myPost = get_post($post_id);
// if (has_category(array('news', 'activitats-dels-residents'), $post_id) &&
// !$update &&
// $myPost->post_modified_gmt == $myPost->post_date_gmt) {
//
// //The URL that we want to send a PUT request to.
// $uid = get_the_guid( $post_id );
// $url = 'https://cloud.hangar.org/remote.php/dav/calendars/hangar/hangar_activitats/neu.ics';
// $headers = array('Content-Type: text/calendar', 'charset=utf-8');
// $userpwd = 'hangar:AV63xlklCuOJgYTnHz5smX4chiAaDpJo';
// $description = get_the_content( $post_id );
// $summary = get_the_title( $post_id );
// $tstart = gmdate("Ymd\THis\Z", strtotime("-2 days"));
// $tend = gmdate("Ymd\THis\Z", strtotime("-2 days"));
// $tstamp = gmdate("Ymd\THis\Z");
//
// // vcalendar
// $body = 'BEGIN:VCALENDAR
// VERSION:2.0
// BEGIN:VEVENT
// DTSTAMP:$tstamp
// DTSTART:$tstart
// DTEND:$tend
// UID:$uid
// DESCRIPTION:$description
// LOCATION:Hangar
// SUMMARY:$summary
// END:VEVENT
// END:VCALENDAR';
//
// //Initiate cURL
// $ch = curl_init($url);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// curl_setopt($ch, CURLOPT_USERPWD, $userpwd);
// //curl_setopt($ch, CURLOPT_PUT, true);
// curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
// curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
//
// //Execute the request.
// $response = curl_exec($ch);
// curl_close($ch);
//
// // send confirmation mail
// $post_title = $summary;
// $post_excerpt = $description;
// $post_url = get_permalink( $post_id );
// $subject = 'A new EVENT post has been saved';
//
// $message = "A new post has been created on your website:\n\n";
// $message .= $post_title . ": " . $post_url . "\n\n";
// $message .= $post_excerpt . "\n\n";
// $message .= $uid . "\n\n";
// $message .= print_r($response);
//
// // Send email to admin.
// wp_mail( 'gerald@hangar.org', $subject, $message );
// }
// }
// add_action( 'save_post', 'create_event', 10, 3 );
//per imprimir el content sense que ens tregui l'html //per imprimir el content sense que ens tregui l'html
function get_the_content_with_formatting ($more_link_text = '(...)', $stripteaser = 0, $more_file = '') { function get_the_content_with_formatting ($more_link_text = '(...)', $stripteaser = 0, $more_file = '') {
@ -154,24 +60,6 @@ function get_the_content_with_formatting ($more_link_text = '(...)', $striptease
$content = substr($content, 0,400); $content = substr($content, 0,400);
return $content; return $content;
} }
//per imprimir l'excerpt indicant un nombre de caràcters màxim
// function the_excerpt_max_charlength($charlength) {
// $excerpt = get_the_excerpt();
// $charlength++;
// if(strlen($excerpt)>$charlength) {
// $subex = substr($excerpt,0,$charlength-5);
// $exwords = explode(" ",$subex);
// $excut = -(strlen($exwords[count($exwords)-1]));
// if($excut<0) {
// echo substr($subex,0,$excut);
// } else {
// echo $subex;
// }
// echo "[...]";
// } else {
// echo $excerpt;
// }
// }
//afegir estils a l'editor //afegir estils a l'editor
@ -248,7 +136,7 @@ function has_subcategories($catt)
endif; endif;
} }
//contruim un panell de control a l'administració per a que vegin les que estan marcades per a sortir a la home //construim un panell de control a l'administració per a que vegin les que estan marcades per a sortir a la home
function menu_control_home(){ function menu_control_home(){
add_menu_page( "Control Home","Control Home", "add_users", "control_home", "control_home", "", 6 ); add_menu_page( "Control Home","Control Home", "add_users", "control_home", "control_home", "", 6 );
} }
@ -374,37 +262,6 @@ class my_Walker_Nav_Menu extends Walker_Nav_Menu {
<?php <?php
/* Code that preserves HTML formating to the automatically generated Excerpt. */ /* Code that preserves HTML formating to the automatically generated Excerpt. */
/* Also modifies the default excerpt_length and excerpt_more filters. */ /* Also modifies the default excerpt_length and excerpt_more filters. */
/*function custom_wp_trim_excerpt($text) {
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]&gt;', $text);
//Add the allowed HTML tags separated by a comma.
$allowed_tags = '<p>,<a>,<em>,<strong>';
$text = strip_tags($text, $allowed_tags);
//Change the excerpt word count.
$excerpt_word_count = 60;
$excerpt_length = apply_filters('excerpt_length', $excerpt_word_count);
//Change the excerpt ending.
$excerpt_end = ' <a href="'. get_permalink($post->ID) . '">' . '&raquo; Continue Reading.' . '</a>';
$excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end);
$words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
if ( count($words) > $excerpt_length ) {
array_pop($words);
$text = implode(' ', $words);
$text = $text . $excerpt_more;
} else {
$text = implode(' ', $words);
}
}*/
// https://stackoverflow.com/questions/15283948/wordpress-html-tags-strip-on-manual-excerpt // https://stackoverflow.com/questions/15283948/wordpress-html-tags-strip-on-manual-excerpt
function custom_wp_trim_excerpt($text='') { function custom_wp_trim_excerpt($text='') {
@ -429,7 +286,7 @@ if ( '' == $text ) {
$excerpt_word_count = 200; /*** MODIFY THIS. change the excerpt word count to any integer you like.***/ $excerpt_word_count = 200; /*** MODIFY THIS. change the excerpt word count to any integer you like.***/
$excerpt_length = apply_filters('excerpt_length', $excerpt_word_count); $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count);
$excerpt_end = '[...]'; /*** MODIFY THIS. change the excerpt endind to something else.***/ $excerpt_end = '<a href="'. get_permalink($post->ID) . '"> [...]</a>'; /*** MODIFY THIS. change the excerpt endind to something else.***/
$excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end);
$words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);