Display Post Views & CPT Count with Crocoblock Jetengine | Elementor | WordPress

  Рет қаралды 13,768

Moxet Khan

Moxet Khan

2 жыл бұрын

You might have face problem displaying Post Views for the CPT especially if your website is a newspaper, property listing or classified. In this tutorial, i will show you how to create it with few lines of code in JetEngine Crocoblock.
In addition to that it covers how to show total number of CPT.
Code to be inserted in Child theme:
$meta_values = get_post_meta( get_the_ID(), "posts-count", true);
$v2 = (int)$meta_values + 1;
update_post_meta( get_the_ID(), 'posts-count', $v2);
Download Elementor:
elementor.com/?ref=16401
Download Crocoblock:
crocoblock.com/?ref=4088
Need to build dynamic websites?
softemblems.com
Follow me on Social Media
Facebook : / mxtchamkani
Instagram : / moxet
Twitter : / sokaniwaal
Track: Peruvian Woods - Dave Osorio [Audio Library Release]
Music provided by Audio Library Plus
Watch: • Peruvian Woods - Dave Osorio | Free B...
Free Download / Stream: alplus.io/peruvian-woods

Пікірлер: 151
@brink6876
@brink6876 Жыл бұрын
Finding your channel made my day. I have been looking hard for someone who explains JetEngine more clearly than the docs on their website. I have been using Crocoblock for the past 4 years but I've only scratched the surface of what is possible I'm sure. That you are explaining some PHP code that interacts with it as well is also a big help. Thanks Liked! Subscribed!
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Thank you for your interest and visting the channel, will try my best to share more valuable tutorials in future :) Keep in touch please
@isaacosei8299
@isaacosei8299 3 ай бұрын
Your channel and content!! Thank you for sharing this, you don't understand how beneficial it has been! Blessings to you.
@naabigaabdoulrazak1959
@naabigaabdoulrazak1959 2 жыл бұрын
Thanks Abdul Moxet, that's an amazing video. Looking forward to seeing the full video of how you built the all site.
@TiagoMBarreto
@TiagoMBarreto 2 жыл бұрын
Thanks for this video Bro, Congrats!
@toygarniron
@toygarniron 2 жыл бұрын
This is great information! I was already tracking this data from Google Analytics, but it can be attractive for high hit content for advertisers to access this data on my website :) Thank you
@WawanInt
@WawanInt Жыл бұрын
Its so awesome..thanks🙏
@cookie9250
@cookie9250 2 жыл бұрын
Views count worked for me.... Thanks
@1WOWACC
@1WOWACC 2 ай бұрын
Great, I hope you continue to develop content about Jetengine
@MuhammadBilal-oc6pi
@MuhammadBilal-oc6pi 3 ай бұрын
Moxet Khan, you are Gem........... thanks for such good content... Please make videos as soon as possible....
@juan07241981
@juan07241981 Жыл бұрын
Hola,, que excelente video,, te agradezco por compartir tu conocimiento,, gracias y sigue adelante,, te encontré por casualidad y no sabes el gusto que me da,, nuevamente gracias y por favor, sigue haciendo este tipo de videos que son diferentes a los que se encuentran en KZbin
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Muchas gracias por tu interés. Por favor, manténgase en contacto para más videos.
@Muhammadkhan-uf4cl
@Muhammadkhan-uf4cl Жыл бұрын
you are the king
@anumnetwork
@anumnetwork Жыл бұрын
Nice Sir ... Thank You
@purnendu.mukherjee
@purnendu.mukherjee Жыл бұрын
You are just awesome
@mauricioalejandro7329
@mauricioalejandro7329 Жыл бұрын
Excellent video!! I don't know what I'm doing wrong but you wouldn't be telling me.. I have put the code from the plugins code snippet $meta_values = get_post_meta( get_the_ID(), "counter-properties", true); $v2 = (int)$meta_values +1; update_post_meta( get_the_ID(), "counter-properties", $v2); Thanks for your time!!
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
please encapsulate your code in a filter as below add_filter('the_content','view_counter'); function view_counter($content) { $meta_values = get_post_meta( get_the_ID(), "post-count", true); $v2 = (int)$meta_values + 1; update_post_meta( get_the_ID(), 'post-count', $v2); }
@michaelj.9401
@michaelj.9401 Жыл бұрын
Works great, thanks; does not work with caching plugin, possible to do the same thing in AJAX or JS? Thanks
@bharat61020
@bharat61020 Жыл бұрын
Hi Moxet, this video was really helpful thank you, but I am facing a issue the post views count does not increase when caching plugin is enabled..... When I disable caching for cpt single pages then everything works fine. Any idea on this?? Thanks!!
@DomenicoMastroianni
@DomenicoMastroianni Жыл бұрын
Thanks for your videos, valuable content indeed. In regard to this post count, is there a way to add a post view based on user role? I'd like to create a front end notification to tell the user how many posts are new or marked as view (meta field not equal to 0). Hope it makes sense.
@VK-yj2kg
@VK-yj2kg Жыл бұрын
May I know is it possible add the view count into Jet posts using your code in a filter as below?
@ramdaniamarulloh6505
@ramdaniamarulloh6505 2 жыл бұрын
Thanks you broo
@soyeb_ali
@soyeb_ali Жыл бұрын
Hello muqsit, how can I make only signle views for single user. 1 view = 1 user. I think this is done via user meta query.
@jernias637
@jernias637 Ай бұрын
Hey Abdul Moxet. Thank you for the great video, love your contents. I have a question; is it possible to do it for custom content types? I created a messaging system similiar to whatsapp by your videos. Basically, I created a post for chat and cct for messages. I want to inform users for not read messages.
@acarolalvarenga
@acarolalvarenga Жыл бұрын
I'd like to add that for each post of a logged user. For example: a user visits a post and I want to tell him: "You've seen this post 4 times". It's for a college content review post type...
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Hello, use JetEngine data store for that, it counts for logged in users.
@acarolalvarenga
@acarolalvarenga Жыл бұрын
@@MoxetKhanPK thank you, I'll check that up!
@outlandermax
@outlandermax Жыл бұрын
Hi Moxet, thank you for your contributions with these handy addons. I just tested this with the encapsulated code and followed exactly how you got this working in the video, but unfortunately my pages are loading blank w. that code in the functions.php child theme. Any ideas if there are some setups that require a modification? Cheers!
@franshescomviran5741
@franshescomviran5741 Жыл бұрын
Try using code snippets
@tecnirf
@tecnirf Жыл бұрын
Hola, Intente hacer conteo de visitas a la Single User Page que crea el Profile Builder pero no funciono. Utilice tu Snippet pero con Get_user_meta y update_user_meta. Ayuda por favor!
@werbeagenturpr-pro5197
@werbeagenturpr-pro5197 2 жыл бұрын
Hello, is there a way to trigger the counter with a time delay, so that it is prevented that a visitor drives the counter up by constantly loading the page. Example: The page is updated several times in one minute but the counter only counts up every minute or every 2 minutes.
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Yes it is possible with the combination of cron job/delay and user agent, so the user agent will get the user details and cronjob will make sure it execute after X time. wordpress.stackexchange.com/questions/56266/delay-function-on-publish
@seekknowledge1928
@seekknowledge1928 2 жыл бұрын
Its an amazing video tutorial.. Please make a video how to build user profile ( Dashboard / login / sign up) by Crocoblock
@serdimay7
@serdimay7 2 жыл бұрын
Thank you for the video. Yes I would love to see how you build the whole system from scratch. Sometimes to better understand some features, you have to explain what environment you are using it for. Waiting for the tutorial as you promised. Thank you again. This is awesome. But the way why didn't you just use the CPT or post count from Jetengine without using the codes in the child theme?
@MoxetKhanPK
@MoxetKhanPK 2 жыл бұрын
I will surely share the full case study soon, do we have built post views built in jetengine?
@jayveecabug6684
@jayveecabug6684 2 жыл бұрын
@@MoxetKhanPK waiting you build the whole system from scratch
@mohamedalarabe1330
@mohamedalarabe1330 Жыл бұрын
First of all thank you for this video But there are two problems when I use this code function view_counter($content) { $meta_values = get_post_meta( get_the_ID(), "post-count", true); $v2 = (int)$meta_values + 1; update_post_meta( get_the_ID(), 'post-count', $v2); } add_filter('the_content','view_counter'); First one is the pages content disappeared. I solved this by adding this line return $content ; The Second problem that the code works on edit post type page but doesn't work on a single page The single page that I use is Crocoblock > Theme Builder > Single page If any help I will be appreciate thanks
@thomasanderson5873
@thomasanderson5873 4 ай бұрын
same here. doesnt work on a single page/single post.
@chris_reyem
@chris_reyem 4 ай бұрын
​@@thomasanderson5873
@chris_reyem
@chris_reyem 4 ай бұрын
// Erhöhe den Seitenaufrufzähler function increment_page_views() { $current_views = get_post_meta(get_the_ID(), 'page_views', true); if ($current_views == '') { $current_views = 0; } $new_views = $current_views + 1; update_post_meta(get_the_ID(), 'page_views', $new_views); } add_action('template_redirect', 'increment_page_views');
@DeveloperPromise
@DeveloperPromise 2 ай бұрын
good
@mrshesek
@mrshesek Жыл бұрын
Hello and thank you for this amazing video! IS there a way to implement this for button click tracking? I have a CPT called Therapists, and contact buttons (Call, Facebook, Mail etc), and the client wishes to count the clicks on this buttons individually for every therapist. Is that possible?
@franshescomviran5741
@franshescomviran5741 Жыл бұрын
I wold like to see this as well.
@rodneylivanze2906
@rodneylivanze2906 Жыл бұрын
This was Brilliant. I am looking for the code of displaying the number of times a document (PDF) has been downloaded to be displayed on the front end
@iemvo9629
@iemvo9629 2 жыл бұрын
I use custom post type. And create the views meta field there. I tried the code but it doesn't work. Do I have to use metabox and create meta field?
@MoxetKhanPK
@MoxetKhanPK 2 жыл бұрын
Make sure you placed the code in functions.php and the meta value is visible in CPT
@antonichristian5845
@antonichristian5845 Жыл бұрын
great video, thanks!!! what i'd like to know is it possible to order a jetengine listing by number of most views (most popular posts) using this method?
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Yes why not, goto query builder and fetch your data sort by most views descending.
@michaelakubas
@michaelakubas Жыл бұрын
Hi, thanks for video. I use post grid from unlimited-elements, and I add custom fields. But when I click on post is post count to all posts. Please help :)
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Hello, just turn off other plugins and themes and check it on blank setting. Make sure get_the_ID() function in place so it can add only in that post.
@SixGamerHeads
@SixGamerHeads Жыл бұрын
Hello, you are amazing. by the way, do you know how to add numbers (numbering) to the posts yo my listing grid? and could you tell me how please? for example, in my Listing, I want it looks like this: Number 1*, Title Post, then the descriptions Number 2*, Title Post, then the descriptions Number 3*, Title Post, then the descriptions etc... * the numbers mean, it's automatically added, and ascending by date or name. according to the number of posts that appear on the page/archive. thank you.
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Hello, you have to use query builder to create a query which fetches all your post details in addition to one extra column for count. I have attached a sample of query builder here. prnt.sc/_yWsUzdrQJ13 Once the query is done, you can display the columns in listing grid including counter column.
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Anyone who faces a problem due to a recent update, please encapsulate your code in a filter as below function increment_post_views() { if (is_single()) { $post_id = get_the_ID(); $views = get_post_meta($post_id, 'post-count', true); // If the 'post_views' meta field doesn't exist, initialize it to 1 if (empty($views)) { $views = 1; } else { $views = intval($views) + 1; } // Update the 'post_views' meta field with the incremented value update_post_meta($post_id, 'post-count', $views); } } add_action('wp', 'increment_post_views');
@alwinlangmann89
@alwinlangmann89 Жыл бұрын
Hey man really love this! Could you please help me with my Rank? I want to be able to view the posts that the most people clicked "submit" on. So i got a elementor form with a submit button on my single-post page. Everytime someone submits the form on a specific post, its "rank" counter should increase. thanks
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
@@alwinlangmann89 Hello Alwin, thank you for you interest. Its easy, what you need to do is to have the button connect to an internal hook as notification in the form. When you click on button it should trigger the hook and the hook should have something like this [make sure your hook name is send] add_action('jet-engine-booking/send', 'send', 10, 2); function send($data, $id){ $post_id = $data["post_id"]; $meta_values = get_post_meta($post_id, "rank-meta", true); $v2 = (int)$meta_values + 1; update_post_meta($post_id, 'rank-meta', updated value); }
@alwinlangmann89
@alwinlangmann89 Жыл бұрын
@@MoxetKhanPK thank you so much! AWESOME
@tkrh.106
@tkrh.106 Жыл бұрын
Hi, thank you for providing very useful information. I post the vimeo URL to show the video in the post. After setting this filtered code , the page cannot load the vimeo. Is there any way to resoleve this?? And using the past code written in a description , the count function was not working.
@KHRifat
@KHRifat Жыл бұрын
I am looking for something like this, you helped me a lot. I am making a Directory site, where every business can see "How many times their profile is visited" in their Dashboard. Also, how many leads they collected (on the profile page there will be some offers if anyone "Claims" the offer by clicking the button, it will be counted as a lead). How to achieve that.? In the dashboard, every user can see their own statistics (Profile visits & Collected leads). Hopefully you will help me with this.
@mrveeto6655
@mrveeto6655 4 ай бұрын
I'm using the Hello Elementor but don't have the child theme.. how to create the child theme?
@mrveeto6655
@mrveeto6655 4 ай бұрын
this method not working when i test
@mauricioalejandro7329
@mauricioalejandro7329 Жыл бұрын
Excellent!! Thanks for sharing your knowledge! Query: *Is it possible to make a listing impression counter?
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Most probabaly with jquery, the visible part of the canvas should send +1 to the impression meta in the back-end each time someone scroll. Its just an idea not yet implemented.
@mauricioalejandro7329
@mauricioalejandro7329 Жыл бұрын
@@MoxetKhanPK it would be great
@dariondanielscreative
@dariondanielscreative 2 жыл бұрын
Hi Moxet! Thank you for great video. What would be the code if I wanted to exclude admin views?
@MoxetKhanPK
@MoxetKhanPK 2 жыл бұрын
Please check this link developer.wordpress.org/reference/functions/is_admin/
@xcantenerealguy1361
@xcantenerealguy1361 Жыл бұрын
How to make this counters when they go over 1000 to be 1k, and if in the case 1 Million to be 1M or even say 1.5k and etc?
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
In the output you have to apply this javascript code stackoverflow.com/questions/10599933/convert-long-number-into-abbreviated-string-in-javascript-with-a-special-shortn
@mokona_0992
@mokona_0992 2 жыл бұрын
Loving your videos! Since you know your way around JetEngine, I have a quick question I hope you can answer. Is it possible to display user data (using data stores) in a dynamic chart against a meta field? For example, I have a library with three states (reading, planned, completed) = data stores. Historical books are separated into different centuries (1st, 2nd, 3rd) = meta field - radio field. The problem is, I can’t figure out how to display the data in a dynamic chart where my users can see their progress broken by century. Is this not possible or perhaps another way of using JetEngine to achieve this?
@dreamsachiever212
@dreamsachiever212 Жыл бұрын
Been looking for an answer for this....
@user-xs8bz6nl3y
@user-xs8bz6nl3y 2 жыл бұрын
Can I somehow make a custom field that will display whether the user is online or not?
@MoxetKhanPK
@MoxetKhanPK 2 жыл бұрын
Well it depends on environment; what mechanism you ll use to determine someone is online or offline, plugin might help. Manual will take timr
@michelfayadat1888
@michelfayadat1888 2 жыл бұрын
Thank you very much for the video. By the way, how can I insert the code since I'm not using a child-theme ?
@MoxetKhanPK
@MoxetKhanPK 2 жыл бұрын
You can add it directly to your theme or using php snippet plugin which helps you add php code anywhere.
@michelfayadat1888
@michelfayadat1888 2 жыл бұрын
@@MoxetKhanPK thanks a lot !
@sergixelmusic6748
@sergixelmusic6748 Жыл бұрын
If it's possible to reset the meta field 'posts-count' each 30 days to 0?
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Yes possible, you have to setup a cron job which throw an action after every 30 days. The cron job PHP will have the meta keys map with the table you want to reset.
@Ellinio
@Ellinio Жыл бұрын
Hello there, Great Tutorial!! Many Thanks!! In my case the post counter rises up by 2 instead of 1 view every time i refresh the page. Any Tip how to resolve that? Thanks in advance!! Greatings from Greece!!
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Hello Thank you for your interest, not sure what is wrong exactly but you can install code snippet and insert over there.
@eacc95
@eacc95 Жыл бұрын
Great video. Question, what should I do if I don't want admin views to count? Thanks in advance
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
You can check from this answer whether the user is admin or not wordpress.stackexchange.com/questions/5047/how-to-check-if-a-user-is-in-a-specific-role/54837#54837
@toygarniron
@toygarniron 2 жыл бұрын
Hello Khan, This tutorial didn't work for me. I did exactly what I saw but the counter is somehow not working. Also, they all need to be updated one by one for the counter to appear on existing posts. It only seems to work on new posts. Where could I be doing wrong? Thank you
@MoxetKhanPK
@MoxetKhanPK 2 жыл бұрын
Two things to consider in your case. Make sure to paste the code inside qp_enque_style, 2nd thing i mentioned in tutorial that the default value of meta must be zero so it applies on both new and old posts.
2 жыл бұрын
@@MoxetKhanPK I used child theme by crocoblock, and it don't have qp_enque_style, so where shoud I put your code /** * Child functions and definitions. */ add_action( 'ocean_header', 'cb_child_do_header', -999 ); add_action( 'ocean_footer', 'cb_child_do_footer', -999 ); /** * Apply Crocoblock custom headers * * @return [type] [description] */ function cb_child_do_header() { cb_child_process_location( 'header', true ); } /** * Apply Crocoblock custom footers * * @return [type] [description] */ function cb_child_do_footer() { cb_child_process_location( 'footer', true ); } /** * Process single location * * @return void */ function cb_child_process_location( $location = null, $cleanup = false ) { if ( ! function_exists( 'jet_theme_core' ) ) { return false; } if( ! defined( 'ELEMENTOR_VERSION' ) ) { return false; } $done = jet_theme_core()->locations->do_location( $location ); if ( $done && $cleanup ) { $hook = current_filter(); remove_all_actions( $hook ); } return $done; }
@muhammadaslan6256
@muhammadaslan6256 11 ай бұрын
how we can do that for woocommerce prodcuts count and sales to show how much was sold this product
@MoxetKhanPK
@MoxetKhanPK 11 ай бұрын
Use query builder instead, run a query which count products in orders table.
@muhammadaslan6256
@muhammadaslan6256 11 ай бұрын
can you guide me to do that ? i want to make default sales value and any one buy it the count will be improve it @@MoxetKhanPK
@brusbezerra
@brusbezerra 7 ай бұрын
Great tutorial, thanks! What about if we want to count viewers by session, not unique views?
@MoxetKhanPK
@MoxetKhanPK 7 ай бұрын
So someone refresh the page 5 times but it counts 1?
@brusbezerra
@brusbezerra 7 ай бұрын
@@MoxetKhanPK yes
@simeon.benevrekov
@simeon.benevrekov Жыл бұрын
For some reason it doesn't work for me. I am trying to use the code snippets plugin to add the code, but I tried inserting it directly to the theme file editor, and still not working :( I've created a metabox, assigned that to the CPT needed etc.
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Did you tried to make meta boxes inside CPT instead of creating individual meta
@simeon.benevrekov
@simeon.benevrekov Жыл бұрын
@@MoxetKhanPK Yes. The first time I’ve just added a meta field to the CPT but the 2nd time, I’ve created a metabox and assign it to the CPT as you show. I reached to the support but they said that on the newest version might not work. Does it still work on your website?
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
@@simeon.benevrekov i ll try it with latest version of jetengine.
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
please encapsulate your code in a filter as below add_filter('the_content','view_counter'); function view_counter($content) { $meta_values = get_post_meta( get_the_ID(), "post-count", true); $v2 = (int)$meta_values + 1; update_post_meta( get_the_ID(), 'post-count', $v2); }
@DavidMurrin77
@DavidMurrin77 9 ай бұрын
I sort of have this working. The main problem is that the counter is added to if I refresh the post in the wordpress dashboard as well, rather than just on the front end
@engrrajonahmed
@engrrajonahmed 4 күн бұрын
Run the code in the frontend only. Use code snippet plugin.
@ProkomputerRup
@ProkomputerRup Жыл бұрын
Thanks for receipe. How about caching plugin? Will be This works?
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Not sure, need to test it.
@bestfriendfhn
@bestfriendfhn Жыл бұрын
How can we display most viewed most using jet listing?
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
The data of your views are stored in database, you can run a query on your post and sort by VIEWS [Meta field]
@shakibkhan1921
@shakibkhan1921 2 жыл бұрын
Please Make basic to advance tutorial on Jet Plugins
@jenniferward6821
@jenniferward6821 2 жыл бұрын
Hi Moxet the guru of Croco. Just asked for a tut about drop downs where in front end firm submission, a SELECT field will then restrict the options in the next select field, eg country, then city then suburb, that sort of thing PLEASE do a tut on that?? Trawled KZbin and found nothing at all.
@MoxetKhanPK
@MoxetKhanPK 2 жыл бұрын
Hello Jennifer, the issue is discussed like 32 weeks ago and mentioned by crocoblock that it is in pipeline to be released. There is no simple shortcut as of now but doable with jquery stackoverflow.com/questions/30346640/javascript-jquery-dependent-drop-down-list
@jenniferward6821
@jenniferward6821 2 жыл бұрын
☹️ jquery… Perhaps do a tut in this?? Re the map listings function: it seems a crucial thing is for the user to have a default “home” starting point, either from browser or from meta, but also the ability to filter the map, using cities, towns suburbs etc. Perhaps via a CCT with all the geolocations user could reference? Then the search for coffee shops mechanics whatever which is already easily done with Jetengine. So three options for that important starter map - 1) the geolocate of the browser - done, 2) the meta of the USER address (switch?) and 3) Heirachical selects of country city suburb .. sort of thing? Feels to me all of this is already possible, but my knowledge is to scant. Tut?? it not possible to use a dynamic range filter on the page to increase / decrease the results one finds? Also if the USER sets up his home suburb, which is geolocated in a CCT, then can we use that as the start place of the map on the page? All sounds (vaguely) doable already?? Please do more on this?
@Website-Developer
@Website-Developer Ай бұрын
Always like your stuff, but I would like a counter for posts published by users based on user roles and CPTs i.e. I have cpt1, cpt2, cpt3, cpt4 and a user role is assigned to each CPT such as user-role1 publishes to cpt1, user-role2 publishes to cpt2, user-role3 publishes to cpt3, user-role4 publishes to cpt4. Each member at their levels would then know how many posts they have published.
@MoxetKhanPK
@MoxetKhanPK Ай бұрын
You can create query for that, select all posts from cpt1 and display the query result count of that query to user-role1 only. same goes for the rest.
@Website-Developer
@Website-Developer Ай бұрын
@@MoxetKhanPK Thank you, and what if I have 10 users with user-role1? Will it determine how many posts each user has?
@MoxetKhanPK
@MoxetKhanPK Ай бұрын
@@Website-Developer yes it will determine
@Website-Developer
@Website-Developer Ай бұрын
@@MoxetKhanPK So I am assuming the each user role would need to have its own template as one template can not be used for all user roles correct?
@MoxetKhanPK
@MoxetKhanPK Ай бұрын
@@Website-Developer It can be used for multiple user role as well.
@webstep4677
@webstep4677 Жыл бұрын
thanks the code works, but my problem is that the counter is updated 2 times. Example: count_start = 116 count_end = 117 If at this moment you look at the value in the admin panel, then there will be 118. I will be glad if someone can help me to solve the problem
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Hi, need to check it thoroughly. Please contact via email.
@arielolberg-swe
@arielolberg-swe 2 жыл бұрын
Can you do a video on how to count posts for certain taxonomy and show the counts in menu
@MoxetKhanPK
@MoxetKhanPK 2 жыл бұрын
You dont need code for that, take dynamic field and choose term count, it shows number of posts in a category
@nikoweb
@nikoweb Жыл бұрын
I don't get it. I made Meta box for my posts, made meta field with exact posts-count Name/ID, added function to the child theme functions.php but the count value won't go up when refreshing the post.
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Is there any cache etc plugin installed? Make sure to change the theme temporaly and apply the changes. I did the exact same thing in tutorial and it works.
@nikoweb
@nikoweb Жыл бұрын
@@MoxetKhanPK There was, tried without caching but couldn't get it to work.
@nikoweb
@nikoweb Жыл бұрын
@@MoxetKhanPK Tried it on fresh local WordPress installation and can't get it to work. Tried with normal posts and made a test CPT, doesn't update the value when visiting the page.
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
@@nikoweb Please DM me on facebook to resolve it, i saw your comments on facebook community as well.
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
please encapsulate your code in a filter as below add_filter('the_content','view_counter'); function view_counter($content) { $meta_values = get_post_meta( get_the_ID(), "post-count", true); $v2 = (int)$meta_values + 1; update_post_meta( get_the_ID(), 'post-count', $v2); }
@anamulhaque7680
@anamulhaque7680 2 ай бұрын
I did the same way how you did, but somehow not working for me.
@giand9614
@giand9614 2 ай бұрын
Add this: function increment_post_views() { if (is_single()) { $post_id = get_the_ID(); $views = get_post_meta($post_id, 'post-count', true); // If the 'post_views' meta field doesn't exist, initialize it to 1 if (empty($views)) { $views = 1; } else { $views = intval($views) + 1; } // Update the 'post_views' meta field with the incremented value update_post_meta($post_id, 'post-count', $views); } } add_action('wp', 'increment_post_views');
@waitingza1978
@waitingza1978 Ай бұрын
@@giand9614 It works. But if used with the button (count click) What do I need to add?
@niceshortschannel6742
@niceshortschannel6742 2 жыл бұрын
Kar ko allah de kamyab ka
@kingmatolo8381
@kingmatolo8381 Жыл бұрын
Unfortunately it didn't work for me. I successfully added the post count meta field and I can see it when posting or editing a custom post. I copied the code on function.php file. The problem is my view count is stuck at zero. Nothing happens . I have watch your video multiple times step by step but for some reasons it doesn't work for me.
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
please encapsulate your code in a filter as below add_filter('the_content','view_counter'); function view_counter($content) { $meta_values = get_post_meta( get_the_ID(), "post-count", true); $v2 = (int)$meta_values + 1; update_post_meta( get_the_ID(), 'post-count', $v2); }
@thomasanderson5873
@thomasanderson5873 4 ай бұрын
@@MoxetKhanPK Thank you, now is working. :)
@ShakilHossainDeveloper
@ShakilHossainDeveloper Жыл бұрын
I have no child theme what can I do now?
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
Add directly in function.php or install code snippet plugin
@Art-01
@Art-01 2 жыл бұрын
Thank you. Can you please make a video for Jet engine, about how to display multi color for product if we use Listing grid. I try to add colors to my product. Only colors. I can use color picker, but it show only one, i try to shows more then one I really hope you can help us with it. Thank you again
@MoxetKhanPK
@MoxetKhanPK 2 жыл бұрын
Can you please eleborate more, how you will use those colors?
@MoxetKhanPK
@MoxetKhanPK 2 жыл бұрын
Can you please eleborate more, how you will use those colors?
@aaizazz
@aaizazz 2 жыл бұрын
Brother Please create different playlists for relevant videos, and add that in playlists. So new commers to the channel or anyone can easily find the Videos which they want to watch
@DJTechReviews
@DJTechReviews Жыл бұрын
This needs to be refined. This doesn't work very well. I've tried multiple ways and every time it seems to be counting 3 views for every single view. Plus, if you add the filter - the content disappears. Unless you return it using "return $content"
@roppor2194
@roppor2194 2 жыл бұрын
Next video pls
@coneqto
@coneqto 11 ай бұрын
Dont work in single page :(
@karimsahraoui7216
@karimsahraoui7216 Жыл бұрын
how to diplay count of current user only
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
You can use data store for that, it counts in user meta.
@karimsahraoui7216
@karimsahraoui7216 Жыл бұрын
@@MoxetKhanPK couldn't find thanks anyway
@ProkomputerRup
@ProkomputerRup Жыл бұрын
Isn't adding 1 to view supposed to be when viewing a ticket? If you just put your code in a function, then the addition will occur when you open any page and not a specific ticket. You need to do this in function.php add cheking: if ( is_singular('ticket') ) { $meta_values = get_post_meta( get_the_ID(), "posts-count", true); $v2 = (int)$meta_values + 1; update_post_meta( get_the_ID(), 'posts-count', $v2); } maybe Im wrong
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
please encapsulate your code in a filter as below add_filter('the_content','view_counter'); function view_counter($content) { $meta_values = get_post_meta( get_the_ID(), "post-count", true); $v2 = (int)$meta_values + 1; update_post_meta( get_the_ID(), 'post-count', $v2); }
@ProkomputerRup
@ProkomputerRup Жыл бұрын
@@MoxetKhanPK in this case function view_counter will be run befor showing every records.... Why not add a function call shortcode in single CPT template "ticket" ?
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
@@ProkomputerRup it totaly depends on your requirement and the way it should execute be it in footer, header, single page or home page, for logged in for guest and so on.
@suleiman8360
@suleiman8360 2 жыл бұрын
Can we have user views
@MoxetKhanPK
@MoxetKhanPK 2 жыл бұрын
Yup! We can have the same in user meta but we need to make sure the time script load is not in CPT but user instance.
@AlexanderHernandez-nw9el
@AlexanderHernandez-nw9el Жыл бұрын
This is amazing! Could you explain how I could reset that counter every 24 hours? I have a WooCommerce shop that I'd like to display how many people have explored this product in the last 24 hours, and then have it reset after the day ends.
@MoxetKhanPK
@MoxetKhanPK Жыл бұрын
You can reset meta values throgh cron job
MEGA BOXES ARE BACK!!!
08:53
Brawl Stars
Рет қаралды 36 МЛН
Became invisible for one day!  #funny #wednesday #memes
00:25
Watch Me
Рет қаралды 53 МЛН
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 52 МЛН
WordPress Frontend Form Submit with Elementor & ACF
25:15
WPTuts
Рет қаралды 109 М.
REST API Google Sheet & Wordpress | Crocoblock JetEngine
11:11
YOTAPHONE 2 - СПУСТЯ 10 ЛЕТ
15:13
ЗЕ МАККЕРС
Рет қаралды 182 М.
Easy Art with AR Drawing App - Step by step for Beginners
0:27
Melli Art School
Рет қаралды 8 МЛН
Hisense Official Flagship Store Hisense is the champion What is going on?
0:11
Special Effects Funny 44
Рет қаралды 2,9 МЛН
Опыт использования Мини ПК от TECNO
1:00
Андронет
Рет қаралды 729 М.