-
Author
-
October 13, 2015 at 15:59 #82048MatthiasParticipant
Hi,
I use Post Views Counter to display how many times a post has been seen, using the shortcode [post-views].
How can I display this in the post meta in Kleo post’s Visual composer element ? I’d like to have this next to the number of comments and author name (see attached)
Thanks for your help
Attachments:
You must be logged in to view attached files.October 13, 2015 at 19:29 #82112RaduModeratorHi,
Can you please provide FTP and admin credentials ?
Regards
Radu
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionOctober 14, 2015 at 18:13 #82248RaduModeratorHi,
I’ve tried to connect to ftp but unsuccessful,
I’ve added a function to kleo-child/functions.php via admin pannel, now i’m not able to view site/dashboard i see that you have renamed the theme directory from kleo to kleo–
Anyways just put this code to your kleo-child/style.css
COPY CODEif ( ! function_exists( 'kleo_entry_meta' ) ) : /** * Prints HTML with meta information for current post: categories, tags, permalink, author, and date. * Create your own kleo_entry_meta() to override in a child theme. * @since 1.0 */ function kleo_entry_meta( $echo = true, $att = array() ) { global $kleo_config; $meta_list = array(); $author_links = ''; $meta_elements = sq_option( 'blog_meta_elements', $kleo_config['blog_meta_defaults'] ); // Translators: used between list items, there is a space after the comma. if ( in_array( 'categories', $meta_elements ) ) { $categories_list = get_the_category_list(__(', ', 'kleo_framework')); } // Translators: used between list items, there is a space after the comma. if ( in_array('tags', $meta_elements ) ) { $tag_list = get_the_tag_list('', __(', ', 'kleo_framework')); } $date = sprintf( '<a href="%1$s" rel="bookmark" class="post-time">' . '<time class="entry-date" datetime="%2$s">%3$s</time>' . '<time class="modify-date hide hidden updated" datetime="%4$s">%5$s</time>' . '</a>', esc_url( get_permalink() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_html( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); if ( is_array( $meta_elements ) && !empty( $meta_elements ) ) { if ( in_array( 'author_link', $meta_elements ) || in_array( 'avatar', $meta_elements ) ) { /* If buddypress is active then create a link to Buddypress profile instead */ if (function_exists( 'bp_is_active' ) ) { $author_link = esc_url( bp_core_get_userlink( get_the_author_meta( 'ID' ), $no_anchor = false, $just_link = true ) ); $author_title = esc_attr( sprintf( __( 'View %s\'s profile', 'kleo_framework' ), get_the_author() ) ); } else { $author_link = esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); $author_title = esc_attr( sprintf( __( 'View all POSTS by %s', 'kleo_framework' ), get_the_author() ) ); } $author = sprintf( '<a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s %4$s</a>', $author_link, $author_title, in_array( 'avatar', $meta_elements ) ? get_avatar( get_the_author_meta( 'ID' ), 50) : '', in_array( 'author_link', $meta_elements ) ? '<span class="author-name">' . get_the_author() . '</span>' : '' ); $meta_list[] = '<small class="meta-author author vcard">' . $author . '</small>'; } if ( function_exists( 'bp_is_active' ) ) { if ( in_array( 'profile', $meta_elements ) ) { $author_links .= '<a href="' . bp_core_get_userlink( get_the_author_meta( 'ID' ), $no_anchor = false, $just_link = true ) . '">' . '<i class="icon-user-1 hover-tip" ' . 'data-original-title="' . esc_attr(sprintf(__('View profile', 'kleo_framework'), get_the_author())) . '"' . 'data-toggle="tooltip"' . 'data-placement="top"></i>' . '</a>'; } if ( bp_is_active( 'messages' ) ) { if ( in_array( 'message', $meta_elements ) ) { $author_links .= '<a href="' . wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( get_the_author_meta( 'ID' ) ) ) . '">' . '<i class="icon-mail hover-tip" ' . 'data-original-title="' . esc_attr(sprintf(__('Contact %s', 'kleo_framework'), get_the_author())) . '" ' . 'data-toggle="tooltip" ' . 'data-placement="top"></i>' . '</a>'; } } } if ( in_array( 'archive', $meta_elements ) ) { $author_links .= '<a href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . '<i class="icon-docs hover-tip" ' . 'data-original-title="' . esc_attr(sprintf(__('View all posts by %s', 'kleo_framework'), get_the_author())) . '" ' . 'data-toggle="tooltip" ' . 'data-placement="top"></i>' . '</a>'; } } if ( $author_links != '' ) { $meta_list[] = '<small class="meta-links">' . $author_links . '</small>'; } if (in_array( 'date', $meta_elements ) ) { $meta_list[] = '<small>' . $date . '</small>'; } $cat_tag = array(); if ( isset( $categories_list ) && $categories_list ) { $cat_tag[] = $categories_list; } if ( isset( $tag_list ) && $tag_list ) { $cat_tag[] = $tag_list; } if (!empty($cat_tag)) { $meta_list[] = '<small class="meta-category">'.implode(", ",$cat_tag).'</small>'; } //comments if ((!isset($att['comments']) || (isset($att['comments']) && $att['comments'] !== false)) && in_array( 'comments', $meta_elements )) { $meta_list[] = '<small class="meta-comment-count"><a href="'. get_permalink().'#comments">'.get_comments_number() . ' <i class="icon-chat-1 hover-tip" ' . 'data-original-title="'.sprintf( _n( 'This article has one comment', 'This article has %1$s comments', get_comments_number(), 'kleo_framework' ),number_format_i18n( get_comments_number() ) ).'" ' . 'data-toggle="tooltip" ' . 'data-placement="top"></i>' . '</a></small>'; } $meta_separator = isset( $att['separator'] ) ? $att['separator'] : sq_option( 'blog_meta_sep', ', ') ; if ( $echo ) { echo implode( $meta_separator, $meta_list ); } else { return implode( $meta_separator, $meta_list ); } // Add third plugin to show post view echo do_shortcode('[post-views]'); } endif;
Regards
Radu
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionOctober 14, 2015 at 18:13 #82249RaduModeratorHi,
I’ve tried to connect to ftp but unsuccessful,
I’ve added a function to kleo-child/functions.php via admin pannel, now i’m not able to view site/dashboard i see that you have renamed the theme directory from kleo to kleo–
Anyways just put this code to your kleo-child/style.css
COPY CODEif ( ! function_exists( 'kleo_entry_meta' ) ) : /** * Prints HTML with meta information for current post: categories, tags, permalink, author, and date. * Create your own kleo_entry_meta() to override in a child theme. * @since 1.0 */ function kleo_entry_meta( $echo = true, $att = array() ) { global $kleo_config; $meta_list = array(); $author_links = ''; $meta_elements = sq_option( 'blog_meta_elements', $kleo_config['blog_meta_defaults'] ); // Translators: used between list items, there is a space after the comma. if ( in_array( 'categories', $meta_elements ) ) { $categories_list = get_the_category_list(__(', ', 'kleo_framework')); } // Translators: used between list items, there is a space after the comma. if ( in_array('tags', $meta_elements ) ) { $tag_list = get_the_tag_list('', __(', ', 'kleo_framework')); } $date = sprintf( '<a href="%1$s" rel="bookmark" class="post-time">' . '<time class="entry-date" datetime="%2$s">%3$s</time>' . '<time class="modify-date hide hidden updated" datetime="%4$s">%5$s</time>' . '</a>', esc_url( get_permalink() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_html( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); if ( is_array( $meta_elements ) && !empty( $meta_elements ) ) { if ( in_array( 'author_link', $meta_elements ) || in_array( 'avatar', $meta_elements ) ) { /* If buddypress is active then create a link to Buddypress profile instead */ if (function_exists( 'bp_is_active' ) ) { $author_link = esc_url( bp_core_get_userlink( get_the_author_meta( 'ID' ), $no_anchor = false, $just_link = true ) ); $author_title = esc_attr( sprintf( __( 'View %s\'s profile', 'kleo_framework' ), get_the_author() ) ); } else { $author_link = esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); $author_title = esc_attr( sprintf( __( 'View all POSTS by %s', 'kleo_framework' ), get_the_author() ) ); } $author = sprintf( '<a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s %4$s</a>', $author_link, $author_title, in_array( 'avatar', $meta_elements ) ? get_avatar( get_the_author_meta( 'ID' ), 50) : '', in_array( 'author_link', $meta_elements ) ? '<span class="author-name">' . get_the_author() . '</span>' : '' ); $meta_list[] = '<small class="meta-author author vcard">' . $author . '</small>'; } if ( function_exists( 'bp_is_active' ) ) { if ( in_array( 'profile', $meta_elements ) ) { $author_links .= '<a href="' . bp_core_get_userlink( get_the_author_meta( 'ID' ), $no_anchor = false, $just_link = true ) . '">' . '<i class="icon-user-1 hover-tip" ' . 'data-original-title="' . esc_attr(sprintf(__('View profile', 'kleo_framework'), get_the_author())) . '"' . 'data-toggle="tooltip"' . 'data-placement="top"></i>' . '</a>'; } if ( bp_is_active( 'messages' ) ) { if ( in_array( 'message', $meta_elements ) ) { $author_links .= '<a href="' . wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( get_the_author_meta( 'ID' ) ) ) . '">' . '<i class="icon-mail hover-tip" ' . 'data-original-title="' . esc_attr(sprintf(__('Contact %s', 'kleo_framework'), get_the_author())) . '" ' . 'data-toggle="tooltip" ' . 'data-placement="top"></i>' . '</a>'; } } } if ( in_array( 'archive', $meta_elements ) ) { $author_links .= '<a href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . '<i class="icon-docs hover-tip" ' . 'data-original-title="' . esc_attr(sprintf(__('View all posts by %s', 'kleo_framework'), get_the_author())) . '" ' . 'data-toggle="tooltip" ' . 'data-placement="top"></i>' . '</a>'; } } if ( $author_links != '' ) { $meta_list[] = '<small class="meta-links">' . $author_links . '</small>'; } if (in_array( 'date', $meta_elements ) ) { $meta_list[] = '<small>' . $date . '</small>'; } $cat_tag = array(); if ( isset( $categories_list ) && $categories_list ) { $cat_tag[] = $categories_list; } if ( isset( $tag_list ) && $tag_list ) { $cat_tag[] = $tag_list; } if (!empty($cat_tag)) { $meta_list[] = '<small class="meta-category">'.implode(", ",$cat_tag).'</small>'; } //comments if ((!isset($att['comments']) || (isset($att['comments']) && $att['comments'] !== false)) && in_array( 'comments', $meta_elements )) { $meta_list[] = '<small class="meta-comment-count"><a href="'. get_permalink().'#comments">'.get_comments_number() . ' <i class="icon-chat-1 hover-tip" ' . 'data-original-title="'.sprintf( _n( 'This article has one comment', 'This article has %1$s comments', get_comments_number(), 'kleo_framework' ),number_format_i18n( get_comments_number() ) ).'" ' . 'data-toggle="tooltip" ' . 'data-placement="top"></i>' . '</a></small>'; } $meta_separator = isset( $att['separator'] ) ? $att['separator'] : sq_option( 'blog_meta_sep', ', ') ; if ( $echo ) { echo implode( $meta_separator, $meta_list ); } else { return implode( $meta_separator, $meta_list ); } // Add third plugin to show post view echo do_shortcode('[post-views]'); } endif;
Regards
Radu
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionOctober 14, 2015 at 18:17 #82251MatthiasParticipantHi,
I’m having a big issue right now. I updated to kleo 3.0.10 but most of my post pictures were missing so I wanted to go back to my previous version. I had a backup so I copied the whole Kleo folder from the backup and pasted it via ftp to the theme folder. I don’t know how to fix this could you help me ???
October 14, 2015 at 18:20 #82253MatthiasParticipantI can’t login I think I’ve been locked out. Can you please login and turn on maintenance mode ??
October 15, 2015 at 16:13 #82382RaduModeratorHi,
I see that your website it works ok,
I’ve added the snippet provided above again in functions and it works correctly with no problems.
Maybe that can be caused by the cache plugin / your hosting or something like this.
Cheers
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionOctober 20, 2015 at 16:04 #83363MatthiasParticipantHi,
Everything works fine, thanks for your code !
How can I hide the echo do_shortcode(‘[post-views]’); for my custom post type “blog” ?Thanks
October 20, 2015 at 16:15 #83366MatthiasParticipantI found an answer, I used if ( ‘post’ == get_post_type() )
October 21, 2015 at 17:44 #83554RaduModeratorHi,
I’m glad if you have figure out.
Best Regards
Radu
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionNovember 11, 2015 at 10:37 #86751MatthiasParticipantHi,
I use this code that you have me above:
COPY CODEif ( ! function_exists( 'kleo_entry_meta' ) ) : /** * Prints HTML with meta information for current post: categories, tags, permalink, author, and date. * Create your own kleo_entry_meta() to override in a child theme. * @since 1.0 */ function kleo_entry_meta( $echo = true, $att = array() ) { global $kleo_config; $meta_list = array(); $author_links = ''; $meta_elements = sq_option( 'blog_meta_elements', $kleo_config['blog_meta_defaults'] ); // Translators: used between list items, there is a space after the comma. if ( in_array( 'categories', $meta_elements ) ) { $categories_list = get_the_category_list(__(', ', 'kleo_framework')); } // Translators: used between list items, there is a space after the comma. if ( in_array('tags', $meta_elements ) ) { $tag_list = get_the_tag_list('', __(', ', 'kleo_framework')); } $date = sprintf( '<a href="%1$s" rel="bookmark" class="post-time" rel="nofollow">' . '<time class="entry-date" datetime="%2$s">%3$s</time>' . '<time class="modify-date hide hidden updated" datetime="%4$s">%5$s</time>' . '</a>', esc_url( get_permalink() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_html( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); if ( is_array( $meta_elements ) && !empty( $meta_elements ) ) { if ( in_array( 'author_link', $meta_elements ) || in_array( 'avatar', $meta_elements ) ) { /* If buddypress is active then create a link to Buddypress profile instead */ if (function_exists( 'bp_is_active' ) ) { $author_link = esc_url( bp_core_get_userlink( get_the_author_meta( 'ID' ), $no_anchor = false, $just_link = true ) ); $author_title = esc_attr( sprintf( __( 'View %s\'s profile', 'kleo_framework' ), get_the_author() ) ); } else { $author_link = esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); $author_title = esc_attr( sprintf( __( 'View all POSTS by %s', 'kleo_framework' ), get_the_author() ) ); } $author = sprintf( '<a class="url fn n" href="%1$s" title="%2$s" rel="author" rel="nofollow">%3$s %4$s</a>', $author_link, $author_title, in_array( 'avatar', $meta_elements ) ? get_avatar( get_the_author_meta( 'ID' ), 50) : '', in_array( 'author_link', $meta_elements ) ? '<span class="author-name">' . get_the_author() . '</span>' : '' ); $meta_list[] = '<small class="meta-author author vcard">' . $author . '</small>'; } if ( function_exists( 'bp_is_active' ) ) { if ( in_array( 'profile', $meta_elements ) ) { $author_links .= '<a href="' . bp_core_get_userlink( get_the_author_meta( 'ID' ), $no_anchor = false, $just_link = true ) . '" rel="nofollow">' . '<i class="icon-user-1 hover-tip" ' . 'data-original-title="' . esc_attr(sprintf(__('View profile', 'kleo_framework'), get_the_author())) . '"' . 'data-toggle="tooltip"' . 'data-placement="top"></i>' . '</a>'; } if ( bp_is_active( 'messages' ) ) { if ( in_array( 'message', $meta_elements ) ) { $author_links .= '<a href="' . wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( get_the_author_meta( 'ID' ) ) ) . '" rel="nofollow">' . '<i class="icon-mail hover-tip" ' . 'data-original-title="' . esc_attr(sprintf(__('Contact %s', 'kleo_framework'), get_the_author())) . '" ' . 'data-toggle="tooltip" ' . 'data-placement="top"></i>' . '</a>'; } } } if ( in_array( 'archive', $meta_elements ) ) { $author_links .= '<a href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '" rel="nofollow">' . '<i class="icon-docs hover-tip" ' . 'data-original-title="' . esc_attr(sprintf(__('View all posts by %s', 'kleo_framework'), get_the_author())) . '" ' . 'data-toggle="tooltip" ' . 'data-placement="top"></i>' . '</a>'; } } if ( $author_links != '' ) { $meta_list[] = '<small class="meta-links">' . $author_links . '</small>'; } if (in_array( 'date', $meta_elements ) ) { $meta_list[] = '<small>' . $date . '</small>'; } $cat_tag = array(); if ( isset( $categories_list ) && $categories_list ) { $cat_tag[] = $categories_list; } if ( isset( $tag_list ) && $tag_list ) { $cat_tag[] = $tag_list; } if (!empty($cat_tag)) { $meta_list[] = '<small class="meta-category">'.implode(", ",$cat_tag).'</small>'; } //comments if ((!isset($att['comments']) || (isset($att['comments']) && $att['comments'] !== false)) && in_array( 'comments', $meta_elements )) { $meta_list[] = '<small class="meta-comment-count"><a href="'. get_permalink().'#comments" rel="nofollow">'.get_comments_number() . ' <i class="icon-chat-1 hover-tip" ' . 'data-original-title="'.sprintf( _n( 'This article has one comment', 'This article has %1$s comments', get_comments_number(), 'kleo_framework' ),number_format_i18n( get_comments_number() ) ).'" ' . 'data-toggle="tooltip" ' . 'data-placement="top"></i>' . '</a></small>'; } $meta_separator = isset( $att['separator'] ) ? $att['separator'] : sq_option( 'blog_meta_sep', ', ') ; if ( $echo ) { echo implode( $meta_separator, $meta_list ); } else { return implode( $meta_separator, $meta_list ); } if ( 'post' == get_post_type() ) { // Add third plugin to show post view echo ' '; echo do_shortcode('<small>[favorite_count post_id=""]</small>'); echo '<small><i class="fa fa-heart"></i></small>'; } } endif;
The last if statement adds the number of favorites to the meta. However, I need the meta key of the favorites, how can I find it ?
Thanks
November 11, 2015 at 17:41 #86826RaduModeratorHi Matthias,
That shortcode is generated by the plugin ( https://wordpress.org/plugins/post-views-counter/ ) the shortcode is builded in wp-content/plugins/post-views-counter/includes/frontend.php line 24
Cheers
Radu
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionNovember 17, 2015 at 10:44 #87658MatthiasParticipantThanks for your help, however this doesn’t exactly answer my questions.
In the visual composer settings, in grid elements, I’m customizing a grid element (see attached). I can add custom fields, but I need the meta keys field name for: author name, comments, likes (see attached). Where can I find this ?
Thanks
Attachments:
You must be logged in to view attached files.November 18, 2015 at 18:03 #87907AndreiModeratorPlease contact the author of the post views plugin in order to point you out what is the “Field Key” that he’s using to store the post views data.
Cheers
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionNovember 20, 2015 at 16:42 #88314MatthiasParticipantThanks but I’m not only talking of the post views plugin, but also about the regular author key, and comments key that is used for the kleo post visual composer element for example.
November 20, 2015 at 18:11 #88347AndreiModeratorComments and author are not available as meta key, they are information of the post itself and cannot be retrieved as meta information.
Please let me know if I can help you with anything else.
CheersHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.