WordPress.org

Ready to get started?Download WordPress

Forums

Updating $wp_query inside the Loop (1 post)

  1. admreg
    Member
    Posted 4 years ago #

    Hi everybody,

    I am trying to dynamically add/remove comments before displaying them. In comments.php, I have:

    $comment_id = wp_insert_comment( $commentdata );
    ..........
    /* end of my code */
    
    /*beginning of original theme code*/
    ........
    wp_list_comments();

    The problem is that the newly added comment is not displayed until page refresh. I figure this is because the Loop works with cached comments stored in $wp_query. What is the best way to update the comment cache while keeping all the Loop counters intact? I would like to have a piece of code that can be just pasted into any theme without interfering with its original comment code. Performance is an issue, too.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags