Home › Forum › Plugin e temi di WP › Link in una pagina
-
AutorePost
-
-
11 Settembre 2006 alle 9:58 #2107AdrianoPartecipante
Salve a tutti,
vorrei sapere se è possibile visualizzare link da me inseriti in una pagina apposita al posto di visualizzarli nella sidebar. Non sò se ciò è possibile. Sono disposto anche a scrivere un pò di codice. Non ho infatti ben capito come inserire e far eseguire del codice all’interno di una pagina. Ho anche provato ad inserire codice php direttamente da mysql, ma questo non viene eseguito.
Grazie per le vostre risposte
Ciao
-
11 Settembre 2006 alle 16:10 #40014degraPartecipante
per avere i link in una pagina (o dove vuoi tu) basta chiamare il codice
<?php get_links_list('parametro'); ?>
, dove per parametro si intende uno dei 2 parametri possibili: “id” e “order”: il primo ordina per “numero” di categoria, il secondo per nome. Per ottenere l’ordinamento inverso, basta anteporre “_” (underscore) al parametro.Per maggiori info: http://codex.wordpress.org/Template_Tags/get_links_list.
Invece per mettere del codice in una pagina (o in un post) ci sono vari plugin che puoi usare: io uso Exec-PHP.
-
12 Settembre 2006 alle 14:48 #40019AdrianoPartecipante
Ciao degra
ho installato il plugins che mi hai detto ma quando eseguo il codice mi restituisce un errore. Sembrerebbe che non sia possibile usare gli oggetti wordpress. Questo è il codice:
<?php
$QueryLink="SELECT link_name, link_url, link_description FROM wp_links WHERE link_visible='Y' ORDER BY link_rating";
$wpdb->query($QueryLink);
$s = $wpdb->get_results("$QueryLink");
foreach ($s as $i)
{
echo "<p style="font-weight: bold"><a target="_blank" href="" .$i->link_url ."">".$i->link_name ."</a></p><p style="font-style: italic">" .$i->link_description ."</p>";
}
?>
L’errore invece è questo:
Fatal error: Call to a member function on a non-object in /home/andrea/public_html/test/wp-content/plugins/exec-php/link.php on line 3
Dove sbaglio?
-
12 Settembre 2006 alle 14:51 #40020AdrianoPartecipante
Ciao degra
ho installato il plugins che mi hai detto ma quando eseguo il codice mi restituisce un errore. Sembrerebbe che non sia possibile usare gli oggetti wordpress. Questo è il codice:
$QueryLink="SELECT link_name, link_url, link_description FROM wp_links WHERE link_visible='Y' ORDER BY link_rating";
$wpdb->query($QueryLink);
$s = $wpdb->get_results("$QueryLink");
foreach ($s as $i)
{
echo "<p style="font-weight: bold"><a target="_blank" href="" .$i->link_url ."">".$i->link_name ."</a></p><p style="font-style: italic">" .$i->link_description ."</p>";
}
L’errore invece è questo:
Fatal error: Call to a member function on a non-object in /home/andrea/public_html/test/wp-content/plugins/exec-php/link.php on line 3
Dove sbaglio?
-
12 Settembre 2006 alle 23:07 #40026degraPartecipante
non capisco… che cos’è tutto quel codice? da dove viene?
-
13 Settembre 2006 alle 0:49 #40029SteveAglAmministratore del forum
Degra->credo sia il codice messo in una pagina / post per visualizzare i link.
polecat->prova a mettere un
global $wpdb;
prima di
$wpdb->query($QueryLink);
-
13 Settembre 2006 alle 17:15 #40035degraPartecipante
sà¬, l’avevo capito, ma mi chiedevo del perchè di tutta questa complessità (che ha poi generato l’errore) quando bastava il tag
-
14 Settembre 2006 alle 23:38 #40052AdrianoPartecipante
mmm forse allora non ho capito!
Quale tag?
Cmq ho inserito anche un global ma l’errore rimane.
Grazie comunque per le indicazioni e scusate il doppio post ma Internet Explorer si era piantato ed evidentemente ho fatto un doppio invio.
Spero che possiate risolvere il mio problema
Grazie ancora
Ciao
-
14 Settembre 2006 alle 23:55 #40053degraPartecipante
il tag è:
<?php get_links_list('parametro'); ?>
, come ho scritto nel primo commento. àˆ lo stesso che si trova nella sidebar per avere il blogroll.Il plugin serve per poterlo inserire in una pagina dall’editor, ma penso che senza il plugin si possa mettere direttamente nel template di una pagina, e poi creare una pagina senza testo che abbia quel template.
-
15 Settembre 2006 alle 11:10 #40062FreeplePartecipante
Io ho risolto con un file nella Dir principale che ho chiamato pp-links.php dove ‘pp’ sta per ‘Personal Pages’. il codice :
<?php
require('./wp-blog-header.php');
get_header(); ?>
<?php get_sidebar(); ?>
<div id="column-contents" class="narrowcolumn" title="Colonna dei contenuti">
<div id="pp-">
<h2>Links da visitare</h2>
Per quanto impegno si possa mettere nello stilare una lista di links si lasciano sempre voragini non lacune ... Segnalatemi pure i Siti che gestite o che per passione visitate, li aggiungerò nella categoria adeguata.
Buona navigazione!
<?php get_links_list(); ?>
</div>
</div>
<?php get_footer(); ?>
Il risultato lo puoi vedere qui: http://www.norisberghen.it/
Ciao!
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.