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

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • 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/...
    Download Crocoblock:
    crocoblock.com...
    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/peru...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 154

  • @brink6876
    @brink6876 2 ปีที่แล้ว +5

    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  2 ปีที่แล้ว +3

      Thank you for your interest and visting the channel, will try my best to share more valuable tutorials in future :)
      Keep in touch please

  • @mauricioalejandro7329
    @mauricioalejandro7329 2 ปีที่แล้ว +2

    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  2 ปีที่แล้ว +5

      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);
      }

  • @jernias637
    @jernias637 4 หลายเดือนก่อน

    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.

  • @michaelj.9401
    @michaelj.9401 ปีที่แล้ว +1

    Works great, thanks;
    does not work with caching plugin, possible to do the same thing in AJAX or JS? Thanks

  • @isaacosei8299
    @isaacosei8299 6 หลายเดือนก่อน

    Your channel and content!! Thank you for sharing this, you don't understand how beneficial it has been! Blessings to you.

  • @PhạmHồngAnh-f2i
    @PhạmHồngAnh-f2i 2 หลายเดือนก่อน

    Thank you so much for solution. You have solution for display post view for CCT?

  • @mauricioalejandro7329
    @mauricioalejandro7329 2 ปีที่แล้ว +1

    Excellent!! Thanks for sharing your knowledge!
    Query:
    *Is it possible to make a listing impression counter?

    • @MoxetKhanPK
      @MoxetKhanPK  2 ปีที่แล้ว +1

      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 2 ปีที่แล้ว

      @@MoxetKhanPK it would be great

  • @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  ปีที่แล้ว +1

      Hello, use JetEngine data store for that, it counts for logged in users.

    • @acarolalvarenga
      @acarolalvarenga ปีที่แล้ว

      @@MoxetKhanPK thank you, I'll check that up!

  • @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.

  • @cookie9250
    @cookie9250 2 ปีที่แล้ว +1

    Views count worked for me.... Thanks

  • @juan07241981
    @juan07241981 2 ปีที่แล้ว +2

    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 TH-cam

    • @MoxetKhanPK
      @MoxetKhanPK  2 ปีที่แล้ว

      Muchas gracias por tu interés. Por favor, manténgase en contacto para más videos.

  • @toygarniron
    @toygarniron 2 ปีที่แล้ว +1

    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

  • @SixGamerHeads
    @SixGamerHeads 2 ปีที่แล้ว +2

    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  2 ปีที่แล้ว

      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.

  • @MuhammadBilal-oc6pi
    @MuhammadBilal-oc6pi 6 หลายเดือนก่อน

    Moxet Khan, you are Gem...........
    thanks for such good content...
    Please make videos as soon as possible....

  • @serdimay7
    @serdimay7 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +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

  • @soyeb_ali
    @soyeb_ali 2 ปีที่แล้ว +1

    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.

  • @ProkomputerRup
    @ProkomputerRup 2 ปีที่แล้ว +1

    Thanks for receipe. How about caching plugin? Will be This works?

    • @MoxetKhanPK
      @MoxetKhanPK  2 ปีที่แล้ว

      Not sure, need to test it.

  • @mohamedalarabe1330
    @mohamedalarabe1330 2 ปีที่แล้ว +5

    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 7 หลายเดือนก่อน +1

      same here. doesnt work on a single page/single post.

    • @chris_reyem
      @chris_reyem 7 หลายเดือนก่อน

      ​@@thomasanderson5873

    • @chris_reyem
      @chris_reyem 7 หลายเดือนก่อน

      // 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');

  • @werbeagenturpr-pro5197
    @werbeagenturpr-pro5197 2 ปีที่แล้ว +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  2 ปีที่แล้ว +1

      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

  • @mrshesek
    @mrshesek 2 ปีที่แล้ว +1

    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?

  • @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!!

  • @1WOWACC
    @1WOWACC 6 หลายเดือนก่อน

    Great, I hope you continue to develop content about Jetengine

  • @brusbezerra
    @brusbezerra 10 หลายเดือนก่อน

    Great tutorial, thanks! What about if we want to count viewers by session, not unique views?

    • @MoxetKhanPK
      @MoxetKhanPK  10 หลายเดือนก่อน +1

      So someone refresh the page 5 times but it counts 1?

    • @brusbezerra
      @brusbezerra 10 หลายเดือนก่อน

      @@MoxetKhanPK yes

  • @DomenicoMastroianni
    @DomenicoMastroianni 2 ปีที่แล้ว

    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.

  • @dariondanielscreative
    @dariondanielscreative 2 ปีที่แล้ว +1

    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/

  • @outlandermax
    @outlandermax 2 ปีที่แล้ว

    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!

  • @michelfayadat1888
    @michelfayadat1888 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      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 !

  • @Ellinio
    @Ellinio 2 ปีที่แล้ว

    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  2 ปีที่แล้ว

      Hello Thank you for your interest, not sure what is wrong exactly but you can install code snippet and insert over there.

  • @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

  • @antonichristian5845
    @antonichristian5845 2 ปีที่แล้ว

    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  2 ปีที่แล้ว

      Yes why not, goto query builder and fetch your data sort by most views descending.

  • @Website-Developer
    @Website-Developer 4 หลายเดือนก่อน

    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  4 หลายเดือนก่อน +1

      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 4 หลายเดือนก่อน

      @@MoxetKhanPK Thank you, and what if I have 10 users with user-role1? Will it determine how many posts each user has?

    • @MoxetKhanPK
      @MoxetKhanPK  4 หลายเดือนก่อน +1

      @@Website-Developer yes it will determine

    • @Website-Developer
      @Website-Developer 4 หลายเดือนก่อน

      @@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  4 หลายเดือนก่อน +1

      @@Website-Developer It can be used for multiple user role as well.

  • @eacc95
    @eacc95 2 ปีที่แล้ว

    Great video. Question, what should I do if I don't want admin views to count? Thanks in advance

    • @MoxetKhanPK
      @MoxetKhanPK  2 ปีที่แล้ว

      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

  • @jenniferward6821
    @jenniferward6821 2 ปีที่แล้ว +1

    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 TH-cam and found nothing at all.

    • @MoxetKhanPK
      @MoxetKhanPK  2 ปีที่แล้ว +1

      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?

  • @toygarniron
    @toygarniron 2 ปีที่แล้ว +1

    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;
      }

  • @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?

  • @iemvo9629
    @iemvo9629 2 ปีที่แล้ว +1

    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

  • @michaelakubas
    @michaelakubas ปีที่แล้ว +1

    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.

  • @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?

  • @MoxetKhanPK
    @MoxetKhanPK  2 ปีที่แล้ว +3

    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 2 ปีที่แล้ว

      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  2 ปีที่แล้ว

      @@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 2 ปีที่แล้ว +1

      @@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.

  • @WawanInt
    @WawanInt 2 ปีที่แล้ว +1

    Its so awesome..thanks🙏

  • @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!

  • @TiagoMBarreto
    @TiagoMBarreto 2 ปีที่แล้ว

    Thanks for this video Bro, Congrats!

  • @mrveeto6655
    @mrveeto6655 8 หลายเดือนก่อน

    I'm using the Hello Elementor but don't have the child theme.. how to create the child theme?

    • @mrveeto6655
      @mrveeto6655 7 หลายเดือนก่อน

      this method not working when i test

  • @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

  • @DavidMurrin77
    @DavidMurrin77 ปีที่แล้ว

    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 3 หลายเดือนก่อน

      Run the code in the frontend only. Use code snippet plugin.

  • @anumnetwork
    @anumnetwork ปีที่แล้ว

    Nice Sir ... Thank You

  • @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 ปีที่แล้ว +1

      Can you please eleborate more, how you will use those colors?

  • @simeon.benevrekov
    @simeon.benevrekov 2 ปีที่แล้ว

    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  2 ปีที่แล้ว

      Did you tried to make meta boxes inside CPT instead of creating individual meta

    • @simeon.benevrekov
      @simeon.benevrekov 2 ปีที่แล้ว

      @@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  2 ปีที่แล้ว

      @@simeon.benevrekov i ll try it with latest version of jetengine.

    • @MoxetKhanPK
      @MoxetKhanPK  2 ปีที่แล้ว

      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);
      }

  • @seekknowledge1928
    @seekknowledge1928 2 ปีที่แล้ว

    Its an amazing video tutorial.. Please make a video how to build user profile ( Dashboard / login / sign up) by Crocoblock

  • @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

  • @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  ปีที่แล้ว +1

      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

  • @nikoweb
    @nikoweb 2 ปีที่แล้ว

    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  2 ปีที่แล้ว

      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 2 ปีที่แล้ว

      @@MoxetKhanPK There was, tried without caching but couldn't get it to work.

    • @nikoweb
      @nikoweb 2 ปีที่แล้ว

      @@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  2 ปีที่แล้ว +1

      @@nikoweb Please DM me on facebook to resolve it, i saw your comments on facebook community as well.

    • @MoxetKhanPK
      @MoxetKhanPK  2 ปีที่แล้ว

      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);
      }

  • @kingmatolo8381
    @kingmatolo8381 2 ปีที่แล้ว

    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  2 ปีที่แล้ว +1

      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 7 หลายเดือนก่อน

      @@MoxetKhanPK Thank you, now is working. :)

  • @Muhammadkhan-uf4cl
    @Muhammadkhan-uf4cl ปีที่แล้ว

    you are the king

  • @webstep4677
    @webstep4677 2 ปีที่แล้ว +1

    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  2 ปีที่แล้ว +1

      Hi, need to check it thoroughly.
      Please contact via email.

  • @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"

  • @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]

  • @ProkomputerRup
    @ProkomputerRup 2 ปีที่แล้ว

    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  2 ปีที่แล้ว +1

      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 2 ปีที่แล้ว

      @@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  2 ปีที่แล้ว

      @@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.

  • @АнтонКравченко-в7п
    @АнтонКравченко-в7п 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

  • @purnendu.mukherjee
    @purnendu.mukherjee ปีที่แล้ว

    You are just awesome

  • @sergixelmusic6748
    @sergixelmusic6748 2 ปีที่แล้ว

    If it's possible to reset the meta field 'posts-count' each 30 days to 0?

    • @MoxetKhanPK
      @MoxetKhanPK  2 ปีที่แล้ว

      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.

  • @muhammadaslan6256
    @muhammadaslan6256 ปีที่แล้ว

    how we can do that for woocommerce prodcuts count and sales to show how much was sold this product

    • @MoxetKhanPK
      @MoxetKhanPK  ปีที่แล้ว

      Use query builder instead, run a query which count products in orders table.

    • @muhammadaslan6256
      @muhammadaslan6256 ปีที่แล้ว

      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

  • @shakibkhan1921
    @shakibkhan1921 2 ปีที่แล้ว

    Please Make basic to advance tutorial on Jet Plugins

  • @anamulhaque7680
    @anamulhaque7680 5 หลายเดือนก่อน

    I did the same way how you did, but somehow not working for me.

    • @giand9614
      @giand9614 5 หลายเดือนก่อน +1

      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 4 หลายเดือนก่อน

      @@giand9614 It works. But if used with the button (count click) What do I need to add?

  • @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

  • @DeveloperPromise
    @DeveloperPromise 5 หลายเดือนก่อน

    good

  • @ShakilHossainDeveloper
    @ShakilHossainDeveloper 2 ปีที่แล้ว

    I have no child theme what can I do now?

    • @MoxetKhanPK
      @MoxetKhanPK  2 ปีที่แล้ว

      Add directly in function.php or install code snippet plugin

  • @coneqto
    @coneqto ปีที่แล้ว

    Dont work in single page :(

  • @ZiabisMotors
    @ZiabisMotors 3 หลายเดือนก่อน

    2024 no funciona :( Lo hecho tal como explicas en tu video

  • @karimsahraoui7216
    @karimsahraoui7216 ปีที่แล้ว

    how to diplay count of current user only

    • @MoxetKhanPK
      @MoxetKhanPK  ปีที่แล้ว +1

      You can use data store for that, it counts in user meta.

    • @karimsahraoui7216
      @karimsahraoui7216 ปีที่แล้ว

      @@MoxetKhanPK couldn't find thanks anyway

  • @ramdaniamarulloh6505
    @ramdaniamarulloh6505 2 ปีที่แล้ว

    Thanks you broo

  • @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.

  • @niceshortschannel6742
    @niceshortschannel6742 2 ปีที่แล้ว

    Kar ko allah de kamyab ka

  • @roppor2194
    @roppor2194 2 ปีที่แล้ว

    Next video pls

  • @baobabmart
    @baobabmart หลายเดือนก่อน

    not working
    $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);