Trying to fetch ranking with short code
-
Hi!
I’m trying to fetch the ranking with a short code to be able to sort in the Tables by supsystic plugin:
function grab_post_meta_shortcode_fn( $atts ) {
$atts = extract( shortcode_atts( array(
‘post_id’ => false,
‘key’ => ”
), $atts ) );
if ( ! $key ) {
return;
}
$post_id = (int)($post_id === false ? get_the_ID() : $post_id);
$data = get_post_meta( $post_id, $key, true );if ( $data ) {
return ‘<span class=”grab-post-meta-value ‘ . sanitize_html_class(‘id-‘ . $post_id) . ‘ ‘ . sanitize_html_class(‘key-‘ . $key) . ‘”>’. $data .'</span>’;
}
}
add_shortcode( ‘grab_post_meta’, ‘grab_post_meta_shortcode_fn’ );I am displaying the star ratings in a table without a problem. However when I’m trying to get their numerical rating it doesn’t display anything. I’ve checked that I use the right page id and I know that the pages have a rating added because the stars are showing correctly. I use the short code like this: [grab_post_meta id=”1393″ key=”_glsr_ranking”]
What am I missing here?
Thank you for the best rating plugin out there!
With best regards,
bb
The
- The topic ‘Trying to fetch ranking with short code’ is closed to new replies.