Redirect first time comments

Since the comment form is generated before the comment is submitted that won’t work too well logically. The better option is comment_post_redirect filter: /** * Filter the location URI to send the commenter after posting. * * @since 2.0.5 * * @param string $location The ‘redirect_to’ URI sent via $_POST. * @param object $comment Comment … Read more

How Can I display the Current Logged-In User’s Comment at the Top of the Comments Section in WordPress?

Alright, I figured it out. Thanks for all the direction everyone! <?php global $current_user,$post; $args = array(‘user_id’ => $current_user->ID,’post_id’ => $post->ID); // The Query $comments_query = new WP_Comment_Query; $comments = $comments_query->query( $args ); // Comment Loop if ( $comments ) { foreach ( $comments as $comment ) { echo ‘<p>’ . $comment->comment_content . ‘</p>’; } … Read more

Change the “Allow comments” text for admin edit screen for custom post type?

You can fire filter hook gettext ( example available too ) to change default text Allow comments. in admin edit screen. Here another sample function: add_filter( ‘gettext’,’wpse221235_change_admin_cpt_text_filter’, 1, 3 ); function wpse221235_change_admin_cpt_text_filter( $translated_text, $text, $domain ) { global $typenow; if ( is_admin() && ‘Allow comments.’ == $text && ‘your-post-type’ == $typenow ) $translated_text = __( … Read more

How can I return the result of my custom function?

Seems pretty much simple: add_filter( ‘get_comment_author_link’, ‘attach_city_to_author’ ); function attach_city_to_author( $author ) { $city = get_comment_meta( get_comment_ID(), ‘city’, true ); if ( $city ) $author = $city; return $author; } Unless if you are adding the city name somewhere else and wanted to remove comment author name then call add_filter(‘get_comment_author’, ‘__return_false’); Hope that helps.

How to get related posts and wp comments under tabs

You need to use do_shortcode() for the shortcode to actually work inside PHP function add_post_content($content) { if(!is_feed() && !is_home()) { $above=”<p></p>”; $content_of_first_tab = ‘A list of related posts ‘; $args= array( ‘number’ => ‘5’, ‘post_id’ => get_the_ID(), // use post_id, not post_ID. ); $comments = get_comments( $args ); $output=””; foreach ( $comments as $comment ) … Read more