Oppure

Loading
31/10/12 20:11
engineer93
Salve a tutti.
Sono alle prese con la creazione di un template wordpress.

Tutto mi funziona tranne che la gestione dei commenti.
Commentando un qualsiasi post, il commento inserito mi appare su ogni singolo post. Di seguito il link del sorgente del mio template

nopaste.info/…

Vi ringrazio in anticipo per il vostro aiuto.
aaa
01/11/12 17:36
XBarboX
Tempo fa avevo fatto un tema wordpress molto minimal. Non mi ricordo nulla ma ti posto il codice. Può tornarti utile:

comments.php
<?php if (!empty($post->post_password) && $_COOKIE['wp-postpass_'.COOKIEHASH]!=$post->post_password) : ?> 
    <p id="comments-locked">Articolo protetto da password</p> 
<?php return; endif; ?> 

<?php if ($comments) : ?> 

<?php  

    /* Author values for author highlighting */ 
    /* Enter your email and name as they appear in the admin options */ 
    $author = array( 
            "highlight" => "highlight", 
            "email" => "YOUR EMAIL HERE", 
            "name" => "YOUR NAME HERE" 
    );  

    /* Count the totals */ 
    $numPingBacks = 0; 
    $numComments  = 0; 

    /* Loop throught comments to count these totals */ 
    foreach ($comments as $comment) { 
        if (get_comment_type() != "comment") { $numPingBacks++; } 
        else { $numComments++; } 
    } 
     
    /* Used to stripe comments */ 
    $thiscomment = 'odd';  
?> 

<?php  
    /* This is a loop for printing comments */ 
    if ($numComments != 0) : ?> 

    <div class="titolo"><?php if($numComments == 1) echo "1 Commento"; else echo $numComments." Commenti";   ?></div> 
    <ol id="comments"> 
     
    <?php foreach ($comments as $comment) : ?> 
    <?php if (get_comment_type()=="comment") : ?> 
     
        <li id="comment-<?php comment_ID(); ?>" class="comment-li"> 
            <div class="comment-meta"> 
                <b><?php comment_author_link() ?></b> il <?php comment_date('l j F Y')?> alle <?php comment_date('G:i')?> scrive:
            </div> 
            <div class="comment-text"> 
                <?php comment_text(); ?> 
            </div> 
        </li> 
         
    <?php if('odd'==$thiscomment) { $thiscomment = 'even'; } else { $thiscomment = 'odd'; } ?> 
     
    <?php endif; endforeach; ?> 
     
    </ol> 
     
    <?php endif; ?> 
     
<?php else :  

    /* No comments at all means a simple message instead */  
?> 

    <div class="titolo">Nessun commento ancora</div> 
     
<?php endif; ?> 

<?php if (comments_open()) : ?> 

    <div id="comments-form"> 
     
    <div class="titolo">Lascia un commento</div> 
     
    <?php if (get_option('comment_registration') && !$user_ID ) : ?> 
        <p>Devi essere <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to= 
        <?php the_permalink(); ?>">collegato</a> per lasciare un commento.</p> 
    <?php else : ?> 

    <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> 

    <?php if ($user_ID) : ?> 
     
    <p>Collegato come<a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"> 
        <?php echo $user_identity; ?></a>.  
        <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout"  
        title="Log out of this account">Logout</a> 
    </p> 
     
    <?php else : ?> 
     
        <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" /> 
        <label for="author">Name<?php if ($req) _e(' (required)'); ?></label></p> 
         
        <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" /> 
        <label for="email">E-mail (will not be published)<?php if ($req) _e(' (required)'); ?></label></p> 
         
        <p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" /> 
        <label for="url">Website</label></p> 
     
    <?php endif; ?> 

        <p><textarea name="comment" id="comment" rows="7" cols="60"></textarea></p> 

        <p><input type="submit" name="submit" id="submit" value="Invia"/> 
        <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>"></p> 
     
    <?php do_action('comment_form', $post->ID); ?> 

    </form>  

<?php endif; // If registration required and not logged in ?> 
</div>

<?php else : // Comments are closed ?> 
    
<?php endif; ?>


poi ad esempio in single.php per richiamare i commenti usa questa riga:
<?php comments_template('/comments.php', true ); ?>


Spero ti torni utile :k:
aaa
01/11/12 18:18
engineer93
Ti ringrazio per la risposta :):) Provo e ti faccio sapere.... Davvero grazie mille
aaa
01/11/12 18:32
engineer93
No c'è sempre lo stesso problema...Il commento fatto sotto un articolo viene comunque visualizzato sotto ogni articolo.A me servirebbe che ogni articolo deve avere i suoi commenti :pat::pat:
aaa
01/11/12 23:59
engineer93
Ho risolto il problema aggiungendo al codice mio [CODE]
<? if(have_posts()): ?>
<? while(have_posts()): ?>
<? the_post() ?>
////CODICE COMMENTI///
<? endwhile; ?>
<? endif; ?>
[/CODE]
In modo che prendesse l'id del post e quindi visualizzare i commenti del post e non tutti.Mi sorge un altro problema.Quando posto, è come se l'azione di altri plugin si neutralizzasse.Ad esempio io ho un plugin per la paginazione degli articoli.Quando inserisco un commento nell articolo mi appare pari pari il codice inserito per impaginare l'articolo cioè [nextpage title"Nome prossima Pagina"].

Come è mai possibile sta cosa??? Grazie in anticipo
aaa
02/11/12 0:10
engineer93
Ho risolto anche questa cosa!!!

In pratica c'era abilitara, in wordpress, la suddivisione dei commenti in pagina.Arrivati tipo a 50 commenti si creava la paginazione che li divideva.Ciò aggiungeva all'estermità del link /comment-page-1/ che dava fastidio ai plugin.Disabilitata questa funzione in Impostazioni ->Discussioni tutto torna a funzionare. :) Grazie Per l'aiuto.Spero di essere d'aiuto per chi avrà lo stesso problema...:D:D:D

E scusate per il posting continuo.
aaa