Home › Forum › Problemi Vari con WP › Problema INTESTAZIONE DINAMICA SU CATEGORIA: cambia nome da sola..sarà impazzita
-
AutorePost
-
-
15 Gennaio 2011 alle 15:31 #16365faremorPartecipante
Ho bisogno del vostro aiuto. Ho nella home paghe una serie di box con i post apprtententi ad una spacifica categoria. Sopra questo box c’è il nome della categoria che immagino come vedeta da codice sotto sia estrapolato dinamicamente, però con un numero ben preciso che gli viene indicato no? es category=8 category=7 ecc… ora perché a volte questa inestazione che immagino sia determinata da `
- <h2 class="latest"><?php the_category(' '); ?></h2>
impazzisce e invece di visualizzarmi solo ad esempio la category=8 mi visualizza anche un sacco di altre categorie? Non dovrebbe visualizzarmi solo quella indicata?
Il codice qui di seguito è un codice che si ripete in cui cambiano solo i riferimenti a categorie diverse...nonostante questo alcuni di queste intestazioni quando pubblico qualche nuovo post impazziscono e prendono l'intestazione della categoria ultima aggiornata...
<div id="content">
<ul class="latest2">
<?php $feature_post = get_posts( 'category=3&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
- <h2 class="latest"><?php the_category(' '); ?></h2>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=3&numberposts=3' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<?php if (function_exists('c2c_get_custom')) : ?>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('title-image','
<?php endif; ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?>
<li class="list-title">" rel="bookmark"><?php the_title(); ?>
<li class="latest-excerpt2"><?php the_excerpt(); ?>
<?php endforeach; ?>
<ul class="latestoneandhalf">
<?php $feature_post = get_posts( 'category=15&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
- <h2 class="latest"><?php the_category(' '); ?></h2>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=15&numberposts=2' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<?php if (function_exists('c2c_get_custom')) : ?>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('post-image','
<?php endif; ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?>
<li class="list-title">" rel="bookmark"><?php the_title(); ?>
<li class="latest-excerptoneandhalf"><?php the_excerpt(); ?>
<?php endforeach; ?>
<ul class="latestoneandhalf">
<?php $feature_post = get_posts( 'category=16&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
- <h2 class="latest"><?php the_category(' '); ?></h2>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=16&numberposts=3' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<?php if (function_exists('c2c_get_custom')) : ?>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('post-image','
<?php endif; ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?>
<li class="list-title">" rel="bookmark"><?php the_title(); ?>
<li class="latest-excerptoneandhalf"><?php the_excerpt(); ?>
<?php endforeach; ?>
</div>
<div id="content">
<ul class="latestoneandhalf">
<?php $feature_post = get_posts( 'category=4&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
- <h2 class="latest"><?php the_category(' '); ?></h2>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=4&numberposts=2' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<?php if (function_exists('c2c_get_custom')) : ?>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('post-image','
<?php endif; ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?>
<li class="list-title">" rel="bookmark"><?php the_title(); ?>
<li class="latest-excerptoneandhalf"><?php the_excerpt(); ?>
<?php endforeach; ?>
<ul class="latestoneandhalf">
<?php $feature_post = get_posts( 'category=5&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
- <h2 class="latest"><?php the_category(' '); ?></h2>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=5&numberposts=2' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<?php if (function_exists('c2c_get_custom')) : ?>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('post-image','
<?php endif; ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?>
<li class="list-title">" rel="bookmark"><?php the_title(); ?>
<li class="latest-excerptoneandhalf"><?php the_excerpt(); ?>
<?php endforeach; ?>
<ul class="latestoneandhalf">
<?php $feature_post = get_posts( 'category=8&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
- <h2 class="latest"><?php the_category(' '); ?></h2>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=8&numberposts=2' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<?php if (function_exists('c2c_get_custom')) : ?>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('post-image','
<?php endif; ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?>
<li class="list-title">" rel="bookmark"><?php the_title(); ?>
<li class="latest-excerptoneandhalf"><?php the_excerpt(); ?>
<?php endforeach; ?>
<ul class="latestoneandhalf">
<?php $feature_post = get_posts( 'category=7&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
- <h2 class="latest"><?php the_category(' '); ?></h2>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=7&numberposts=2' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<?php if (function_exists('c2c_get_custom')) : ?>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('post-image','
<?php endif; ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?>
<li class="list-title">" rel="bookmark"><?php the_title(); ?>
<li class="latest-excerptoneandhalf"><?php the_excerpt(); ?>
<?php endforeach; ?>
</div>
<div id="content">
<ul class="latestoneandhalf">
<?php $feature_post = get_posts( 'category=12&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
- <h2 class="latest"><?php the_category(' '); ?></h2>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=12&numberposts=2' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<?php if (function_exists('c2c_get_custom')) : ?>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('post-image','
<?php endif; ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?>
<li class="list-title">" rel="bookmark"><?php the_title(); ?>
<li class="latest-excerptoneandhalf"><?php the_excerpt(); ?>
<?php endforeach; ?>
<ul class="latestoneandhalf">
<?php $feature_post = get_posts( 'category11&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
- <h2 class="latest"><?php the_category(' '); ?></h2>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=11&numberposts=2' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<?php if (function_exists('c2c_get_custom')) : ?>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('post-image','
<?php endif; ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?>
<li class="list-title">" rel="bookmark"><?php the_title(); ?>
<li class="latest-excerptoneandhalf"><?php the_excerpt(); ?>
<?php endforeach; ?>
<ul class="latestoneandhalf">
<?php $feature_post = get_posts( 'category=10&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
- <h2 class="latest"><?php the_category(' '); ?></h2>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=10&numberposts=2' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<?php if (function_exists('c2c_get_custom')) : ?>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('post-image','
<?php endif; ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?>
<li class="list-title">" rel="bookmark"><?php the_title(); ?>
<li class="latest-excerptoneandhalf"><?php the_excerpt(); ?>
<?php endforeach; ?>
<ul class="latestoneandhalf">
<?php $feature_post = get_posts( 'category=13&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
- <h2 class="latest"><?php the_category(' '); ?></h2>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=13&numberposts=2' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<?php if (function_exists('c2c_get_custom')) : ?>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('post-image','
<?php endif; ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?>
<li class="list-title">" rel="bookmark"><?php the_title(); ?>
<li class="latest-excerptoneandhalf"><?php the_excerpt(); ?>
<?php endforeach; ?>
</div>
<div id="content">
<ul class="latestoneandhalf">
<?php $feature_post = get_posts( 'category=9&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
- <h2 class="latest"><?php the_category(' '); ?></h2>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=9&numberposts=2' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<?php if (function_exists('c2c_get_custom')) : ?>
- " title="<?php the_title(); ?>">
<?php echo c2c_get_custom('post-image','
<?php endif; ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?>
<li class="list-title">" rel="bookmark"><?php the_title(); ?>
<li class="latest-excerptoneandhalf"><?php the_excerpt(); ?>
<?php endforeach; ?>
<iframe width="700" height="350" src="http://www.flickr.com/slideShow/index.gne?set_id=72157624333531404&frifam=true&favorites=own&contacts=y&single=y" frameBorder="4" scrolling="si"></iframe>
</div>
-
15 Gennaio 2011 alle 16:14 #80330SteveAglAmministratore del forum
Postare uan tonnelata di codice non richiesto nont i farà avereinfo prima anzi… comuqnue:
No http://codex.wordpress.org/Function_Reference/the_category the_category mostra i le categorie a cui appartiene iun post (inq uesto casol il primo dell’elenco, quindi le mostra tutte… siome il box chiede quellid i uan categoria specifica usa:
http://codex.wordpress.org/Function_Reference/get_cat_name
passandogli l’ID della categoria che viene viisualizzata.. il tuo tema usa quella funzione perchè suppone che l’articolo venga aassegnato ad una sola categoria ma forse tu non usi questo metodo.. o sbaglio?
-
15 Gennaio 2011 alle 16:45 #80332faremorPartecipante
Scusate per l’eccessivo codice…ridondante
Sisi io sto attento che i post siano solo riferiti ad una categoria però in effetti può essere comodo metterli in due categorie cosଠfinisce in due box, però appunto io vorrei che l’intestazione fosse solo riferita ad una categoria. Possibile che l’unico modo è mettere un link statico? Perché avevo pensato anche a questa soluzione.
Poi c’è un box specifico,che invece di mantenere fisso il nome della categoria espressa nel codice, richiama come intestazione l’ultima categoria aggiornata, ma non quella espressa comen l’id…anche questo non è normale no?
-
15 Gennaio 2011 alle 16:54 #80335SteveAglAmministratore del forum
L’unico modo NON è mettere un link statico ma usare la funzione che ti ho indicato…. ma si vede che non l’hai manco letta. Poi se come dici tu il tme a a pervede si usi una sola categoria o ti adegui o modifichi il tema o ne scegli uno diverso… non puoi prentedere che un tag di WP funzioni diversamente da come è previsto funzioni e the_categori elenca TUTTE le categorie di un post… ergo li non va bene se i post sono multicategoria
-
24 Gennaio 2011 alle 18:59 #80573faremorPartecipante
Ok perfetto ci sto provando l’unica cosa che solo con get category name
<?php echo get_cat_name(3);?>
non ho la categoria linkabile. Se la volessi rendere cliccabile cosa devo fare?
Ho provao a comporre un pò di codice ma non va....
" title="<?php echo get_cat_name(3);?>"><?php echo get_cat_name(3);?>
-
24 Gennaio 2011 alle 20:01 #80575SteveAglAmministratore del forum
usare in combinazione http://codex.wordpress.org/Function_Reference/get_category_link… leggere altro oltre al link fornito visto che li c’è tutto pareva brutto vero… meglio la pappa pronta
-
26 Gennaio 2011 alle 15:59 #80658faremorPartecipante
sei cosଠefficente tu
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.