Home › Forum › Problemi Vari con WP › Lista ultimi post in pagina non wordpress
-
AutorePost
-
-
14 Giugno 2008 alle 12:40 #6980TheSneezerPartecipante
Ciao a tutti,
ho una domanda da porvi.
Se il mio blog wordpress (versione 2.5.1) è localizzato non nella root, ma in una cartella del sito, esempio http://www.miosito.it/wpblog/, esiste un modo per includere nella index del sito (www.miosito.it/index.php) la lista degli ultimi post pubblicati anche se questa pagina non appartiene alla cartella dove è stato installato wordpress?
Ciao!
-
14 Giugno 2008 alle 12:41 #54725wollyAmministratore del forum
cerca nel forum visto che se ne è parlato diverse volte negli ultimi giorni
-
14 Giugno 2008 alle 13:13 #54726TheSneezerPartecipante
grazie, ho trovato i post che parlavano dell’argomento e sono riuscito ad implementare la cosa utilizzando questo codice:
<?php
$db= @mysql_connect('localhost','utente','password');
mysql_select_db('nomedatabase' , $db);
$con = mysql_connect("localhost","utente","password");
$sel_db = mysql_select_db("nomedatabase", $con);
$result = mysql_query("select * FROM wp_posts WHERE post_type ='post' ORDER BY id desc limit 10 " ,$db);
while ($records = mysql_fetch_assoc($result)) {
echo "". $records ."<br>";
}
?>
L'unico problema è che vengono inseriti anche le bozze di post e i post programmati ma non ancora pubblicati. Come si può modificare il codice?
Inoltre è possibile linkare direttamente l'url riscritto (http://localhost/wpblog/titolo-del-post/) invece di http://localhost/wpblog/index.php?p=id?
-
14 Giugno 2008 alle 13:29 #54728ondapiPartecipante
-
14 Giugno 2008 alle 13:38 #54729TheSneezerPartecipante
ciao ondapi,
ho letto quel topic, e ho utilizzato il codice che hai suggerito.
Nel codice che ho inserito sopra non viene visualizzata correttamente l’utima riga, che sarebbe invece:
echo "". $records['post_title'] ."<br>";
Non riesco a farlo visualizzare correttamente, guarda nel codice html di questa pagina per vederlo …
Per il primo problema ho già risolto unsando
post_status = 'publish'
mentre per il secondo, cioè quello di linkare l'url riscritto, come si potrebbe fare?
-
14 Giugno 2008 alle 14:26 #54730ondapiPartecipante
esatto aggiungendo and post_status =’publish’ alla query hai ristretto la tua ricerca ai post pubblicati,
per la seconda opzione, io avevo scelto l’id perchè utilizzo il permalink predefinito ( ?p=123 ) e mi torna utile associare il post ad un id, nel tuo caso la facceda si complica, non so dove wp vada a generare il permalink, non penso sia impossibile, prova ad usare il campo guid della medesima tabella wp_posts, che mi pare tenga conto dell’url del post
-
14 Giugno 2008 alle 15:37 #54736SteveAglAmministratore del forum
non so dove wp vada a generare il permalink,
http://codex.wordpress.org/Template_Tags/get_permalink
date un’occhiata anche qui
http://www.wpitaly.it/forum/topic/7364?replies=11#post-30077
-
16 Giugno 2008 alle 18:37 #54817TheSneezerPartecipante
Grazie mille a entrambi!! Ho risolto il mio problema personalizzando il codice postato da Arturo qui:
-
19 Giugno 2008 alle 20:34 #54943alessandro85Partecipante
sono riuscito a usare il tuo script.. yuppi ya ye.
http://www.intotheoz.com/test/
ora so che forse è impossibile ma secondo voi è fattibile inserire magari in small il time a cui è stato inserito il messaggio e sotto il riassunto non cliccabile?
p.s. se avete windows il sito si vede strano forse.. non è definitivo haha
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.