WPIntell

Source evidence

Question of code

Post Views for Jetpack · support · 2023-05-04T06:07:00+00:00

mixedsentiment
mediumseverity
0.84relevance
3replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

2 / 25 rows with source links

8.0% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

23 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
lotfreeman resolved
Started using your plugin, works great! Understood with snippets. Can you tell me where to put this code <?php echo do_shortcode( '[jp_post_view]' ); ?> where is the topic? Theme: Kadence I would like to display the views on the post card, and not inside the page or post that the views from your plugin were visible I ask for your advice! I would recommend that you do not edit your theme files directly. If you do that, your changes would disappear the next time you update to a new version of the theme. Instead, you can use a plugin like this one to add code to your site. You can then choose where that code will be hooked into your theme. Your theme, Kadence, offers a lot of hooks, places where you can inject content. You can, for example, decide to inject content right after the entry meta data, like on this screenshot: Would that work for you? To do that, you would add the following code to the Code Snippets plugin I mentioned above: add_action( 'kadence_after_loop_entry_meta', function () { printf( '<span class="views">%s</span>', do_shortcode( '[jp_post_view]' ) ); } ); Let me know if it helps! Thanks, the code worked great. I admire you, you are a true professional! Your plugin is seriously slowing down the site. Found out today by running a speed test, can you fix it? Could you check if you are running the latest version of the plugin, version 1.5.0? I made some changes to improve performance in that version, so that should help. Beyond those changes, the plugin will have an impact on performance indeed, especially if you display multiple counters on the same page (like with the code snippet above). The plugin does cache data to help with performance, but the first time the page is loaded it will be slow since it needs to fetch your stats data from WordPress.com, for each post with a counter on the page. If you’d like to cache data even more aggressively on your site to further improve performance, you can add the following code snippet to your site: /** * Cache post views for 6 hours. */ add_filter( 'jp_post_views_cache_duration', function () { return 6 * HOUR_IN_SECONDS; } ); Note, however, that if you add the following snippet, the number of views will only be refreshed every 6 hours on your site.

Comments

3 shown
Jeremy Herve 2023-05-04T18:26:00+00:00

I would recommend that you do not edit your theme files directly. If you do that, your changes would disappear the next time you update to a new version of the theme. Instead, you can use a plugin like this one to add code to your site. You can then choose where that code will be hooked into your theme. Your theme, Kadence, offers a lot of hooks, places where you can inject content. You can, for example, decide to inject content right after the entry meta data, like on this screenshot: Would that work for you? To do that, you would add the following code to the Code Snippets plugin I mentioned above: add_action( 'kadence_after_loop_entry_meta', function () { printf( '<span class="views">%s</span>', do_shortcode( '[jp_post_view]' ) ); } ); Let me know if it helps!

lotfreeman 2023-05-05T01:43:00+00:00

Thanks, the code worked great. I admire you, you are a true professional! Your plugin is seriously slowing down the site. Found out today by running a speed test, can you fix it?

Jeremy Herve 2023-05-05T08:47:00+00:00

Could you check if you are running the latest version of the plugin, version 1.5.0? I made some changes to improve performance in that version, so that should help. Beyond those changes, the plugin will have an impact on performance indeed, especially if you display multiple counters on the same page (like with the code snippet above). The plugin does cache data to help with performance, but the first time the page is loaded it will be slow since it needs to fetch your stats data from WordPress.com, for each post with a counter on the page. If you’d like to cache data even more aggressively on your site to further improve performance, you can add the following code snippet to your site: /** * Cache post views for 6 hours. */ add_filter( 'jp_post_views_cache_duration', function () { return 6 * HOUR_IN_SECONDS; } ); Note, however, that if you add the following snippet, the number of views will only be refreshed every 6 hours on your site.