Risposte nei forum create
-
AutorePost
-
ManuelHTPartecipante
Scusami ma non riesco a trovare la soluzione in quella pagina, sai come posso risolvere?
ManuelHTPartecipanteHo risolto il problema con la tua query però togliendo
$array=mysql_fetch_array($query);
prima del while e mettendo "ORDER BY comment_ID" invece che "ORDER BY c.comment_ID".
Ora funziona bene grazie a tutti e due
ManuelHTPartecipanteSi ma il problema ora non è che non mi fa vedere gli utenti, e che mi fa vedere i commenti non in base agli ultimi inseriti dall’utente.
E’ molto strano perché comunque la query è molto precisa e non lascia molto spazio ad errori secondo me. Cosa potrebbe mai interferire con quello?
ManuelHTPartecipanteIl codice completo messo nel functions.php è questo:
function post_comments() {
global $current_user;
get_currentuserinfo();
global $user_ID;
if ($user_ID == '1') {
$sql="SELECT DISTINCT (c.comment_post_ID) AS post_id, p.post_title FROM wp_comments c, wp_posts p WHERE c.comment_post_ID = p.ID AND c.user_id=$user_ID ORDER BY c.comment_ID DESC LIMIT 6" ;
$query=@mysql_query($sql) or die (mysql_error());
$array=mysql_fetch_array($query);
while ($array=mysql_fetch_array($query))
{
$post_ID= $array;
echo $post_ID.", ";
$post_titolo= $array;
echo $post_titolo.', ';
}
}
}
Come vedi le variabili globali le ho richiamate.
PS: L'istruzione if l'ho messa solo per fare delle prove in modo che i risultati siano visibili solo se ci si logga come amministratore e quindi user_ID=1.
ManuelHTPartecipanteEppure non so perchè ma ancora mi mostra i commenti sballati.
Mi mostra per primo il commento al post 87 che è il penultimo che ho commentato. Poi mi mostra il 423 che è stato commentato molto tempo fa, poi il 783, 773, 746 ecc e poi tutti in ordine decrescente però di ID post e non di commento.
Come mai?
ManuelHTPartecipanteSi non ho messo il codice ma ho detto che nella index funziona mentre nell’header no quindi non capisco quale sia la differenza tra metterlo nella index e nell’header.
Comunque ecco il codice:
global $current_user;
get_currentuserinfo();
$sql="SELECT * FROM wp_comments WHERE user_id='$user_ID' GROUP BY comment_post_ID ORDER BY comment_ID DESC" ;
$query=@mysql_query($sql) or die (mysql_error());
$array=mysql_fetch_array($query);
while ($array=mysql_fetch_array($query))
{
$post_ID= $array;
echo $post_ID.", ";
$sql_post="SELECT post_title FROM wp_posts WHERE ID='$post_ID'" ;
$query_post=@mysql_query($sql_post) or die (mysql_error());
$array_post=mysql_fetch_array($query_post);
$post_titolo= $array_post;
echo $post_titolo.', ';
}
Poi ho un altro problema, in pratica uso GROUP BY per raggruppare gli ID dei post e li ordino in base al ID del commento solo che non me li fa vedere né in base al ID dei commenti né in base al ID dei post
ManuelHTPartecipanteSi perchè? Cosa mi è sfuggito?
ManuelHTPartecipanteHo capito la soluzione, prima mi era sfuggita, in pratica si impostano direttamente nel codice che serve per mostrare il thumbnail:
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(180,220), array("class" => "alignleft post_thumbnail")); } ?>
-
AutorePost