I am not sure. I used the code you suggested in functions.php, and then I
edited the comments.php template so it checks the post type - see the
bolded portion. The field data was showing before, but now it is not.
<?php
/**
* Use Bootstrap's media object for listing comments
*
* @link http://twitter.github.com/bootstrap/components.html#media
*/
class Roots_Walker_Comment extends Walker_Comment {
function start_lvl(&$output, $depth = 0, $args = array()) {
$GLOBALS['comment_depth'] = $depth + 1; ?>
<ul <?php comment_class('media unstyled comment-' . get_comment_ID());
?>>
<?php
}
function end_lvl(&$output, $depth = 0, $args = array()) {
$GLOBALS['comment_depth'] = $depth + 1;
echo '</ul>';
}
function start_el(&$output, $comment, $depth = 0, $args = array(), $id =
0) {
$depth++;
$GLOBALS['comment_depth'] = $depth;
$GLOBALS['comment'] = $comment;
if (!empty($args['callback'])) {
call_user_func($args['callback'], $comment, $args, $depth);
return;
}
extract($args, EXTR_SKIP); ?>
<li id="comment-<?php comment_ID(); ?>" <?php comment_class('media
comment-' . get_comment_ID()); ?>>
* <?php if (get_post_type() == 'profile') { *
* include(locate_template('templates/comment-profile.php')); } else {*
* include(locate_template('templates/comment.php')); } ?>*
}
<?php
}
function end_el(&$output, $comment, $depth = 0, $args = array()) {
if (!empty($args['end-callback'])) {
call_user_func($args['end-callback'], $comment, $args, $depth);
return;
}
echo "</div></li>\n";
}
}
function roots_get_avatar($avatar) {
$avatar = str_replace("class='avatar", "class='avatar pull-left
media-object", $avatar);
return $avatar;
}
add_filter('get_avatar', 'roots_get_avatar');
Post by J.D. GrimesYes. That means it must be using its own version of the comment_form()
function. Maybe it has similar hooks?
Post by Gregory Lancasterawesome! Thats exactly what I needed. Apparently with this framework the
comments.php isnt affected by the add_comment_fields, I have to add it
manually. Since thats the case, I can skip the function right?
Post by J.D. Grimescomment_form_logged_in_after
function add_comment_fields( $fields ) {
?>
<p class="comment-form-age">
<label for="age"><?php _e( 'Age' ); ?></label>
<input id="age" name="age" type="text" size="30" />
</p>
<?php
}
add_filter( 'comment_form_logged_in_after', 'add_comment_fields' );
That will display to logged in users only. Just echo out the form input.
The saving should work the same as before, I think.
Post by J.D. Grimes// Default comment form elements are hidden when user is logged in
So, if you want them to show even when the user is logged in, you will
have to use a different hook. I don't know any off of the top of my
head...
Post by Gregory LancasterPost by J.D. GrimesPost by J.D. GrimesOn Oct 7, 2013, at 3:01 PM, Gregory Lancaster <
I got it :)
I followed the smashing guide, and no fields showed up. So I tried
just
Post by Gregory LancasterPost by J.D. GrimesPost by J.D. Grimescopy pasting their example code and that didnt work either. Is there
function add_comment_fields($fields) {
$fields['age'] = '<p class="comment-form-age"><label for="age">' .
__(
Post by Gregory LancasterPost by J.D. GrimesPost by J.D. Grimes'Age' ) . '</label>' .
'<input id="age" name="age" type="text" size="30" /></p>';
return $fields;
}
add_filter('comment_form_default_fields','add_comment_fields');
function add_comment_meta_values($comment_id) {
if(isset($_POST['age'])) {
$age = wp_filter_nohtml_kses($_POST['age']);
add_comment_meta($comment_id, 'age', $age, false);
}
}
add_action ('comment_post', 'add_comment_meta_values', 1);
Post by J.D. GrimesI tried to send a reply to that earlier, but I don't think it went
through
Post by J.D. GrimesPost by J.D. Grimes- I just resent it now, let me know if you get it.
On Oct 7, 2013, at 2:54 PM, Gregory Lancaster <
Post by Gregory LancasterI was going to (i am tryign to code the plugin I emailed you about
myself
Post by J.D. GrimesPost by J.D. GrimesPost by Gregory Lancastertoday, I have all day :) ) but the is_post_type was depreciated.
Not
Post by J.D. GrimesPost by J.D. GrimesPost by Gregory Lancastersure what to use now.
Post by Chris McCoyI would check for the post type, if its the one you wish to add to
do
to
http://wordpress-hackers.1065353.n5.nabble.com/adding-custom-fields-to-a-c
Nabble.com.
Post by Gregory LancasterPost by J.D. GrimesPost by J.D. GrimesPost by J.D. GrimesPost by Gregory LancasterPost by Chris McCoyPost by BenderisGreat_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers