Tag Info

New answers tagged

0

So you want all comments made by anyone on posts created by the logged in user ? Untested, but try: $args = array( 'author' => get_current_user_id(), 'posts_per_page' => -1 ); $the_query = new WP_Query( $args ); <?php if ( $the_query->have_posts() ) : ?> <?php while ( ...


0

Actually the WP_Comment_Query class supports pretty much everything you want. You might want to use either post_author to fetch the comments or user_id. Both do pretty much the same thing. As you can see, the post_status is publish and only for the post type post. Alter the arguments as you need them. if ( ! is_user_logged_in() ) return print 'Nothing ...


0

Using the @shanebp ideas of using get_comments: $args = array( 'post_author' => get_current_user_id(), // It will use the current logged in use to grab the comments ); $comments = get_comments( $args ); // Referer to http://codex.wordpress.org/Function_Reference/wp_list_comments $list_args = array( 'reverse_top_level' => false // Show the ...


1

Have you tried comment_post action? It's fired right after the comment is inserted into the database. function share_comment_on_facebook( $comment_ID ) { $commentdata = get_comment( $comment_ID ); if ( $commentdata['comment_approved'] ) { // fire up the code to launch pop up } } add_action( 'comment_post', 'share_comment_on_facebook' ); ...


0

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 object. */ ...


0

Login to WordPress dashbord, and choose the right user and select the proper value of 'Display name publicly as' as your wish for every user. If there are a lot of users, simply modify your code from the_author to the_author_meta('first_name'). Here you can change 'first_name' to something else as given in the function reference page.


0

You have to dive into comment template in your theme and find out the line where username is printed. Then use the following function in functions.php: function alter_username( $username ){ return substr( $username, 0, 1 ). str_repeat( '*', strlen( $username ) - 2 ) . substr( $username, strlen( $username ) - 1 ,1 ); } Then use the function in comment ...


0

You will need to use combination of substr and str_repeat PHP functions to achieve this. Although it's very simple. <?php function hide_username( $username ) { $stringlen = strlen( $username ); return substr( $username, 0, 1 ) . str_repeat( '*', $stringlen - 2 ) . substr( $username, $stringlen - 1, 1 ); } $username = ...


0

For anybody having the same problem, the $post variable was overridden inside the post by a related posts section. So either rename the new variable or use wp_reset_postdata() inside the same section. Sorry, only after I posted the question I found this post that provides the answer: Comments are assigned to wrong or related post Only I was using the reset ...


2

There is definitely a performance advantage in keeping your comment spam to a minimum. If you have a lot of comments, the query time can get pretty out of control. To make it easier, you should install Akismet if you haven't already. Akismet will automatically detect spam comments and move them to WordPress spam section. You can then delete all the spam ...


0

If you're wanting your users to be able to add the xml tags into the comment form, without having them removed, it would be best to add a filter to pre_process_comment so as to add <pre> tags around the comment before it's posted to the DB.


2

So after some time I done exactly what I wanted and I thought it would be nice to share. So in functions.php add function c_parent_comment_counter($pid,$uid){ global $wpdb; $query = "SELECT COUNT(comment_post_id) AS count FROM $wpdb->comments WHERE <code>comment_approved</code> = 1 AND <code>comment_post_ID</code> = $pid ...


1

You'd probably have to do this in javascript, but I'm guessing the reason you want to add a class is to style it differently? If so, just use different styles for #respond that is inside a reply container. So perhaps the style would be .comment-replies > #respond or something similar.


1

WordPress runs a service to generate screenshots. You can get any website screenshot like this. http://s.wordpress.com/mshots/v1/http://www.google.com?w=400&h=300 And yes, it records as a hit on website and will be logged.


0

If deactivating all the plugins does not solve the problem it may be a problem with your .htaccess file, especially if you have installed/activated a plugin that deals with comments in any way. You can generate a new basic .htaccess file by: Access your hosting account cpanel and select the File Manager. Delete the .htaccess file in the root directory of ...



Top 50 recent answers are included