I just updated from 3.6 to the latest version and to my pleasure I see that the theme’s post view counter finally works with plugin. Before the update I used the workaround as suggested by tagDIV which used the Ajax_the_views plugin and the WP-PostViews plugin. Now I want to abandon those plugins and use the Theme’s counter, but I don’t want to lose all the views on my older posts. Those views are stored in the database in the postmeta table under the meta_value views. Now I want to copy the value from views to the theme’s custom field post_views_count.
Does anyone know what query to run to make this possible? I already tried this code as suggested by Marius to someone else:
update ‘wp_postmeta’
set ‘meta_value’ = ‘views’
where ‘meta_key’ = ‘post_views_count’
Unfortunately this doesn’t work. Can someone help me out?
Hi Emil,
This is exactly how I used to update the views, but I really want to get rid of those two ajax plugins to count the views since the theme is able to do it correctly itself. So the theme reads the views from the custom field “post_views_count”, but my older posts have their view counts in the custom field “views”. I now want to use the theme’s counter, so to show the correct views on older posts I want to copy the values from the “views” custom field to the “post_views_count”. How do I do this? I want to use the theme’s counter so I can delete the two other plugins but I don’t want to lose the views on older posts!
Likely need to read up on how to duplicate a metafield in the wordpress dbase; so you can duplicate and rename the field, then delete the old one.
Outside the scope of “how to use the theme,” and has more to do with how to use phpmyadmin to create the duplicate field — lots of tutorials online on how to do this sort of thing.
Some kind soul might be willing to spend the time to spell it out here – but you might want to research this, or post a query on stackexchange ?
Maybe your right Cris and should I post this to stackexchange. I thought I could give it a shot here since the themes view counter didn’t work for a long time and alot of people, inluding me, used the workaround as suggested by tagDIV. I hadn’t updated the theme in a while and thought maybe there are people who already ditched the two extra plugins and ran into the same problem as I have now. I can’t be the only one who want to use the theme’s counter, but doesn’t want to lose the views on older posts.
I’ll just wait and maybe someone can help me out. Chris, how did you fix this problem on your sites? Or are you still using the plugins as suggested by tagDIV?
On some sites we turn off the theme counter, and use WP-PostViews — which we’ve used for years; on some sites we use the theme counter to show the count on pages, and manually change the theme counter setup file to change the field to “views” which is the datafield we’ve used for years and years (9?). Long time — I was younger then 😉
So, that way we use the existing field, keep old counts, and then theme counts “from now on.” If we turn off the theme for some reason, we switch WP-PostViews back on, which uses the “views” field, and no loss of tracking.
Anyway, that’s how I do it.
*addition:
we don’t use w3cache so, don’t need to use the “workaround” some folks are doing or the ajax counter. Since we have a dedicated server we’re running mod_pagespeed via opcache and I have 32GB of RAM to play with, not so necessary.
One annoying thing we have right now is somebody pinging our RSS feeds every 5 minutes and causing some kind of php thing to go from green to yellow EVERY 5 minutes, then every 10 minutes, then 20 minutes later; then exactly one hour later. Really weird. Can’t figure out where/what/when that is happening.
Always something 🙂
-
This reply was modified 11 years by
simchris.