Join the Soledad Facebook Users Group here
for Share, assistance, discussion, and Updates related to Soledad WordPress Theme.

If you can't create a new ticket - you can send us an email via our contact form and we will get back to you.

Okay
  Public Ticket #3188244
new post's view count
Closed

Comments

  •  3
    timmy2426 started the conversation

    My website is currently using the coming soon page provided by bluehost, which has not been officially released yet.

    I found that every time I edit a new post, the view count of the theme's template default kit will increase by one. As a result, the new post has just been released, and the view count is already as much as the default kit. Also, I have checked Appearance → Customize → Single Post option: Enable ajax post view count.

    1. Will it be effective if the default kit is converted into a draft?
    2. How to keep the view count of the default kit at zero?
    3. How to make the view count of a new post count from zero when it is published?

    Sincere thanks

    Attached files:  2022-12-14 15.23.45.png
      2022-12-14 15.22.47.png
      2022-12-14 15.21.36.png

  •  2,486
    PenciDesign replied

    Hi,

    Please add the following code to the Soledad child theme "functions.php" file or via the Code Snippet plugin here:

    add_action('publish_post',function($id){
        $count_key = penci_get_postviews_key();
        update_post_meta($id,$count_key,0);
    },10,1);

    Regards,
    PenciDesign.



  •  3
    timmy2426 replied

    I have added custom PHP code, but it doesn't work. Articles will show 0 the instant they load, then jump to 70. If I turn off "Enable ajax post view count.", it will show 0. If I turn on, it will show 70. please help me again on how to solve it?

    Also, I would like to know more about the meaning of the option "Enable ajax post view count". What is the difference between enabling and disabling it? I hope you can explain it to me.

    Sincerely thank you!

    Attached files:  2.png
      1.png
      3.png

  •  2,486
    PenciDesign replied

    Hi,

    For this case, please send me your WordPress admin account in a PRIVATE reply.
    I'll log in and try to help you check this problem.

    Regards,
    PenciDesign.



  •   timmy2426 replied privately
  •  2,486
    PenciDesign replied

    Hi,

    Please also send me the site URL.

    Regards,
    PenciDesign.


  •   timmy2426 replied privately
  •   timmy2426 replied privately
  •  2,486
    PenciDesign replied

    Hi,

    I've updated the code.

    Please check.

    Regards,
    PenciDesign.


  •   timmy2426 replied privately
  •  2,486
    PenciDesign replied

    Hi,

    I've re-updated the code for your site.

    Please create a new post then check again.

    Regards,
    PenciDesign.


  •  3
    timmy2426 replied

    Still not working. The newly created post test4 still shows 74 views on the post content page, and now the number won't increase even after reorganization. But I found that in the backend I can see that the number of post views is 0. Please check the screenshot 1.

    I guess there is something wrong with the code of "Enable ajax post view count."? Also for the template page, can its view count be fixed at 0? Otherwise, every time a new post is published, the number of views will be increased a lot, and then the number will be increased infinitely, and then the number of views will be the same for the published post.Please check the screenshot 2.

    Attached files:  2.png
      1.png

  •  2,486
    PenciDesign replied

    Hi,

    This is a problem with the system cache.

    I've fixed this issue.

    Please check.

    Regards,
    PenciDesign.


  •  3
    timmy2426 replied

    Thank you very much, it worked!
    In order to avoid similar problems in the future, I would also like to ask the following questions.

    1. what is the system cache you mentioned? Do I need to clean it again in the future? How do I clean it up?

    2. Do I need to keep the custom function code that you wrote in functions.php before?

    3. Is this a problem with the theme itself and will it need to be updated in the future?

  •  2,486
    PenciDesign replied

    Hi,

    1. The cache I've mentioned is your hosting/server cache included in the WordPress core,

    2. You should keep the custom code on the functions.php file,

    3. No. Soledad theme counter will be increased for all users when you post loaded. The code I've added in the functions.php will clear all the post counters after you've clicked the Publish button and not count for admin.

    Regards,
    PenciDesign.


  •  3
    timmy2426 replied

    According to your reply, is there a UI interface to clear the system cache in the wp background? Or did you modify WordPress core files? In this way, when the next wp is updated, will the problem of viewing count happen again? How can I prevent this problem from reappearing due to wp core updates, or any plugin and theme updates?

    Thank you very much for your detailed explanation.

  •  2,486
    PenciDesign replied

    Hi,

    1. Please read this article to understand how to clear the cache: https://www.bluehost.com/help/article/wordpress-how-to-use-our-page-caching-feature

    2. This problem never appears in a future updates.

    Regards,
    PenciDesign.

  •  3
    timmy2426 replied

    I know this, I tried clicking the "Clear Everything" button before asking, but nothing happened, and the page didn't reload. Did you click the "Clear Everything" button to fix this? At the moment of clicking, is the web page reloaded?

  •  3
    timmy2426 replied

    Did you turn off the Caching setting to fix the problem?

  •  2,486
    PenciDesign replied

    Hi,

    Yes. I've turned it off for dev mode.

    Regards,
    PenciDesign.


  •  3
    timmy2426 replied

    If I open Bluehost > Caching setting again, will the problem with the view count arise again?

  •  2,486
    PenciDesign replied

    Hi,

    No. I've permanently fixed this issue.

    Regards,
    PenciDesign.

  •  3
    timmy2426 replied

    I have understood it completely, thank you for your help.

  •  3
    timmy2426 replied

    I updated the theme yesterday, then new post's view count as long as the admin refreshes the article, it will automatically increase once the number of records. The previous problem has reappeared.

    Attached files:  2.jpg
      1.jpg

  •   timmy2426 replied privately
  •  2,486
    PenciDesign replied

    Hi,

    I've re-update your site.

    Please check.

    Regards,
    PenciDesign.


  •  3
    timmy2426 replied

    Can you tell me how you did it? I tried to clear the browser and WP cache from the web side as well as the host side, but it still doesn't work. I would like to know how you solved this problem.

  •  2,486
    PenciDesign replied

    Hi,

    I've modified some template files. We'll consider adding this as an option in the next update.

    Regards,
    PenciDesign.


  •  3
    timmy2426 replied

    Great! I hope that in the next update, the two features of zero view count when posting and the site not counting the view count of admins will be optional in the GUI.

    If this feature is really available by then, can the code of the current "functions.php" file on my site be deleted?

  •  2,486
    PenciDesign replied

    Hi,

    You can delete all the custom codes after updating Soledad in the future.

    Regards,
    PenciDesign.


  •  3
    timmy2426 replied

    Ok, thank you for your reply, looking forward to the next update.