Saturday, March 7, 2015

listing customized comments in wordpress

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp list comments

Description

Displays all comments for a post or Page based on a variety of parameters including ones set in the administration area.

Usage

 <?php wp_list_comments$args$comments ); ?> 

Default Usage

$args
(array) (optional) The options for the function.
Default:
<?php $args = array(
 'walker'            => null,
 'max_depth'         => '',
 'style'             => 'ul',
 'callback'          => null,
 'end-callback'      => null,
 'type'              => 'all',
 'reply_text'        => 'Reply',
 'page'              => '',
 'per_page'          => '',
 'avatar_size'       => 32,
 'reverse_top_level' => null,
 'reverse_children'  => '',
 'format'            => 'html5', //or xhtml if no HTML5 theme support
 'short_ping'        => false // @since 3.6,
        'echo'     => true // boolean, default is true
); ?>
max_depthper_page, and reverse_top_level can be more easily controlled through the Administration Panel Discussion Settingsbut a theme can override those settings here.
$comments
(array) (optional) Array obtained by get_comments query.
Default: The default return of get_comments.

Arguments

'walker' 
Walker object ) Provide a custom Walker class object to use when rendering the comments. This is the primary method of customizing comment HTML.
<?php
wp_list_comments( array(
    'walker' => new Walker_Comment()
) );
'max_depth' 
integer ) How deep (in comment replies) should the comments be fetched.
'style' 
string ) Can be either 'div', 'ol', or 'ul' (the default). Note that any containing tags that must be written explicitly. For instance:
<div class="comment list">
    <?php wp_list_comments( array( 'style' => 'div' ) ); ?>
</div>
OR
<ol class="comment list">
    <?php wp_list_comments( array( 'style' => 'ol' ) ); ?>
</ol>
'callback' 
callback ) The name of a custom function to use to open and display each comment. Using this will make your custom function get called to display each comment, bypassing all internal WordPress functionality in this respect. Use to customize comments display for extreme changes to the HTML layout. Note that your callback must include the opening <div><ol>, or <ul> tag (corresponding with the style parameter), but not the closing tags. WordPress will supply the closing tag automatically, or you can use end-callback to override this default. The callback is separate from the end-callback to facilitate hierarchical comments. Use with caution.
'end-callback' 
callback ) The name of a custom function to use to close each comment. Using this will make your custom function get called to at the end of each comment, bypassing the WordPress default of using </div></ol>, or </li> based on the style parameter. Use to customize the ending tags for a comment. The callback is separate from the end-callback to facilitate hierarchical comments. Use with caution.
'type' 
string ) The type of comment(s) to display. Can be 'all''comment''trackback''pingback', or 'pings''pings' is both 'trackback' and 'ping back' together.
'reply_text' 
string ) Text to display in each comment as a reply link. (This isn't an argument of this function but it gets passed to the get_comment_reply_link function.)
'page' 
integer ) The current page in the pagination to display.
'per_page' 
integer ) The number of items to show for each page of comments.
'avatar_size' 
integer ) Size that the avatar should be shown as, in pixels. http://gravatar.com/ supports sizes between 1 and 512. Use 0 to hide avatars.
'reverse_top_level' 
boolean ) Setting this to true will display the most recent comment first then going back in order.
'reverse_children' 
boolean ) Setting this to true will display the children (reply level comments) with the most recent ones first, then going back in order.
'format' 
boolean ) This can be set to 'html5' or 'xhtml' - it defaults to your theme's current_theme_supports( 'html5' ) setting.
'short_ping' 
boolean ) Whether you want to use a short ping.
'echo' 
boolean ) Whether to echo the list or just return it.

Examples

Default Usage

Outputs an ordered list of the comments. Things like threading or paging being enabled or disabled are controlled via the Settings Discussion SubPanel.
<ol class="commentlist">
<?php wp_list_comments(); ?>
</ol>

Comments Only With A Custom Comment Display

Displays just comments (no pingbacks or trackbacks) while using a custom callback function to control the look of the comment. You may want to add a max_depth=X parameter, if the reply links are not appearing.
<ul class="commentlist">
<?php wp_list_comments( 'type=comment&callback=mytheme_comment' ); ?>
</ul>
You will need to define your custom callback function in your theme's functions.php file. Here is an example:
function mytheme_comment($comment, $args, $depth) {
 $GLOBALS['comment'] = $comment;
 extract($args, EXTR_SKIP);

 if ( 'div' == $args['style'] ) {
  $tag = 'div';
  $add_below = 'comment';
 } else {
  $tag = 'li';
  $add_below = 'div-comment';
 }
?>
 <<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
 <?php if ( 'div' != $args['style'] ) : ?>
 <div id="div-comment-<?php comment_ID() ?>" class="comment-body">
 <?php endif; ?>
 <div class="comment-author vcard">
 <?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
 <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?>
 </div>
 <?php if ( $comment->comment_approved == '0' ) : ?>
  <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>
  <br />
 <?php endif; ?>

 <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
  <?php
   /* translators: 1: date, 2: time */
   printf( __('%1$s at %2$s'), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), '  ', '' );
  ?>
 </div>

 <?php comment_text(); ?>

 <div class="reply">
 <?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
 </div>
 <?php if ( 'div' != $args['style'] ) : ?>
 </div>
 <?php endif; ?>
<?php
}
Note the lack of a trailing </li>. In order to accommodate nested replies, WordPress will add the appropriate closing tag after listing any child elements.

Display Comments for a Specific Page/Post

Outputs an ordered list of comments for a specific page or post. Things like threading or paging being enabled or disabled are controlled via the Settings Discussion SubPanel.
<ol class="commentlist">
 <?php
  //Gather comments for a specific page/post 
  $comments = get_comments(array(
   'post_id' => XXX,
   'status' => 'approve' //Change this to the type of comments to be displayed
  ));

  //Display the list of comments
  wp_list_comments(array(
   'per_page' => 10, //Allow comment pagination
   'reverse_top_level' => false //Show the latest comments at the top of the list
  ), $comments);
 ?>
</ol>

Change Log

Since: 2.7.0

Source File

wp_list_comments() is located in wp-includes/comment-template.php.

Related

Comments Functions

List & Dropdown Functions

See also index of Function Reference and index of Template Tags.

Customizing comment form in wordpress

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/comment form

This page is marked as incomplete. You can help Codex by expanding it.

Description

This tag outputs a complete commenting form for use within a template.
Most strings and form fields may be controlled through the $args array passed into the function, while you may also choose to use the comment_form_default_fields filter to modify the array of default fields if you'd just like to add a new one or remove a single field. All fields are also individually passed through a filter of the form comment_form_field_$name where $name is the key used in the array of fields.
Please note, that although most parameters are marked as optional, not including them all in your code will produce errors when using define('WP_DEBUG', true);

Usage

<?php comment_form$args$post_id ); ?>

Default Usage

<?php comment_form(); ?>
twentytendefault6.png
As seen in the popular twentyten theme - called here: wp-content/themes/twentyten/comments.php

Parameters

args
(array) (optional) Options for strings, fields etc in the form.
Default: (See below)
post_id
(mixed) (optional) Post ID to generate the form for, uses the current post if null
Default: null (the current post)

$args

Note: If you change the $defaults in your comments template using $new_defaults, you must declare the $new_defaults BEFORE you call comment_form($new_defaults);, otherwise, they won't take effect.
Default values:
fields
(array) (optional) Input fields: 'author', 'email', 'url'.
Default: apply_filters( 'comment_form_default_fields', $fields )
comment_field
(string) (optional) The textarea and the label of comment body.
Default:
'<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>'
must_log_in
(string) (optional)
Default:
'<p class="must-log-in">' .  sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>'
logged_in_as
(string) (optional)
Default:
'<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>'
comment_notes_before
(string) (optional) Text or HTML to be displayed before the set of comment form fields if the user is not logged in.
Default:
'<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>'
comment_notes_after
(string) (optional) Text or HTML to be displayed after the set of comment fields (and before the submit button)
Default:
'<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>'
id_form
(string) (optional) value of the id attribute of form element (<form> tag).
Default: 'commentform'
id_submit
(string) (optional) value of the id attribute of submit button.
Default: 'submit'
class_submit
(string) (optional) value of the class attribute of submit button.
Default: 'submit'
title_reply
(string) (optional) The title of comment form (when not replying to a comment, see comment_form_title).
Default: __( 'Leave a Reply' )
title_reply_to
(string) (optional) The title of comment form (when replying to a comment, see comment_form_title).
Default: __( 'Leave a Reply to %s' )
cancel_reply_link
(string) (optional) link label to cancel reply.
Default: __( 'Cancel reply' )
label_submit
(string) (optional) the name of submit button.
Default: __( 'Post Comment' )

$fields

Default form fields:
$fields =  array(

  'author' =>
    '<p class="comment-form-author"><label for="author">' . __( 'Name', 'domainreference' ) . '</label> ' .
    ( $req ? '<span class="required">*</span>' : '' ) .
    '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) .
    '" size="30"' . $aria_req . ' /></p>',

  'email' =>
    '<p class="comment-form-email"><label for="email">' . __( 'Email', 'domainreference' ) . '</label> ' .
    ( $req ? '<span class="required">*</span>' : '' ) .
    '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) .
    '" size="30"' . $aria_req . ' /></p>',

  'url' =>
    '<p class="comment-form-url"><label for="url">' . __( 'Website', 'domainreference' ) . '</label>' .
    '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) .
    '" size="30" /></p>',
);
Note: To use the variables present in the above code in a custom callback function, you must first set these variables within your callback using:
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );

Default $args array

$args = array(
  'id_form'           => 'commentform',
  'id_submit'         => 'submit',
  'class_submit'      => 'submit',
  'name_submit'       => 'submit',
  'title_reply'       => __( 'Leave a Reply' ),
  'title_reply_to'    => __( 'Leave a Reply to %s' ),
  'cancel_reply_link' => __( 'Cancel Reply' ),
  'label_submit'      => __( 'Post Comment' ),
  'format'            => 'xhtml',

  'comment_field' =>  '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) .
    '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true">' .
    '</textarea></p>',

  'must_log_in' => '<p class="must-log-in">' .
    sprintf(
      __( 'You must be <a href="%s">logged in</a> to post a comment.' ),
      wp_login_url( apply_filters( 'the_permalink', get_permalink() ) )
    ) . '</p>',

  'logged_in_as' => '<p class="logged-in-as">' .
    sprintf(
    __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ),
      admin_url( 'profile.php' ),
      $user_identity,
      wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) )
    ) . '</p>',

  'comment_notes_before' => '<p class="comment-notes">' .
    __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) .
    '</p>',

  'comment_notes_after' => '<p class="form-allowed-tags">' .
    sprintf(
      __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ),
      ' <code>' . allowed_tags() . '</code>'
    ) . '</p>',

  'fields' => apply_filters( 'comment_form_default_fields', $fields ),
);

Return

void

Examples

Simple example how to change some comment form fields.
$comments_args = array(
        // change the title of send button 
        'label_submit'=>'Send',
        // change the title of the reply section
        'title_reply'=>'Write a Reply or Comment',
        // remove "Text or HTML to be displayed after the set of comment fields"
        'comment_notes_after' => '',
        // redefine your own textarea (the comment body)
        'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><br /><textarea id="comment" name="comment" aria-required="true"></textarea></p>',
);

comment_form($comments_args);

Uses filter hooks

Pluggable actions

Changelog

Source Code

comment_form() is located in wp-includes/comment-template.php.

Related

Comments Functions

See also index of Function Reference and index of Template Tags.

Sunday, February 15, 2015

SEO using weebly and google webmaster tool + useful info

http://hc.weebly.com/hc/en-us/articles/201723433-Verify-Your-Site-with-Search-Engines

https://support.google.com/webmasters/answer/1050724?hl=en

https://support.google.com/webmasters/answer/35769#3

https://www.youtube.com/watch?v=kDfw4yt554g

Tips for SEO
http://moz.com/beginners-guide-to-seo/keyword-research

Google local business page for free like facebook business page
https://www.google.com/business/

http://thenextweb.com/dd/2015/02/18/300-awesome-free-things-massive-list-free-resources-know/?awesm=tnw.to_q3MrX&utm_medium=referral&utm_source=t.co&utm_campaign=share%20button&utm_content=300%20awesome%20free%20things:%20A%20massive%20list%20of%20free%20resources%20you%20should%20know


wordpress SEO tutorial
https://www.youtube.com/watch?v=G8o8u7OtuZY

plugin for seo :
google analytics
sitemap xml seo friendly image plugin
website cache plugin
google author relative tag plugin
wp socializer plugin
update ping list 2013 - when new content is published it will automatically be indexed in google ,yahoo etc


Tutorial for developing own wordpress theme
https://www.youtube.com/watch?v=k7olvEeBM2I

Develop wordpress website using html template and blank wordpress theme

https://www.youtube.com/watch?v=bvAKY8sQpRA&list=PLapGz-KdoBpzrZ5YYaELvo5aD6MyfXan0

http://html5blank.com/

How to import windows image into virtual box

Steps:

- Download virtual box from https://www.virtualbox.org/wiki/Downloads and install it double clicking it after the download.
- Open the application and go to file menu and import appliance and set the path to your image file of the operating system