Hello Knepveu,
As per your query, you want to separate “Leave a comment” from post meta. Show “Leave a comment” in the top and bottom of post on blog post listing (home or archieve page).
Let me know if this is what you needed.
Copy the following code in your functions.php file and check the output.
// Remove Default Post Meta
remove_action( 'rtp_hook_post_meta_top', 'rtp_default_post_meta' ); // Remove Post Meta Top
remove_action( 'rtp_hook_post_meta_bottom', 'rtp_default_post_meta' ); // Remove Post Meta Bottom
function rtp_custom_post_meta( $placement = 'top' ) {
if ( 'post' == get_post_type() && ! rtp_is_bbPress() ) {
global $post, $rtp_post_comments;
$position = ( 'bottom' == $placement ) ? 'l' : 'u'; // l = Lower/Bottom , u = Upper/Top
if ( rtp_has_postmeta( $position ) ) {
if ( $position == 'l' ) {
echo '';
} ?>
<?php
if ( 'bottom' == $placement ){
rtp_hook_begin_post_meta_bottom();
} else {
rtp_hook_begin_post_meta_top();
}
// Author Link
if ( $rtp_post_comments[ 'post_author_' . $position ] || $rtp_post_comments[ 'post_date_' . $position ] ) {
if ( $rtp_post_comments[ 'post_author_' . $position ] ) {
printf( __( '
By %s', 'rtPanel' ), ( ! $rtp_post_comments[ 'author_link_' . $position ] ? get_the_author() . ( $rtp_post_comments[ 'author_count_' . $position ] ? '(' . get_the_author_posts() . ')' : '' ) : sprintf( __( '
%3$s', 'rtPanel' ), get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ), esc_attr( sprintf( __( 'Posts by %s', 'rtPanel' ), get_the_author() ) ), get_the_author() ) . ( $rtp_post_comments[ 'author_count_' . $position ] ? '(' . get_the_author_posts() . ')' : '' ) ) );
}
echo ( $rtp_post_comments[ 'post_author_' . $position ] && $rtp_post_comments[ 'post_date_' . $position ] ) ? ' ' : '';
if ( $rtp_post_comments[ 'post_date_' . $position ] ) {
printf( __( '
· %s', 'rtPanel' ), get_the_date( 'c' ), get_the_time( $rtp_post_comments[ 'post_date_format_' . $position ] ) );
}
}
// Post Categories
echo ( get_the_category_list() && $rtp_post_comments[ 'post_category_' . $position ] ) ? '
· ' . get_the_category_list( ', ' ) . '' : '';
// Post Tags
echo ( get_the_tag_list() && $rtp_post_comments[ 'post_tags_' . $position ] ) ? '
' . get_the_tag_list( __( 'Tagged', 'rtPanel' ) . ': ', ', ', '' ) . '
' : '';
// Post Custom Taxonomies
$args = array( '_builtin' => false );
$taxonomies = get_taxonomies( $args, 'objects' );
foreach ( $taxonomies as $key => $taxonomy ) {
( get_the_terms( $post->ID, $key ) && isset( $rtp_post_comments[ 'post_' . $key . '_' . $position ] ) && $rtp_post_comments[ 'post_' . $key . '_' . $position ] ) ? the_terms( $post->ID, $key, '
' . $taxonomy->labels->singular_name . ': ', ', ', '' ) : '';
}
if ( 'bottom' == $placement )
rtp_hook_end_post_meta_bottom();
else
rtp_hook_end_post_meta_top();
?>
<?php
if ( $position == 'l' ) {
echo '';
}
}
} elseif ( ! rtp_is_bbPress() ) {
if ( get_edit_post_link() && ( 'top' == $placement ) ) {
?>
<?php rtp_hook_end_post_meta_top(); ?>
<?php
}
}
}
// Add new custom post meta
add_action( 'rtp_hook_post_meta_top', 'rtp_custom_post_meta' ); // Post Meta Top
add_action( 'rtp_hook_post_meta_bottom', 'rtp_custom_post_meta' ); // Post Meta Bottom
// Get comment count
function rtp_custom_comment_count() {
global $rtp_post_comments;
add_filter( 'get_comments_number', 'rtp_only_comment_count', 11, 2 );
if ( ( is_archive() || is_home() || is_front_page() ) && ( ( ( get_comments_number() || @comments_open() ) && ! is_attachment() && ! rtp_is_bbPress() ) ) ) { // If post meta is set to top then only display the comment count. ?>
<?php comments_popup_link( _x( 'Leave a comment', 'comments number', 'rtPanel' ), _x( '1 Comment', 'comments number', 'rtPanel' ), _x( '% Comments', 'comments number', 'rtPanel' ), 'rtp-post-comment rtp-common-link' ); ?><?php
}
remove_filter( 'get_comments_number', 'rtp_only_comment_count', 11, 2 );
}
add_action( 'rtp_hook_post_meta_top', 'rtp_custom_comment_count' );
add_action( 'rtp_hook_post_meta_bottom', 'rtp_custom_comment_count' );