Home › Forum › Problemi Vari con WP › Navigazione a pagine ed esclusione categorie da home
-
AutorePost
-
-
11 Ottobre 2012 alle 3:02 #22784Empoli5StellePartecipante
Salve sono il gestore di http://www.empoli5stelle.com sito che ho personalmente creato con l’aiuto di uno webmaster che adesso si è un po’ distratto e quindi per fare alcuni piccoli aggiustamenti devo trovarlo libero, oppure fare da me.
Voglio sistemare il blog soprattutto per quel che riguarda la gestione newsletter e post notifications quindi probabilmente nei prossimi giorni farò altre domande.
L’argomento di questo topic è la navigazione a pagine e l’esclusione di categorie specifiche dalla home.
Attualmente sto escludendo le categorie che vedete nei “minipost” in colonna centrale col plugin “category exclusion” ne ho provati altri, se non tutti, ed il problema rimane. Ovvero attivando questo plugin ed escludendo le categorie che non devono passare dalla home la navigazione a pagine in basso alla home sparisce.
La navigazione a pagine è integrata nel tema, ed anche plugiin tipo pagenav non cambiano la situazione.
Grazie.
-
11 Ottobre 2012 alle 5:48 #97938TittiModeratore
Il plugin che citi non lo trovo, comunque non c’è bisogno di un plugin per escludere categorie dalla home. Inserisci questo codice nel functions.php del tema corrente:
// Escludere categorie da home
function exclude_category($query) {
if ( $query->is_home ) {
$query->set(‘cat’, ‘-ID -ID’);
}
return $query;
}
add_filter(‘pre_get_posts’, ‘exclude_category’);
Dove c’è ID metti il numero ID delle categorie che vuoi escludere. Funziona anche con l’abbreviazione del nome della categoria al posto dell’ID, cosଠcome lo vedi scritto nella pagina della categoria.
-
11 Ottobre 2012 alle 12:44 #97948Empoli5StellePartecipante
Il plugin installato è questo http://wordpress.org/extend/plugins/ultimate-category-excluder/ ma come ripeto ne ho provati diversi e tutti danno lo stesso problema.
Il blog è un network e le categorie da escludere non sono le stesse su tutti i blog, quindi credo di non poter utilizzare la modifica al functions.php sugerita.
Oppure mi sbaglio?
Per alcune modifiche o aggiunte al tema modificammo il footer da apposito spazio nelle opzioni del tema, adesso il footer è questo:
<style>
#header {height:90px; background: #192227 url(/header-background2.png) no-repeat right 0px}
div.content_left {width:529px}
div.content_center {width:250px}
div.content_right {width:200px}
div#content_right_wrapper {width:480px;margin-left:-480px}
div.content_right .widget {background-color:#DDD}
div.article p a, div.article ul a {color:#0000AA}
div.header_ad {float:left; margin:10px}
img.branding {float: none}
</style>
<style>
#logomovimento {
opacity: 0.0; /* CSS3 */
-moz-opacity: 0.0; /* legacy Firefox */
-khtml-opacity: 0.0; /* legacy Safari/Konqueror */
filter: alpha(opacity=00); /* MSIE */
}
</style>
<script>
/* set the opacity of the element (between 0.0 and 1.0) */
function setOpacity(level) {
element.style.opacity = level;
element.style.MozOpacity = level;
element.style.KhtmlOpacity = level;
element.style.filter = "alpha(opacity=" + (level * 100) + ");";
}
var element = document.getElementById('logomovimento');
var duration = 2000; /* 1000 millisecond fade = 1 sec */
var steps = 40; /* number of opacity intervals */
var delay = 5000; /* 5 sec delay before fading out */
function fadeIn(){
for (i = 0; i <= 1; i += (1 / steps)) {
setTimeout("setOpacity(" + i + ")", i * duration);
}
setTimeout("fadeOut()", delay);
}
function fadeOut() {
for (i = 0; i <= 1; i += (1 / steps)) {
setTimeout("setOpacity(" + (1 - i) + ")", i * duration);
}
setTimeout("fadeIn()", delay);
}
setTimeout("fadeIn()", 3000);
</script>
<!-- GOOGLE PLUS -->
<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
{lang: 'it'}
</script>
Posso inserire il codice di cui sopra qui? Ed eventualmente con quale sintassi. -
11 Ottobre 2012 alle 13:29 #97950TittiModeratore
Non avevi detto che è un multisite, e allora probabilmente quel plugin non funziona perché non tutti i plugin funzionano con il network, quando ne cerchi uno devi controllare che dichiari di funzionare sul MU.
Per il codice nel functions, se il tema è lo stesso editerai il file mettendo tutti gli ID di categorie da escludere complessivamente, se il tema è diverso metterai gli ID interessati in ogni file. Se i nomi delle categorie da escludere sono gli stessi ma gli ID sono diversi allora usa l’abbreviazione, scegli te come ti conviene fare.
Altrimenti escludile con questo codice dal file della home o pagina principale (index.php? dipende dal tema…), perché nel file footer?
-
18 Ottobre 2012 alle 20:53 #98076Empoli5StellePartecipante
Ho “risolto” il problema inserendo il codice del link nella index.php ed esludendo cosଠsenza plugin ancune categorie dalle varie home dei blog.
Le “” stanno per il fatto che adesso sono ricomparsi i numeri delle pagine in basso e le categorie sono ok, il problema è che cliccando su uno qualsiasi dei numeri in basso ricarica sempre la home.
-
18 Ottobre 2012 alle 21:33 #98078TittiModeratore
Il problema c’è disattivando tutti i plugin? E con il tema di default? Quando ha smesso di funzionare la navigazione?
Provato a rimettere il footer.php originale? Provato ad aggiornare i permalink?
-
18 Ottobre 2012 alle 22:31 #98079Empoli5StellePartecipante
Il problema c’è disattivando tutti i plugin?
Si
E con il tema di default?
Il Twenty Ten non ha la navigazione a pagine, ma solo “aritcoli più vecchi” e “articoli più recenti” cmq questo scorrimento funziona.
Quando ha smesso di funzionare la navigazione?
Non so è un pezzo che mi porto dietro questo problema, adesso stiamo facendo una piccola ristrutturazione del blog e mi sono impuntato
Provato a rimettere il footer.php originale?
si, e non cambia nulla.
Provato ad aggiornare i permalink?
Si.
-
19 Ottobre 2012 alle 5:58 #98080TittiModeratore
àˆ probabile allora che la colpa sia del tema. Senti dall’autore o cerca nel supporto, tra l’altro è un tema a pagamento e l’assistenza dovrebbe essere compresa.
Edit: se hai fatto delle modifiche al tema, dovresti anche provare ad attivare l’originale e vedere come si comporta, in questa demo ovviamente tutto funziona, oppure prova solo al momento a togliere l’esclusione delle categorie
-
26 Ottobre 2012 alle 17:28 #98269Empoli5StellePartecipante
Lasciamo perdere le risposte del tipo.
Vero che l’assistenza essendo per il primo anno è scaduta, ma è anche vero che non gli abbiamo mai chiesto nulla.
Dopo una prima fase dove faceva finta di non capire, risponde:
Massive News does not include options to remove specific posts from the home page. If you are modifying the code within index.php, you will most likely break the pagination functionality.
Che è una piccola perla di verità .
Quindi nulla se qualcuno ha qualche suggerimento i ringraziamenti sono anticipati.
-
26 Ottobre 2012 alle 19:36 #98271TittiModeratore
Il discorso dell’autore del tema non fa una piega, dato che nativamente la sua paginazione funziona.
Devi confermare e chiarire assolutamente questo: senza plugin attivati e senza nessuna modifica al tema, la paginazione funziona?
La risposta esatta è sà¬
Altrimenti siamo da capo, quindi è importante appurarlo, e fare nuove prove.
Se è cosà¬, allora credo che in questa pagina ci sia il motivo e la soluzione al problema, dato che il codice del Codex che rompe la paginazione usa proprio query_posts:
If query_posts or WP_Query is altering the main loop and the “paged” parameter is not set you’ll need to add it with get_query_var(). This is so WordPress knows exactly what page it’s on.
Leggi tutto, ma al codice dopo quella frase nel tuo caso va cambiata l’ultima riga perché non si tratta di numero di post ma di tutti i post di una o più categorie, da escludere in home.
Dovrebbe diventare una cosa del genere:
Davanti aggiungi la condizione home, poi la prima riga è uguale, e il primo 1 è il valore della prima pagina, il secondo 1 è l’ID di categoria
<?php if ( is_home() ) {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts($query_string . '&cat=-1&paged='.$paged);
} ?>Oppure, cambiando solo l’ultima riga (es. con meno due categorie):
...query_posts("paged=$page&cat=-1,-2");
o ancora:
...query_posts("cat=-1&paged=$paged");
Io non so scrivere PHP, sono soluzioni che ho messo insieme cercando, ma l’importante è capire il concetto, poi se c’è qualcosina da cambiare si vedrà , ma credo che almeno una di quelle (o tutte e tre) dovrebbe andare.
-
26 Ottobre 2012 alle 21:12 #98273Empoli5StellePartecipante
Sembrerebbe funzionare!!!!!!!!
Faccio un po’ di prove e confermo.
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.