WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Popular Posts
Increase post view count within code (9 posts)

  1. ozkan
    Member
    Posted 3 years ago #

    Hi,

    I need to increment post's view count by code. I looked over the forum posts but not found any related one. I need to do it inside like single.php, index.php or so.

    http://wordpress.org/extend/plugins/wordpress-popular-posts/

  2. Héctor Cabrera
    Member
    Plugin Author

    Posted 3 years ago #

    Hi ozkan,

    Sorry, I'm not following here. What do you mean by "increment post's view count by code"?

  3. ozkan
    Member
    Posted 3 years ago #

    When a post detail page is opened by user, WordPress Popular Posts plugin adds +1 to the click count of that post. What I want is to make it in a php file by writing a code like incrementPostCount(post_id); Is there a way to do it, or where should i check for that in the plugin's codes. Any help is appreciated.

    Thanks for your response.

  4. Héctor Cabrera
    Member
    Plugin Author

    Posted 3 years ago #

    I see, but why do you want to do that exactly?

  5. ozkan
    Member
    Posted 3 years ago #

    Because when a post link is clicked i want to make a redirection to another page or post, but still want that post to get its click count. So then i think the way to do it is to increment it by code, if i am not wrong.

  6. Héctor Cabrera
    Member
    Plugin Author

    Posted 3 years ago #

    Don't think you need to to that if you're using my plugin. Once the user lands on a page or post my plugin should detect it and increment the view count automatically (that is, assumming that you're redirecting them to another page or post inside your blog).

  7. ozkan
    Member
    Posted 3 years ago #

    I was expecting that too, but it didn't work like that. I put my redirection code at the end of index.php, but plugin never incremented it.
    I use this code for redirection:
    $URL="http://www.example.com";
    header ("Location: $URL");

  8. Héctor Cabrera
    Member
    Plugin Author

    Posted 3 years ago #

    Mmm that's odd. Can you please check if there's a WPP javascript code on your posts' <head> section after the redirection is done?

  9. ozkan
    Member
    Posted 3 years ago #

    No, I want to wpp_update the page that I redirected from. I mean if i click on post1 then i redirected to post2, i want post1 to get +1 pageview.
    So i guess it is not happening because the WPP javascript not even loaded and run because before it's posted to the client i make a redirect. So I think it is possible only by code. I know what I need is a little awkward, but do you have any suggestion?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic