Home › Forum › Problemi Vari con WP › Post nella sidebar
-
AutorePost
-
-
24 Marzo 2007 alle 23:22 #3461iStevePartecipante
Salve, avrei questa esigenza: nella sidebar avrei bisogno di inserire un post di una determinata categoria, esiste un plugin?
io ho fatto una ricerca nel forum e ho trovato solo random-posts che però non è quello che cerco, io infatti avrei bisogno di inserire uno specifico post e non casuale
grazie
-
25 Marzo 2007 alle 7:26 #44003ondapiPartecipante
io ho avuto la tua stessa esigenza e ho risolto in questo modo
ho inserito nella sidebar questo pezzo di codice che però de vi in parte personalizzare, inserendo al posto di utente e password i tuoi dati di connessione al database, al posto di database il nome del database e su xxxx il numero id del post da visualizzare
<?php $db = mysql_connect('localhost','utente','password')or die('no connessione:' . mysql_error());
mysql_select_db(database , $db);
$result = mysql_query("select * FROM wp_posts WHERE id = 'xxxx' " ,$db);
while ($records = mysql_fetch_assoc($result)) {
echo " <table border=0 width=70%><tr><td>";
echo "<h2>".$records['post_title'] ."</h2></td></tr><tr><td>";
echo "".$records['post_content'] ."</td></tr></table>";
}
?>
inserendo il tag marquee è possibile creare un effetto di scorrimento verticale adatto per news o info veloci in questo caso il post relatico può essere salvato come bozza, quindi non pubblicato direttamente su wp ma ripescato da questo script
penso sia possibile renderlo ancora più fluido accetto ben volentieri suggerimenti
-
25 Marzo 2007 alle 13:34 #44007iStevePartecipante
Grazie, proverò.
Però vorrei capire come si fa ad avere post diversi su diverse colonne tipo questi http://rovato.org/ oppure http://www.ivg.it/ che sono basati appunto su wp.
La mia esigenza è quella di fare un giornale e avrei bisogno di avere notizie diverse in diverse posizioni
Grazie
-
25 Marzo 2007 alle 15:03 #44010ondapiPartecipante
ciao iSteve
se vuoi vedere solo dei singoli post che no devono subire frequenti cambiamenti, puoi ripetere lo script che ti ho mandato, cabiando il codice id, se invece utilizzi una pagina come home page del tuo sito basato su wp e vuoi visualizzare nella sidabar un tot di articoli di una determinata categoria, allora puoi utilizzare un tema grafico che supporta gli asides, tipo k2, con un po’ di pazienza puoi creare più gruppi d articoli suddivisi per categorie
-
25 Marzo 2007 alle 16:56 #44011iStevePartecipante
Ok funziona!
Sarebbe interessante a questo punto se si potesse inserire anzichè id del post, l’ultimo( o gli ultimi 2-3) post creato di una specifica categoria.
Mi spiego mi piacerebbe creare un riquadro con ULTIMISSIME e allora creando una categoria ultimissime potrei aggiornare le notizie a “scalare” tenendo mel riquadro solo l’ultima (o le ultime 2 -3)
Io purtroppo non ci capisco niente di programmazione….
Ciao
-
25 Marzo 2007 alle 17:47 #44013ivgitPartecipante
ciao se mi spieghi esattamente di cosa hai bisogno ti dico come abbiamo fatto
Matteo ivg.it
-
25 Marzo 2007 alle 20:30 #44018iStevePartecipante
io sto creando un giornale online e avrei intenzione di farlo con una colonna centrale con le notizie, poi nelle sidebar vorrei mettere delle finestre con delle notizie specifiche, ad esempio Ultimissime, sport o altra categoria, a dire il vero le ultimissime le vorrei mettere in testa alle altre nella colonna centrale e per questo ho creato una pagina “intro” che mi va sopra le notizie dove ho inserito pubblicità e altro e vorrei metterer appunto le ultimissime, il metodo di ondapi funziona solo che mi mette solo un post specifico, quindi se voglio aggiornare le news devo cancellare il contenuto del post ed inserire altra news, per me sarebbe più pratico avere una categoria e pubblicare solo l’ultimo post inserito (se poi si può decidere 1 – 2 – 3 ecc è meglio) e cosଠvorrei fare nelle sidebar magari con un’altra categoria: Questi post poi si dovrebbero aprire nella colonna centrale per leggere l’articolo intero.
Chissà se mi sono spiegato…..
-
25 Marzo 2007 alle 20:59 #44020ivgitPartecipante
Prima di tutto premetto che noi x ivg abbiamo modificato il db di wp aggiungendo alle varie notizie un rank che va da 1 a 6 in modo da dare una diversa posizione alle notizie nelle varie posizioni della HP.
Per quanto riguarda la sidebar noi abbiamo lo scroll delle notizie delle ultime 24h (tutte le news rank 5-4-3) e gli articoli più commentati.
ciao
-
25 Marzo 2007 alle 21:49 #44022iStevePartecipante
Grazie del consiglio, ma io sono un principiante e non ho capito niente di quello che mi hai detto, so a malapena cambiare qualcosa nel tema, figuriamoci se so fare ad intervenire sul database…
Grazie comunque
-
27 Marzo 2007 alle 1:22 #44039ondapiPartecipante
puoi tranquillamente inserire dei post nella sidebar associati a una specifica categoria, ma per quelle che sono le mie conoscenze (poche) di wp sono in grado di farlko solo con temi che supportano cere funzioni tipo K2, che puoi vedere in azione qui e qui puoi scaricare una versione da qua ma ti consigli di fare delle prove sempre in locale
a questo punto installato il tema devi attivare la terza colonna in pannello di controllo – aspetto – k2 option – custom scheme e optare per swhitc/swhich.css, ma penso non sia indispensabile,
aggiungi nel sidebar.php questo codice
<!--modulo asides-->
<div class="asides"> <h2><?php _e('<b><i>post in evidenza</i></b>'); ?><a href="<?php bloginfo('url'); ?>/?feed=rss&cat=<?php echo $k2asidescategory; ?>" title="RSS Feed for Asides" class="feedlink"><img src="<?php bloginfo('template_directory'); ?>/images/feed.png" alt="RSS" /></a>
</h2>
<?php $temp_query = $wp_query; // save original loop ?>
<?php /* Choose a category to be an 'aside' in the K2 options panel */ query_posts("cat=1&showposts=2"); while (have_posts()) : the_post(); { ?>
<br /><a href="<?php the_permalink() ?>" rel="bookmark" title="Permalink a <?php the_title(); ?>"><?php the_title(); ?></a>
<!--<?php echo wptexturize($post->post_content_20) ?> <span class="metalink"><a href="<?php the_permalink($post->ID) ?>" rel="bookmark" title='Permanent Link to this aside'>#</a></span> -->
<?php /* End Asides Loop */ } endwhile; ?></div>
<?php $wp_query = $temp_query; // revert to original loop ?>
<!--fine modulo asides-->
il file deve essere personalizzato dove
cat=1&showposts=2
indica la categoria da visualizzare e il numero di post di questa, questo esempio mostra solo i titoli dei post, se vuoi far vedere parte del testo dopo<?php the_title(); ?>"><?php the_title(); ?></a>
aggiungi<?php the_excerpt(); ?>
se vuoi vedere l’intero post aggiungi
<?php the_content(); ?>
lo script può essere ripetuto, basta cambiare la categoria.
k2 permette di avere una sidebar dinamica che ti permette di posizionare lo script dove vuoi
-
27 Marzo 2007 alle 10:10 #44041ondapiPartecipante
a volte le soluzioni ti capitano proprio sotto agli occhi prendo spunto da questa discussione di andrea prova con questo script più sempice e che dovrebbe adattarsi su qualsiasi tema
<?php $myposts = get_posts('numberposts=5&category=3');
foreach($myposts as $post) : ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php the_excerpt(); ?></li>
<?php endforeach; ?>
devi modificare sempre le variabili
numberposts=5&category=3
se sostituisci
<?php the_excerpt(); ?> con <?php the_content(); ?>
visualizzi l’intero post, se lo elimini vedi solo il titolo -
27 Marzo 2007 alle 21:35 #44054iStevePartecipante
Grazie, stasera non ho il tempo di provare, farò un po di esperimenti e poi riferisco.
Naturalmente ne approfitto per altri chiarimenti
che cosa intendi ondapi quando mi dici inserendo il tag marquee è possibile creare un effetto di scorrimento
dove lo trovo?
Grazie e scusate se sono proprio una schiappa
-
28 Marzo 2007 alle 20:36 #44067iStevePartecipante
Per ondapi
io ho provato e funziona (a dire il vero io il contenuto del post lo visualizzo mettendo excerpt anzichè content) cè un modo per decidere la lunghezza del contenuto che viene visualizzato? praticamente il simbolo […] mi viene dopo un tot di parole, è possibile decidere dopo quante parole o caratteri metterlo?
Grazie, piano piano sto facendo un bel lavoro….. (almeno per me!)
-
28 Marzo 2007 alle 20:44 #44068andreaPartecipante
Non mi sembra che ci sia un modo per configurare la lunghezza dell’excerpt, però si può utilizzare un plugin tipo “excerpt reloaded”.
-
29 Marzo 2007 alle 7:46 #44073ondapiPartecipante
mi sembra di ricordare che la ‘funzione’ excerpt visualizzi solamente 120 caratteri, fore quel plugin che citi potrebbe fare al caso tuo ma devi verificare
a dire la verità sull’ultimo script che ti ho proposto, quello che ho ripescato da andrea mi da qualche problema in locale, nel senso che mi visualizza i titoli dei post e i link corretti, ma non il contenuto relativo al post, anche a te…?
-
29 Marzo 2007 alle 17:23 #44078iStevePartecipante
A me online lo script di andrea funziona bene usando appunto excerpt
Chiedo un’altra cosa io lo script l’ho messo nella sidebar e mi prende lo “stile” della sidebar
come faccio a dargli la grandezza del font, colore ecc diversa da tutto il resto della sidebar?
devo intevenire nei CSS (che non ci capisco una mazza), oppure cè il modo di aggiungere nello script dimensione font ecc
più che altro è la distanza fra una riga e l’altra che è molto “larga” e mi tirne il post molto lungo (poer questo chiedevo di accorciare le parole)
Grazie
-
29 Marzo 2007 alle 19:52 #44080ondapiPartecipante
i Steve dice
non ci capisco una mazza
a dire il vero anch’io non ci capisco molto, ma mi piace smanettare un po’ col codice, molte volte mi compare errore parse… qualche volta qualcosa va per il verso giusto, ma penso che i forum servino proprio a questo, condividere con gli altri le proprie esperienze i propri insuccessi e qualche volta anche i modesti risultati ottenuti
penso si possa inserire tutto dentro a un div dare un .class e formattare tutto con css, dovrei fare delle prove in locale, magari ti faccio sapere, ma se ci arrivi prima di me passamele grazie
-
29 Marzo 2007 alle 20:57 #44082andreaPartecipante
Per ondapi: in effetti lo script basato su get_posts() funziona se usi the_excerpt(), ma non funziona se usi the_content(). Per rimediare occorre inserire:
<?php setup_postdata($post); ?>
immediatamente prima di richiamare the_content().
-
31 Marzo 2007 alle 11:23 #44090ondapiPartecipante
grazie della dritta andrea ora funziona sia con the_excerpt che con the_content
per correttezza ripropongo il tuo script. ciao
<?php $myposts = get_posts('numberposts=2&category=3');
foreach($myposts as $post) : ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><?php setup_postdata($post); ?> <?php the_excerpt(); ?></li>
<?php endforeach; ?>
-
31 Marzo 2007 alle 19:01 #44098ondapiPartecipante
per iSteve, vediamo se riesco a spiegarti quanto chiesto
- per marquee intendo questo
<marquee behavior=”scroll” direction=”up” scrollamount=”1″ scrolldelay=”1″ onmouseover=” this.stop()” onmouseout=”this.start()” style=”height:70px;width:80%;border:solid #ffffff 1px;background:#ffffff;padding :5px;” height=”70″ width=”80%”> e qui dentro ci inserisci lo script o quello che vuoi
</marquee>
- invece per formattare in modo diverso il contenuto dello script dalla sidebar puoi applicare il css
includi lo script tra <div id=elenco> e </div> e aggiungi al foglio di stile (style.css)
#elenco { background-color: beige;
font-family: 'Verdana', 'Helvetica', Sans-Serif;
font-size: 0.9em;
text-align: left;}
che puoi altamente personalizzare ciao
- per marquee intendo questo
-
1 Aprile 2007 alle 13:05 #44102iStevePartecipante
Wow! grazie ora provo subito.
-
18 Maggio 2007 alle 8:35 #44713LuachanPartecipante
Salve, gente.
Mi riallaccio a questa discussione perchè ho un problema simile a quello di iSteve: devo creare, nella sidebar sinistra del tema che sto usando per http://www.realmatera.it, un box in cui scorrano in maniera dinamica i titoli degli ultimi 4-5 posts, senza distinguerli per categoria o per commenti ricevuti.
Ho provato ad usare gli script proposti in questo thread ma mi mostravano sempre lo stesso articolo (anche eliminando &category=3).
Vorrei fare una cosa tipo quella presente su http://www.ivg.it/ (nella sidebar è presente quel box con le notizie scorrevoli, insomma..)
Grazie in anticipo, come sempre.
-
18 Maggio 2007 alle 8:41 #44714LuachanPartecipante
Allora, ho risolto in parte il problema, ossia adesso i titoli dei post scorrono verticalmente ma il problema sta nel fatto che a scorrere è solo un post e non tutti (ho cancellato numberposts=3&category=3 e come per incanto i titoli di un solo post hanno inziato a scorrere).
Vorrei sapere cosa aggiungere nel codice dello script per far scorrere, ad esempio, gli ultimi 5 post…
Grazie
-
18 Maggio 2007 alle 18:01 #44720ondapiPartecipante
per far scorrere i titoli devi inserire uno script che ti stampa gli ultimi titoli come questo:
<h2>Articoli recenti</h2>
<ul>
<?php wp_get_archives('type=postbypost&limit=10'); ?>
</ul>
dove il 10 è il numero dei post in discussione
se lo inserisci nel marquee io di solito ci aggiungo dei
<br/>
prima e dopo lo script per evitare l’effetto “scalino” -
18 Maggio 2007 alle 20:27 #44725LuachanPartecipante
Grazie mille, ondapi. Ho risolto
-
23 Settembre 2007 alle 14:47 #46810iStevePartecipante
grazie della dritta andrea ora funziona sia con the_excerpt che con the_content
per correttezza ripropongo il tuo script. ciao
<?php $myposts = get_posts('numberposts=2&category=3');
foreach($myposts as $post) : ?>
- "><?php the_title(); ?><?php setup_postdata($post); ?> <?php the_excerpt(); ?>
<?php endforeach; ?>
Torno su questo argomento perchè avrei bisogno di aggiungere il nome dell’autore oltre al titolo
Grazie
-
23 Settembre 2007 alle 15:11 #46811iStevePartecipante
<?php $myposts = get_posts(‘numberposts=2&category=35’);
foreach($myposts as $post) : ?>
- “><?php the_title(); ?><?php setup_postdata($post); ?>
- di: “><?php the_author() ?>
<?php endforeach; ?>
A dire il vero avrei risolto cosà¬, solo che anche l’autore ha il permalink (cioè mi linka all’articolo) mi piacerebbe di più se non avesse nessun link ed il permalink rimanesse solo sul titolo dell’articolo
-
23 Settembre 2007 alle 15:16 #46812iStevePartecipante
Scusate ma oggi sono tonto,
ho risolto eliminando il permalink davanti al php the author (che però nel messaggio sopra non si vede)
scusate se ho disturbato il forum
-
23 Settembre 2007 alle 19:43 #46821ondapiPartecipante
(che però nel messaggio sopra non si vede)
se intendi che hai inserito degli script tra gli apici del tag code e poi se li è mangiati, ti dico che da un po’ di tempo mi capita anche a me, avevo pensato di aprire un topic a proposito
a volte per inserire un tag < scrivo & l t ;
-
30 Settembre 2007 alle 21:54 #47051kikko088Partecipante
io invece ho un’altro problemino….nell’home.php funziona, scorrono gli ultimi articoli, se vado in qualsiasi altra pagina nisba….rimane fermo….why?
kikko088
-
1 Ottobre 2007 alle 17:15 #47065ondapiPartecipante
ciao Kikko se utilizzi il tema k2 attento ai widget
puoi inserire il codice all’interno di uno che supporti il php
tempo fa k2 lo installava di default ora non so, ma ci sono sempre dei plughin che abilitano questa funzione Executable PHP widget
poi dal pannello dei widget devi fare in modo che sia visibile nelle pagine-sezioni di tua scelta
-
2 Ottobre 2007 alle 16:44 #47080kikko088Partecipante
ciau non cambia na pippa….nella home va e nel resto no…:S
kikko088
-
14 Ottobre 2007 alle 8:53 #47351percefalPartecipante
Come modifico:
<?php get_archives(‘postbypost’, 5); ?>
se oltre al titolo volessi visualizzare anche parte del contenuto?
-
14 Gennaio 2008 alle 22:29 #49496gighenPartecipante
ciao,
noto solo ora la discussione, se vuoi post come quelli di rovato.org basta che ti scarichi il tema, guardi com’è fatto e ti copi-incolli le parti che ti servono
-
15 Gennaio 2008 alle 17:42 #49516kikko088Partecipante
ciao a tutti, ho un problema da porvi, sono riuscito a fare funzionare il box grazie all’aiuto di andrea, ora ho quesito da porvi, se attivo polyglot (per avere il sito multilingua) nel box mi traduce tutto alla perfezione tranne il titolo in cui compaiono i tags [lang_xx][/lang_xx], dove sta il problema secondo voi??
il codice è qeusto
<?php
$myposts = get_posts('numberposts=3&order=DESC&orderby=post_date');
foreach($myposts as $post) : ?>
$post->post_title; ?>
<?php setup_postdata($post); ?>
<?php the_excerpt(); ?>
<?php endforeach; ?>
ultima domanda, c'è una soluzione alternativa al marquee per far scorrere le notizie??col marquee e firefoz non si vede bene
kikko088
-
22 Maggio 2008 alle 15:23 #53862piscione75Partecipante
< Salve, gente.
Mi riallaccio a questa discussione perchè ho un problema simile a quello di iSteve: devo creare, nella sidebar sinistra del tema che sto usando per http://www.realmatera.it, un box in cui scorrano in maniera dinamica i titoli degli ultimi 4-5 posts, senza distinguerli per categoria o per commenti ricevuti.
Ho provato ad usare gli script proposti in questo thread ma mi mostravano sempre lo stesso articolo (anche eliminando &category=3).
Vorrei fare una cosa tipo quella presente su http://www.ivg.it/ (nella sidebar è presente quel box con le notizie scorrevoli, insomma..) >
Salve anch’io ho realizzato questo scroll text con il codice in 1pagina. Unico problema che vorrei realizzare comne sul sito “IGV” informazioni e notizie separate che ne sò da orario o altro…
invece a me inserisco le notizie con semplice testo o incollo da una fonte esterna dal sito..ma Poi mi compaiono una dietro l’altra come fosse una sola e lunga notizia. Non so se ho reso l’idea..ho provato mettendo “.” alla fine di ogni notizia..anche con “*”..ma niente il risultato non cambia..!!!!!!!
Help Me..e grazie in anticipo
-
22 Maggio 2008 alle 17:36 #53870
-
26 Maggio 2008 alle 9:58 #53944piscione75Partecipante
“prova con questo”
Grazie ho provato e và meglio xchè mi mette la data e sotto l’articolo, almeno ho separato le varie news…!
Ma mi inserisce sempre la vecchia data del 1 articolo nel sito..!
Invece io vorrei inserire io la news..e mi dovrebbe inserire la data di quando inserico la news..”live” non so se rendo l’idea!!!!!!
ecco il mio codice prova:
<h2>ULTIMISSIME</h2>
<!– creo l’effetto roll–>
<marquee behavior=”scroll” direction=”up” scrollamount=”1″ scrolldelay=”1″ onmouseover=” this.stop()” onmouseout=”this.start()”
style=”height:70px;width:20%;border:solid #ffffff 1px;background:#ffffff;padding :5px;” height=”70″ width=”20%”>
<br/><br/><br/><!– opzionali–>
<?php query_posts(‘showposts=6’); while (have_posts()) : the_post(); ?><!– 5
<!– ora e data–>
<small><?php the_time(‘H:i j F’) ?></small>
<h5 id=”post-<?php the_ID(); ?>”>
jhfshghjjaghsjfahgfslahjgf
jsghghghfsjjhgshjfshjfshgf
jkbsjgfjsjgfjgfjbgfjabgjf
jkfgbjfbgfjgfjkgf</h5>
<!– ora e data–>
<small><?php the_time(‘H:i j F’) ?></small>
<h5 id=”post-<?php the_ID(); ?>”>
sagcgsagucgdagdgggadsgh
dahujhdfhdudaHMN
KJBDAJKDJKJKDAK
<?php endwhile; ?>
<br/><br/><br/><br/><br/><br/><!– opzionali–>
</marquee>
-
26 Maggio 2008 alle 12:04 #53950piscione75Partecipante
ho inserito questo codice…il browser web mi dovrebbe ridare indietro la data/orario al momento che pubblico..invece non mi funziona.!
anche se faccio un file di testo salvo html..non mi restituisce…!!!!!! dove sbalio..?!?
<p>Pubblicato: <?php the_time(‘j/n/Y’); ?> alle <?php the_time(‘H:i’); ?></p>
-
26 Maggio 2008 alle 12:22 #53951SteveAglAmministratore del forum
che the_time è ua funzione di WP che restituisce un valore per l’articolo corrente e quindi fuori dal Loop non funziona!
-
26 Maggio 2008 alle 15:00 #53959piscione75Partecipante
e quindi al posto “the_time” cosa ci và ..!??!
PS: quindi se io inserisco una news in WP..con quel codice…mi dovrebbe dare la data-orario di quando la pubblico..!?
-
26 Maggio 2008 alle 15:51 #53963piscione75Partecipante
fatto ecco:
<h5><big><?php echo (date(“H:i d/m/Y”));;?></big></h5>
grazie
-
5 Giugno 2008 alle 18:40 #54400pmandaraPartecipante
fatto ecco:
<h5><big><?php echo (date(“H:i d/m/Y”));;?></big></h5>
grazie
-
31 Ottobre 2008 alle 21:48 #59027livio1982Partecipante
Ciao a tutti
Io ho un sito joomla e un forum phpbb3, vorrei fare lo stesso lavoro che fate voi, e cioè far apparire gli ultimi post..
Ho provato, ma l’esito è stato molto negativo.
Qualcun può aiutarmi??
-
31 Ottobre 2008 alle 22:07 #59029wollyAmministratore del forum
questo è il supporto di wordpress, sei nel forum sbagliato.
-
18 Gennaio 2010 alle 8:43 #70732fabryvenPartecipante
grazie della dritta andrea ora funziona sia con the_excerpt che con the_content
per correttezza ripropongo il tuo script. ciao
<?php $myposts = get_posts('numberposts=2&category=3');
foreach($myposts as $post) : ?>
- "><?php the_title(); ?><?php setup_postdata($post); ?> <?php the_excerpt(); ?>
<?php endforeach; ?>
‘giorno a tutti…
fino ad oggi ho utilizzato questo script perfettamente e senza nessun problema, ma ho notato che su alcuni blog in cui sono passato alla versione di wordpress 2.9.1 NON FUNZIONA PIU’!
sugli altri ancora non aggiornati va perfettamente e fa il suo lavoro
chi può aiutarmi a rimodularlo per la nuova versione di wordpress? e comem ai non funziona più?
grazie mille a tutti!
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.