Hi @bekee,
I’ve added extra helpers so that you can output the values with the help of post_id.
Here is the link to Github, with the corresponding functions: https://github.com/pixelbart/helpful/blob/master/core/values.php
// get pro for single post
helpful_get_pro( $post_id = null );
// get contra for single post
helpful_get_contra( $post_id = null );
Helpful also stores something in the meta fields, but not everything. Helpful’s meta fields are updated every time the overview pages are called in wp-admin.
// get pro for single post
get_post_meta( $post_id, 'helpful-pro', true);
// get contra for single post
get_post_meta( $post_id, 'helpful-contra', true);
Hopefully that could help you a little.
-
This reply was modified 6 years, 6 months ago by
Pixelbart.
-
This reply was modified 6 years, 6 months ago by
Pixelbart.
-
This reply was modified 6 years, 6 months ago by
Pixelbart.
-
This reply was modified 6 years, 6 months ago by
Pixelbart.
-
This reply was modified 6 years, 6 months ago by
Pixelbart.
@bekee
$args = [
'posts_per_page' => -1,
'meta_query' => [],
'fields' => 'ids',
'meta_key' => 'helpful-pro',
'orderby' => 'meta_value_num',
'order' => 'DESC',
];
$query = new WP_Query( $args );
if ( $query->found_posts ) {
printf( '<strong>%s</strong><br>', esc_html__( 'Pro:' ) );
foreach ( $query->posts as $post_id ) :
printf( '%s: %d<br>', get_the_title( $post_id ), (int) get_post_meta( $post_id, 'helpful-pro', true ) );
endforeach;
}
$args = [
'posts_per_page' => -1,
'meta_query' => [],
'fields' => 'ids',
'meta_key' => 'helpful-contra',
'orderby' => 'meta_value_num',
'order' => 'DESC',
];
$query = new WP_Query( $args );
if ( $query->found_posts ) {
printf( '<strong>%s</strong><br>', esc_html__( 'Contra:' ) );
foreach ( $query->posts as $post_id ) :
printf( '%s: %d<br>', get_the_title( $post_id ), (int) get_post_meta( $post_id, 'helpful-contra', true ) );
endforeach;
}
I’ve already tested the code on myself. All you have to do is insert the post_type as argument and change the order accordingly (ASC/DESC).
-
This reply was modified 6 years, 6 months ago by
Pixelbart.
-
This reply was modified 6 years, 6 months ago by
Pixelbart.
Thread Starter
bekee
(@bekee)
@pixelbart
Wow! Thank you so much for your speedy reply. I appreciate it!