Salve a tutti,
Sto cercando di apportare delle modifiche al mio template wp, chiedo aiuto agli esperti di php perché son davvero alle prime armi..
Il mio obiettivo è che per ogni categoria vorrei avere un piccolo testo di presentazione (diverso per ognuna di esse), solo nella prima pagina della Categoria. Mi sono documentata e ho trovato queste istruzioni (codex.wordpress.org/Category_Templates) da seguire per ottenere quel risultato.
Sto seguendo 'Different text on some category pages' e 'text displaying only on first page of archive'.
Mi suggerisce di aggiungere dei codici fuori dal loop (outside the loop) e above the loop (sopra al loop).
Qual è la posizione precisa in cui devo metterli? vi indico la bozza di php sui cui devo lavorare..
Esempio: ho due categorie 'arredamento casa' ed 'arredamento negozi'
[PHP]<?php get_header(); ?>
<div id="content">
<?php if (is_category('arredamento casa')) : ?><p>This is the text to describe category arredamento casa </p><?php elseif (is_category('arredamento negozi')) : ?><p>This is the text to describe category arredamento negozi</p><?php else : ?><p>This is some generic text to describe all other category pages, I could be left blank</p><?php endif; ?>
<?php if ( $paged < 2 ) : ?><p>Text for first page of Category archive.</p><?php else : ?><p>Text for subsequent pages of Category.Can be left out.</p><?php endif; ?> <?php if (have_posts()) : ?>
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
<h3 class="block-title">
<?php if ( is_day() ) : ?>
<?php printf( __( 'Daily Archives: %s', 'delicacy' ), '<span>' . get_the_date() . '</span>' ); ?>
<?php elseif ( is_month() ) : ?>
<?php printf( __( 'Monthly Archives: %s', 'delicacy' ), '<span>' . get_the_date( 'F Y' ) . '</span>' ); ?>
<?php elseif ( is_year() ) : ?>
<?php printf( __( 'Yearly Archives: %s', 'delicacy' ), '<span>' . get_the_date( 'Y' ) . '</span>' ); ?>
<?php elseif ( is_category() ) : ?>
<?php _e( 'Blog Archives for category', 'delicacy' ) ?> <?php single_cat_title(); ?>
<?php elseif ( is_tag() ) : ?>
<?php _e( 'Blog Archives for tag', 'delicacy' ) ?> <?php single_tag_title(); ?>
<?php else : ?>
<?php _e( 'Blog Archives', 'delicacy' ); ?>
<?php endif; ?>
</h3>
<div class="post-list">
<?php while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('list-post-item'); ?>>
<?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a>
<?php } ?>
<h2><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="entry-meta">
<span class="date"><?php the_time( get_option('date_format') ); ?></span>
<span class="comments"><?php comments_popup_link(__('No comments','delicacy'), __('1 comment','delicacy'), __('Comments: %','delicacy')); ?></span>
<?php if(get_the_title() == '') : ?>
<a href="<?php the_permalink(); ?>" class="thepermalink" title="<?php _e( 'Permalink', 'delicacy' ); ?>"><?php _e( 'Permalink', 'delicacy' ); ?></a>
<?php endif; ?>
</div>
<?php the_excerpt(); ?>
</div>
<div class="deco-line"></div>
<?php endwhile; ?>
<?php
if(function_exists('wp_pagenavi')) :
wp_pagenavi();
else :
?>
<div class="wp-pagenavi">
<div class="alignleft"><?php next_posts_link('« '.__('Previous Entries','delicacy')) ?></div>
<div class="alignright"><?php previous_posts_link(__('Next entries','delicacy').' »') ?></div>
</div>
<?php endif; ?>
<?php else : ?>
<h3 class="block-title"><?php _e('Not found', 'delicacy'); ?></h3>
<?php endif; ?>
</div><!-- end #post-list -->
</div><!-- end #content -->
<?php get_sidebar(); ?>
</div><!-- end-wrapper -->
<?php get_footer(); ?>
[/PHP]
La posizione è corretta? Qualcuno mi può aiutare?? Grazie!!! ![;) 😉](https://connect.gt/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=8s11thadplu)