Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    It is indeed possible, thanks to the WordPress.com Stats API. You can learn more about the API here:
    https://stats.wordpress.com/csv.php
    https://phoxis.org/2011/04/24/wordpress-com-stats-api/
    https://wpgr.org/2013/03/02/rendering-jetpack-stats/

    You could also install this Jetpack add-on:
    https://www.ads-software.com/plugins/jetpack-post-views/
    It already bundles a few methods to add Post Views to your posts.

    I hope this helps.

    Thread Starter EVOgroup

    (@evogroup)

    I have the jetpack-post-views plugin but there is no shortcode to add the number of post views into the post with shortcode.

    the only option to display it it via the template file and php

    <?php echo get_post_meta( $post->ID, ‘jetpack-post-views’, true ); ?>

    but i want to set it in a specific place inside the post so the only solution is a short code but i dont know how to do it and the author of jetpack-post-views plugin is not answering.

    Please someone help me to write a simple short code to display number of post views.

    Thanks

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    You might want to contact the plugin author here and ask them to implement this feature into their plugin.

    In the meantime, you can build your own small plugin to extend the Jetpack Post Views plugin and add the [jpviews] shortcode, for example, like so:

    function jeherve_jpviews_shortcode() {
    	$post_id = get_the_ID();
    
    	return get_post_meta( $post_id, 'jetpack-post-views', true );
    
    }
    add_shortcode( 'jpviews', 'jeherve_jpviews_shortcode' );
    Thread Starter EVOgroup

    (@evogroup)

    That’s all i wanted, working great!!!
    THANKS Jeremy!!!
    You the best!!!

    Thread Starter EVOgroup

    (@evogroup)

    5 Stars to you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Short code [views]’ is closed to new replies.