Display comments rather than titles in WordPress articles

Source: Internet
Author: User
Tags comments sprintf

 

First find the wp_regiondes/default-widgets.php under the root directory, find in functionwidget '(about 625th lines)

Run the following code (about 655th lines ):

The code is as follows: Copy code

If ($ comments ){
Foreach (array) $ comments as $ comment ){
$ Output. = '<li class = "recentcomments">'./* translators: comments widget: 1: comment

Author, 2: post link */sprintf (_ x ('% 1 $ s on % 2 $ s', 'widgets'), get_comment_author_link (),

'<A href = "'. esc_url (get_comment_link ($ comment-> comment_ID). '">'. get_the_title

($ Comment-> comment_post_ID). '</a>'). '</li> ';
     }
}

Set

The code is as follows: Copy code

Change get_the_title ($ comment-> comment_post_ID) to strip_tags ($ comment-

> Comment_content ),

At the same time, change the on in sprintf to the text you want to display, such as "say", so that the style becomes

"Comments" say "comment content" Below is the modified code (note: back up the code before modification)

The code is as follows: Copy code

If ($ comments ){
Foreach (array) $ comments as $ comment ){
$ Output. = '<li class = "recentcomments">'./* translators: comments widget: 1: comment

Author, 2: post link */sprintf (_ x ('% 1 $ s said: % 2 $ s', 'widgets'), get_comment_author_link

(), '<A href = "'. esc_url (get_comment_link ($ comment-> comment_ID). '">'. strip_tags

($ Comment-> comment_content). '</a>'). '</li> ';
     }
}

In fact, this $ output is the output html code, so you can modify it based on your own needs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.